+ //%%%%%% test code
+ case ADMIN_ESTABLISH_SA_VPNCONTROL:
+ {
+ struct admin_com_psk *acp;
+ char *data;
+ struct sockaddr *dst;
+ struct bound_addr *target;
+
+ com->ac_errno = -1;
+
+ acp = (struct admin_com_psk *)
+ ((char *)com + sizeof(*com) +
+ sizeof(struct admin_com_indexes));
+
+ target = (struct bound_addr *)racoon_malloc(sizeof(struct bound_addr));
+ if (target == NULL) {
+ plog(LLV_ERROR, LOCATION, NULL,
+ "cannot allocate memory: %s\n",
+ strerror(errno));
+ break;
+ }
+
+ if ((id = vmalloc(acp->id_len)) == NULL) {
+ plog(LLV_ERROR, LOCATION, NULL,
+ "cannot allocate memory: %s\n",
+ strerror(errno));
+ goto outofhere;
+ }
+ data = (char *)(acp + 1);
+ memcpy(id->v, data, id->l);
+
+ if ((key = vmalloc(acp->key_len)) == NULL) {
+ plog(LLV_ERROR, LOCATION, NULL,
+ "cannot allocate memory: %s\n",
+ strerror(errno));
+ vfree(id);
+ id = NULL;
+ goto outofhere;
+ }
+ data = (char *)(data + acp->id_len);
+ memcpy(key->v, data, key->l);
+
+ dst = (struct sockaddr *)
+ &((struct admin_com_indexes *)
+ ((caddr_t)com + sizeof(*com)))->dst;
+
+ // assume IPv4
+ target->address = ((struct sockaddr_in *)dst)->sin_addr.s_addr;
+
+#ifdef ENABLE_HYBRID
+ /* Set the id and key */
+ if (id && key) {
+
+ target->user_id = id;
+ target->user_pw = key;
+ }
+#endif
+ vpn_connect(target);
+ com->ac_errno = 0;
+outofhere:
+ if (target->user_id != NULL)
+ vfree(target->user_id);
+ if (target->user_pw != NULL)
+ vfree(target->user_pw);
+ if (target != NULL)
+ racoon_free(target);
+ break;
+ }
+