+ 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;
+}
+
+int send_del_subnet(connection_t *cl, subnet_t *subnet)
+{
+ int x;
+ char *netstr;
+ char *owner;
+cp
+ if(cl->options & OPTION_INDIRECT)
+ owner = myself->name;
+ else
+ owner = subnet->owner->name;
+
+ x = send_request(cl, "%d %s %s", DEL_SUBNET, owner, netstr = net2str(subnet));
+ free(netstr);
+cp
+ return x;