+ char subnetstr[MAX_STRING_SIZE];
+ char name[MAX_STRING_SIZE];
+ connection_t *owner, *p;
+ subnet_t *subnet;
+ avl_node_t *node;
+cp
+ if(sscanf(cl->buffer, "%*d "MAX_STRING" "MAX_STRING, name, subnetstr) != 2)
+ {
+ syslog(LOG_ERR, _("Got bad ADD_SUBNET from %s (%s)"), cl->name, cl->hostname);
+ return -1;
+ }
+
+ /* Check if owner name is a valid */
+
+ if(check_id(name))
+ {
+ syslog(LOG_ERR, _("Got bad ADD_SUBNET from %s (%s): invalid identity name"), cl->name, cl->hostname);
+ return -1;
+ }
+
+ /* Check if subnet string is valid */
+
+ if(!(subnet = str2net(subnetstr)))
+ {
+ syslog(LOG_ERR, _("Got bad ADD_SUBNET from %s (%s): invalid subnet string"), cl->name, cl->hostname);
+ return -1;
+ }
+
+ /* Check if somebody tries to add a subnet of ourself */
+
+ if(!strcmp(name, myself->name))
+ {
+ syslog(LOG_ERR, _("Warning: got ADD_SUBNET from %s (%s) for ourself, restarting"),
+ cl->name, cl->hostname);
+ sighup = 1;
+ return 0;
+ }
+
+ /* Check if the owner of the new subnet is in the connection list */
+
+ if(!(owner = lookup_id(name)))
+ {
+ syslog(LOG_ERR, _("Got ADD_SUBNET for %s from %s (%s) which is not in our connection list"),
+ name, cl->name, cl->hostname);
+ return -1;
+ }
+
+ /* If everything is correct, add the subnet to the list of the owner */
+
+ subnet_add(owner, subnet);
+
+ /* Tell the rest */
+
+ for(node = connection_tree->head; node; node = node->next)
+ {
+ p = (connection_t *)node->data;
+ if(p->status.meta && p->status.active && p!= cl)
+ send_add_subnet(p, subnet);
+ }
+cp
+ return 0;