along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: net.c,v 1.35.4.110 2001/05/28 08:56:57 guus Exp $
+ $Id: net.c,v 1.35.4.113 2001/06/05 19:45:47 guus Exp $
*/
#include "config.h"
int keylifetime = 0;
int keyexpires = 0;
-char *unknown = NULL;
-
void send_udppacket(connection_t *cl, vpn_packet_t *inpkt)
{
vpn_packet_t outpkt;
outlen += outpad;
outpkt.len = outlen - sizeof(outpkt.salt);
+ total_socket_in += outlen;
+
receive_packet(cl, &outpkt);
cp
}
send_udppacket(cl, packet);
}
+/* Broadcast a packet to all active connections */
+
+void broadcast_packet(connection_t *from, vpn_packet_t *packet)
+{
+ avl_node_t *node;
+ connection_t *cl;
+cp
+ if(debug_lvl >= DEBUG_TRAFFIC)
+ syslog(LOG_INFO, _("Broadcasting packet of %d bytes from %s (%s)"),
+ packet->len, from->name, from->hostname);
+
+ for(node = connection_tree->head; node; node = node->next)
+ {
+ cl = (connection_t *)node->data;
+ if(cl->status.meta && cl != from)
+ send_packet(cl, packet);
+ }
+cp
+}
+
void flush_queue(connection_t *cl)
{
list_node_t *node, *next;
cp
myself = new_connection();
- asprintf(&myself->hostname, "MYSELF");
+ asprintf(&myself->hostname, _("MYSELF"));
myself->options = 0;
myself->protocol_version = PROT_CURRENT;
else
myself->port = cfg->data.val;
- if((cfg = get_config_val(myself->config, config_indirectdata)))
- if(cfg->data.val == stupid_true)
- myself->options |= OPTION_INDIRECT;
-
- if((cfg = get_config_val(myself->config, config_tcponly)))
- if(cfg->data.val == stupid_true)
- myself->options |= OPTION_TCPONLY;
-
/* Read in all the subnets specified in the host configuration file */
for(next = myself->config; (cfg = get_config_val(next, config_subnet)); next = cfg->next)
subnet_add(myself, net);
}
+cp
+ /* Check some options */
+
+ if((cfg = get_config_val(config, config_indirectdata)))
+ if(cfg->data.val == stupid_true)
+ myself->options |= OPTION_INDIRECT;
+
+ if((cfg = get_config_val(config, config_tcponly)))
+ if(cfg->data.val == stupid_true)
+ myself->options |= OPTION_TCPONLY;
+
+ if((cfg = get_config_val(myself->config, config_indirectdata)))
+ if(cfg->data.val == stupid_true)
+ myself->options |= OPTION_INDIRECT;
+
+ if((cfg = get_config_val(myself->config, config_tcponly)))
+ if(cfg->data.val == stupid_true)
+ myself->options |= OPTION_TCPONLY;
+
+ if(myself->options & OPTION_TCPONLY)
+ myself->options |= OPTION_INDIRECT;
+
+ if((cfg = get_config_val(config, config_mode)))
+ {
+ if(!strcasecmp(cfg->data.ptr, "router"))
+ routing_mode = RMODE_ROUTER;
+ else if (!strcasecmp(cfg->data.ptr, "switch"))
+ routing_mode = RMODE_SWITCH;
+ else if (!strcasecmp(cfg->data.ptr, "hub"))
+ routing_mode = RMODE_HUB;
+ else
+ {
+ syslog(LOG_ERR, _("Invalid routing mode!"));
+ return -1;
+ }
+ }
+ else
+ routing_mode = RMODE_ROUTER;
+
+cp
+ /* Open sockets */
+
if((myself->meta_socket = setup_listen_meta_socket(myself->port)) < 0)
{
syslog(LOG_ERR, _("Unable to set up a listening TCP socket!"));
keyexpires = time(NULL) + keylifetime;
cp
- /* Check some options */
-
- if((cfg = get_config_val(config, config_indirectdata)))
- {
- if(cfg->data.val == stupid_true)
- myself->options |= OPTION_INDIRECT;
- }
-
- if((cfg = get_config_val(config, config_tcponly)))
- {
- if(cfg->data.val == stupid_true)
- myself->options |= OPTION_TCPONLY;
- }
-
- if(myself->options & OPTION_TCPONLY)
- myself->options |= OPTION_INDIRECT;
/* Activate ourselves */
return NULL;
}
- p->name = unknown;
+ asprintf(&p->name, _("UNKNOWN"));
p->address = ntohl(ci.sin_addr.s_addr);
p->hostname = hostlookup(ci.sin_addr.s_addr);
p->port = htons(ci.sin_port); /* This one will be overwritten later */