+void
+isakmp_unity_reply(iph1, attr)
+ phase1_handle_t *iph1;
+ struct isakmp_data *attr;
+{
+ int type = ntohs(attr->type);
+ int alen = ntohs(attr->lorv);
+
+ type &= ~ISAKMP_GEN_MASK;
+
+ struct unity_network *network = (struct unity_network *)(attr + 1);
+ int index = 0;
+ int count = 0;
+
+ switch(type) {
+ case UNITY_SPLIT_INCLUDE:
+ {
+ if ((iph1->mode_cfg->flags & ISAKMP_CFG_GOT_SPLIT_INCLUDE) == 0) {
+ if (alen)
+ count = alen / sizeof(struct unity_network);
+
+ for(;index < count; index++)
+ splitnet_list_add(
+ &iph1->mode_cfg->split_include,
+ &network[index],
+ &iph1->mode_cfg->include_count);
+
+ iph1->mode_cfg->flags |= ISAKMP_CFG_GOT_SPLIT_INCLUDE;
+ }
+ break;
+ }
+ case UNITY_LOCAL_LAN:
+ {
+ if ((iph1->mode_cfg->flags & ISAKMP_CFG_GOT_SPLIT_LOCAL) == 0) {
+ if (alen)
+ count = alen / sizeof(struct unity_network);
+
+ for(;index < count; index++)
+ splitnet_list_add(
+ &iph1->mode_cfg->split_local,
+ &network[index],
+ &iph1->mode_cfg->local_count);
+
+ iph1->mode_cfg->flags |= ISAKMP_CFG_GOT_SPLIT_LOCAL;
+ }
+ break;
+ }
+ case UNITY_PFS:
+ {
+ break;
+ }
+ case UNITY_SPLITDNS_NAME:
+ case UNITY_BANNER:
+ case UNITY_SAVE_PASSWD:
+ case UNITY_NATT_PORT:
+ case UNITY_FW_TYPE:
+ case UNITY_BACKUP_SERVERS:
+ case UNITY_DDNS_HOSTNAME:
+ default:
+ plog(ASL_LEVEL_WARNING,
+ "Ignored attribute %s\n",
+ s_isakmp_cfg_type(type));
+ break;
+ }
+ return;
+}
+
+static vchar_t *
+isakmp_cfg_split(iph1, attr, netentry, count)
+ phase1_handle_t *iph1;
+ struct isakmp_data *attr;
+ struct unity_netentry *netentry;
+ int count;
+{
+ vchar_t *buffer;
+ struct isakmp_data *new;
+ struct unity_network * network;
+ size_t len;
+ int index = 0;
+
+ char tmp1[40];
+ char tmp2[40];
+
+ len = sizeof(struct unity_network) * count;
+ if ((buffer = vmalloc(sizeof(*attr) + len)) == NULL) {
+ plog(ASL_LEVEL_ERR, "Cannot allocate memory\n");
+ return NULL;
+ }
+
+ new = (struct isakmp_data *)buffer->v;
+ new->type = attr->type;
+ new->lorv = htons(len);
+
+ network = (struct unity_network *)(new + 1);
+ for (; index < count; index++) {
+
+ memcpy(&network[index],
+ &netentry->network,
+ sizeof(struct unity_network));
+
+ inet_ntop(AF_INET, &netentry->network.addr4, tmp1, 40);
+ inet_ntop(AF_INET, &netentry->network.mask4, tmp2, 40);
+ plog(ASL_LEVEL_DEBUG, "splitnet: %s/%s\n", tmp1, tmp2);
+
+ netentry = netentry->next;
+ }
+
+ return buffer;
+}
+
+int splitnet_list_add(list, network, count)
+ struct unity_netentry ** list;
+ struct unity_network * network;
+ int *count;
+{
+ struct unity_netentry * newentry;
+
+ /*
+ * allocate new netentry and copy
+ * new splitnet network data
+ */
+ newentry = (struct unity_netentry *)
+ racoon_malloc(sizeof(struct unity_netentry));
+ if (newentry == NULL)
+ return -1;
+
+ memcpy(&newentry->network,network,
+ sizeof(struct unity_network));
+ newentry->next = NULL;
+
+ /*
+ * locate the last netentry in our
+ * splitnet list and add our entry
+ */
+ if (*list == NULL)
+ *list = newentry;
+ else {
+ struct unity_netentry * tmpentry = *list;
+ while (tmpentry->next != NULL)
+ tmpentry = tmpentry->next;
+ tmpentry->next = newentry;
+ }
+
+ (*count)++;
+
+ return 0;
+}
+
+void splitnet_list_free(list, count)
+ struct unity_netentry * list;
+ int *count;
+{
+ struct unity_netentry * netentry = list;
+ struct unity_netentry * delentry;
+
+ *count = 0;
+
+ while (netentry != NULL) {
+ delentry = netentry;
+ netentry = netentry->next;
+ racoon_free(delentry);
+ }
+}
+
+char * splitnet_list_2str(list)
+ struct unity_netentry * list;
+{
+ struct unity_netentry * netentry;
+ char tmp1[40];
+ char tmp2[40];
+ char * str;
+ int len;
+ int print_len;
+ int rc;
+
+ /* determine string length */
+ len = 0;
+ netentry = list;
+ while (netentry != NULL) {
+
+ inet_ntop(AF_INET, &netentry->network.addr4, tmp1, 40);
+ inet_ntop(AF_INET, &netentry->network.mask4, tmp2, 40);
+ len += strlen(tmp1);
+ len += strlen(tmp2);
+ len += 2;
+
+ netentry = netentry->next;
+ }
+
+ /* allocate network list string */
+ str = racoon_malloc(len);
+ if (str == NULL)
+ return NULL;