along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: protocol_subnet.c,v 1.1.4.14 2003/07/22 20:55:20 guus Exp $
+ $Id: protocol_subnet.c,v 1.1.4.17 2003/11/17 15:30:18 guus Exp $
*/
#include "system.h"
#include "utils.h"
#include "xalloc.h"
-bool send_add_subnet(connection_t *c, subnet_t *subnet)
+bool send_add_subnet(connection_t *c, const subnet_t *subnet)
{
bool x;
char *netstr;
node_add(owner);
}
+ if(tunnelserver && owner != myself && owner != c->node)
+ return false;
+
/* Check if we already know this subnet */
if(lookup_subnet(owner, s)) {
return true;
}
+ /* In tunnel server mode, check if the subnet matches one in the config file of this node */
+
+ if(tunnelserver) {
+ config_t *cfg;
+ subnet_t *allowed;
+
+ for(cfg = lookup_config(c->config_tree, "Subnet"); cfg; cfg = lookup_config_next(c->config_tree, cfg)) {
+ if(!get_config_subnet(cfg, &allowed))
+ return false;
+
+ if(!subnet_compare(s, allowed))
+ break;
+
+ free_subnet(allowed);
+ }
+
+ if(!cfg)
+ return false;
+
+ free_subnet(allowed);
+ }
+
/* If everything is correct, add the subnet to the list of the owner */
subnet_add(owner, s);
/* Tell the rest */
- forward_request(c);
+ if(!tunnelserver)
+ forward_request(c);
return true;
}
-bool send_del_subnet(connection_t *c, subnet_t *s)
+bool send_del_subnet(connection_t *c, const subnet_t *s)
{
bool x;
char *netstr;
return true;
}
+ if(tunnelserver && owner != myself && owner != c->node)
+ return false;
+
/* Check if subnet string is valid */
s = str2net(subnetstr);
/* Tell the rest */
- forward_request(c);
+ if(!tunnelserver)
+ forward_request(c);
/* Finally, delete it. */