- Reinstated a queue for outgoing packets.
This commit is contained in:
		
							parent
							
								
									049ff67817
								
							
						
					
					
						commit
						07a08f5539
					
				
					 9 changed files with 119 additions and 211 deletions
				
			
		|  | @ -17,7 +17,7 @@ | |||
|     along with this program; if not, write to the Free Software | ||||
|     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| 
 | ||||
|     $Id: connection.c,v 1.1.2.7 2001/01/05 23:53:49 guus Exp $ | ||||
|     $Id: connection.c,v 1.1.2.8 2001/01/07 15:25:40 guus Exp $ | ||||
| */ | ||||
| 
 | ||||
| #include "config.h" | ||||
|  | @ -26,6 +26,7 @@ | |||
| #include <syslog.h> | ||||
| 
 | ||||
| #include <avl_tree.h> | ||||
| #include <list.h> | ||||
| 
 | ||||
| #include "net.h"	/* Don't ask. */ | ||||
| #include "netutl.h" | ||||
|  | @ -77,6 +78,7 @@ connection_t *new_connection(void) | |||
|   connection_t *p = (connection_t *)xmalloc_and_zero(sizeof(*p)); | ||||
| cp | ||||
|   p->subnet_tree = avl_alloc_tree((avl_compare_t)subnet_compare, NULL); | ||||
|   p->queue = list_alloc((list_action_t)free); | ||||
| cp | ||||
|   return p; | ||||
| } | ||||
|  | @ -84,10 +86,8 @@ cp | |||
| void free_connection(connection_t *p) | ||||
| { | ||||
| cp | ||||
|   if(p->sq) | ||||
|     destroy_queue(p->sq); | ||||
|   if(p->rq) | ||||
|     destroy_queue(p->rq); | ||||
|   if(p->queue) | ||||
|     list_delete_list(p->queue); | ||||
|   if(p->name && p->name!=unknown) | ||||
|     free(p->name); | ||||
|   if(p->hostname) | ||||
|  |  | |||
|  | @ -17,13 +17,14 @@ | |||
|     along with this program; if not, write to the Free Software | ||||
|     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| 
 | ||||
|     $Id: connection.h,v 1.1.2.4 2001/01/05 23:53:49 guus Exp $ | ||||
|     $Id: connection.h,v 1.1.2.5 2001/01/07 15:25:41 guus Exp $ | ||||
| */ | ||||
| 
 | ||||
| #ifndef __TINC_CONNECTION_H__ | ||||
| #define __TINC_CONNECTION_H__ | ||||
| 
 | ||||
| #include <avl_tree.h> | ||||
| #include <list.h> | ||||
| 
 | ||||
| #include "config.h" | ||||
| 
 | ||||
|  | @ -74,16 +75,12 @@ typedef struct connection_t { | |||
|   int socket;                      /* our udp vpn socket */ | ||||
|   int meta_socket;                 /* our tcp meta socket */ | ||||
|   status_bits_t status;            /* status info */ | ||||
|   packet_queue_t *sq;              /* pending outgoing packets */ | ||||
|   packet_queue_t *rq;              /* pending incoming packets (they have no
 | ||||
| 				      valid key to be decrypted with) */ | ||||
|   RSA *rsa_key;                    /* the public/private key */ | ||||
| 
 | ||||
|   RSA *rsa_key;                    /* the public/private key */ | ||||
|   EVP_CIPHER_CTX *cipher_inctx;    /* Context of encrypted meta data that will come from him to us */ | ||||
|   EVP_CIPHER_CTX *cipher_outctx;   /* Context of encrypted meta data that will be sent from us to him */ | ||||
|   char *cipher_inkey;              /* His symmetric meta key */ | ||||
|   char *cipher_outkey;             /* Our symmetric meta key */ | ||||
| 
 | ||||
|   EVP_CIPHER *cipher_pkttype;      /* Cipher type for encrypted vpn packets */  | ||||
|   char *cipher_pktkey;             /* Cipher key and iv */ | ||||
|   int cipher_pktkeylength;         /* Cipher key and iv length*/ | ||||
|  | @ -95,6 +92,8 @@ typedef struct connection_t { | |||
| 
 | ||||
|   time_t last_ping_time;           /* last time we saw some activity from the other end */   | ||||
| 
 | ||||
|   list_t *queue;                   /* Queue for packets awaiting to be encrypted */ | ||||
| 
 | ||||
|   char *mychallenge;               /* challenge we received from him */ | ||||
|   char *hischallenge;              /* challenge we sent to him */ | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										168
									
								
								src/net.c
									
										
									
									
									
								
							
							
						
						
									
										168
									
								
								src/net.c
									
										
									
									
									
								
							|  | @ -17,7 +17,7 @@ | |||
|     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.89 2001/01/05 23:53:49 guus Exp $ | ||||
|     $Id: net.c,v 1.35.4.90 2001/01/07 15:25:41 guus Exp $ | ||||
| */ | ||||
| 
 | ||||
| #include "config.h" | ||||
|  | @ -72,10 +72,10 @@ | |||
| #include <utils.h> | ||||
| #include <xalloc.h> | ||||
| #include <avl_tree.h> | ||||
| #include <list.h> | ||||
| 
 | ||||
| #include "conf.h" | ||||
| #include "connection.h" | ||||
| #include "list.h" | ||||
| #include "meta.h" | ||||
| #include "net.h" | ||||
| #include "netutl.h" | ||||
|  | @ -190,129 +190,6 @@ cp | |||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|   add the given packet of size s to the | ||||
|   queue q, be it the send or receive queue | ||||
| */ | ||||
| void add_queue(packet_queue_t **q, void *packet, size_t s) | ||||
| { | ||||
|   queue_element_t *e; | ||||
| cp | ||||
|   e = xmalloc(sizeof(*e)); | ||||
|   e->packet = xmalloc(s); | ||||
|   memcpy(e->packet, packet, s); | ||||
| 
 | ||||
|   if(!*q) | ||||
|     { | ||||
|       *q = xmalloc(sizeof(**q)); | ||||
|       (*q)->head = (*q)->tail = NULL; | ||||
|     } | ||||
| 
 | ||||
|   e->next = NULL;			/* We insert at the tail */ | ||||
| 
 | ||||
|   if((*q)->tail)			/* Do we have a tail? */ | ||||
|     { | ||||
|       (*q)->tail->next = e; | ||||
|       e->prev = (*q)->tail; | ||||
|     } | ||||
|   else					/* No tail -> no head too */ | ||||
|     { | ||||
|       (*q)->head = e; | ||||
|       e->prev = NULL; | ||||
|     } | ||||
| 
 | ||||
|   (*q)->tail = e; | ||||
| cp | ||||
| } | ||||
| 
 | ||||
| /* Remove a queue element */ | ||||
| void del_queue(packet_queue_t **q, queue_element_t *e) | ||||
| { | ||||
| cp | ||||
|   free(e->packet); | ||||
| 
 | ||||
|   if(e->next)				/* There is a successor, so we are not tail */ | ||||
|     { | ||||
|       if(e->prev)			/* There is a predecessor, so we are not head */ | ||||
|         { | ||||
|           e->next->prev = e->prev; | ||||
|           e->prev->next = e->next; | ||||
|         } | ||||
|       else				/* We are head */ | ||||
|         { | ||||
|           e->next->prev = NULL; | ||||
|           (*q)->head = e->next; | ||||
|         } | ||||
|     } | ||||
|   else					/* We are tail (or all alone!) */ | ||||
|     {           | ||||
|       if(e->prev)			/* We are not alone :) */ | ||||
|         { | ||||
|           e->prev->next = NULL; | ||||
|           (*q)->tail = e->prev; | ||||
|         } | ||||
|       else				/* Adieu */ | ||||
|         { | ||||
|           free(*q); | ||||
|           *q = NULL; | ||||
|         } | ||||
|     } | ||||
|      | ||||
|   free(e); | ||||
| cp | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|   flush a queue by calling function for | ||||
|   each packet, and removing it when that | ||||
|   returned a zero exit code | ||||
| */ | ||||
| void flush_queue(connection_t *cl, packet_queue_t **pq, | ||||
| 		 int (*function)(connection_t*,vpn_packet_t*)) | ||||
| { | ||||
|   queue_element_t *p, *next = NULL; | ||||
| cp | ||||
|   for(p = (*pq)->head; p != NULL; ) | ||||
|     { | ||||
|       next = p->next; | ||||
| 
 | ||||
|       if(!function(cl, p->packet)) | ||||
|         del_queue(pq, p); | ||||
|          | ||||
|       p = next; | ||||
|     } | ||||
| 
 | ||||
|   if(debug_lvl >= DEBUG_TRAFFIC) | ||||
|     syslog(LOG_DEBUG, _("Queue flushed")); | ||||
| cp | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|   flush the send&recv queues | ||||
|   void because nothing goes wrong here, packets | ||||
|   remain in the queue if something goes wrong | ||||
| */ | ||||
| void flush_queues(connection_t *cl) | ||||
| { | ||||
| cp | ||||
|   if(cl->sq) | ||||
|     { | ||||
|       if(debug_lvl >= DEBUG_TRAFFIC) | ||||
| 	syslog(LOG_DEBUG, _("Flushing send queue for %s (%s)"), | ||||
| 	       cl->name, cl->hostname); | ||||
|       flush_queue(cl, &(cl->sq), xsend); | ||||
|     } | ||||
| 
 | ||||
|   if(cl->rq) | ||||
|     { | ||||
|       if(debug_lvl >=  DEBUG_TRAFFIC) | ||||
| 	syslog(LOG_DEBUG, _("Flushing receive queue for %s (%s)"), | ||||
| 	       cl->name, cl->hostname); | ||||
|       flush_queue(cl, &(cl->rq), xrecv); | ||||
|     } | ||||
| cp | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|   send a packet to the given vpn ip. | ||||
| */ | ||||
|  | @ -345,39 +222,52 @@ cp | |||
|       return -1; | ||||
|     } | ||||
| 
 | ||||
|   if(!cl->status.active) | ||||
|     { | ||||
|       if(debug_lvl >= DEBUG_TRAFFIC) | ||||
| 	syslog(LOG_INFO, _("%s (%s) is not active, dropping packet"), | ||||
| 	       cl->name, cl->hostname); | ||||
| 
 | ||||
|       return 0; | ||||
|     } | ||||
| 
 | ||||
|   /* If we ourselves have indirectdata flag set, we should send only to our uplink! */ | ||||
| 
 | ||||
|   /* FIXME - check for indirection and reprogram it The Right Way(tm) this time. */ | ||||
|    | ||||
|   if(!cl->status.validkey) | ||||
|     { | ||||
| /* FIXME: Don't queue until everything else is fixed.
 | ||||
|       if(debug_lvl >= DEBUG_TRAFFIC) | ||||
| 	syslog(LOG_INFO, _("No valid key known yet for %s (%s), queueing packet"), | ||||
| 	       cl->name, cl->hostname); | ||||
|       add_queue(&(cl->sq), packet, packet->len + 2); | ||||
| */ | ||||
| 
 | ||||
|       list_insert_tail(cl->queue, packet); | ||||
| 
 | ||||
|       if(!cl->status.waitingforkey) | ||||
| 	send_req_key(myself, cl);			/* Keys should be sent to the host running the tincd */ | ||||
|       return 0; | ||||
|     } | ||||
| 
 | ||||
|   if(!cl->status.active) | ||||
|     { | ||||
| /* FIXME: Don't queue until everything else is fixed.
 | ||||
|       if(debug_lvl >= DEBUG_TRAFFIC) | ||||
| 	syslog(LOG_INFO, _("%s (%s) is not ready, queueing packet"), | ||||
| 	       cl->name, cl->hostname); | ||||
|       add_queue(&(cl->sq), packet, packet->len + 2); | ||||
| */ | ||||
|       return 0; /* We don't want to mess up, do we? */ | ||||
|     } | ||||
| 
 | ||||
|   /* can we send it? can we? can we? huh? */ | ||||
| cp | ||||
|   return xsend(cl, packet); | ||||
| } | ||||
| 
 | ||||
| void flush_queue(connection_t *cl) | ||||
| { | ||||
|   list_node_t *node, *next; | ||||
| 
 | ||||
|   if(debug_lvl >= DEBUG_TRAFFIC) | ||||
|     syslog(LOG_INFO, _("Flushing queue for %s (%s)"), cl->name, cl->hostname); | ||||
|    | ||||
|   for(node = cl->queue->head; node; node = next) | ||||
|     { | ||||
|       next = node->next; | ||||
|       xsend(cl, (vpn_packet_t *)node->data); | ||||
|       list_delete_node(cl->queue, node); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|   open the local ethertap device | ||||
| */ | ||||
|  |  | |||
|  | @ -16,7 +16,7 @@ | |||
|     along with this program; if not, write to the Free Software | ||||
|     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| 
 | ||||
|     $Id: net.h,v 1.9.4.24 2000/12/22 21:34:23 guus Exp $ | ||||
|     $Id: net.h,v 1.9.4.25 2001/01/07 15:25:44 guus Exp $ | ||||
| */ | ||||
| 
 | ||||
| #ifndef __TINC_NET_H__ | ||||
|  | @ -117,9 +117,7 @@ extern void close_network_connections(void); | |||
| extern void main_loop(void); | ||||
| extern int setup_vpn_connection(connection_t *); | ||||
| extern void terminate_connection(connection_t *); | ||||
| extern void flush_queues(connection_t *); | ||||
| extern void add_queue(packet_queue_t **, void *, size_t); | ||||
| 
 | ||||
| extern void flush_queue(connection_t *); | ||||
| 
 | ||||
| #include <config.h> | ||||
| #ifdef HAVE_OPENSSL_RSA_H | ||||
|  |  | |||
							
								
								
									
										24
									
								
								src/netutl.c
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								src/netutl.c
									
										
									
									
									
								
							|  | @ -1,6 +1,7 @@ | |||
| /*
 | ||||
|     netutl.c -- some supporting network utility code | ||||
|     Copyright (C) 1998,1999,2000 Ivo Timmermans <itimmermans@bigfoot.com> | ||||
|                             2000 Guus Sliepen <guus@sliepen.warande.net> | ||||
| 
 | ||||
|     This program is free software; you can redistribute it and/or modify | ||||
|     it under the terms of the GNU General Public License as published by | ||||
|  | @ -16,7 +17,7 @@ | |||
|     along with this program; if not, write to the Free Software | ||||
|     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| 
 | ||||
|     $Id: netutl.c,v 1.12.4.16 2000/11/22 18:54:08 guus Exp $ | ||||
|     $Id: netutl.c,v 1.12.4.17 2001/01/07 15:25:44 guus Exp $ | ||||
| */ | ||||
| 
 | ||||
| #include "config.h" | ||||
|  | @ -40,27 +41,6 @@ | |||
| 
 | ||||
| #include "system.h" | ||||
| 
 | ||||
| 
 | ||||
| /*
 | ||||
|   free a queue and all of its elements | ||||
| */ | ||||
| void destroy_queue(packet_queue_t *pq) | ||||
| { | ||||
|   queue_element_t *p, *q; | ||||
| cp | ||||
|   for(p = pq->head; p != NULL; p = q) | ||||
|     { | ||||
|       q = p->next; | ||||
|       if(p->packet) | ||||
| 	free(p->packet); | ||||
|       free(p); | ||||
|     } | ||||
| 
 | ||||
|   free(pq); | ||||
| cp | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| char *hostlookup(unsigned long addr) | ||||
| { | ||||
|   char *name; | ||||
|  |  | |||
|  | @ -17,7 +17,7 @@ | |||
|     along with this program; if not, write to the Free Software | ||||
|     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| 
 | ||||
|     $Id: process.c,v 1.1.2.18 2001/01/05 23:53:51 guus Exp $ | ||||
|     $Id: process.c,v 1.1.2.19 2001/01/07 15:25:45 guus Exp $ | ||||
| */ | ||||
| 
 | ||||
| #include "config.h" | ||||
|  | @ -35,7 +35,6 @@ | |||
| #include <unistd.h> | ||||
| #include <termios.h> | ||||
| 
 | ||||
| #include <list.h> | ||||
| #include <pidfile.h> | ||||
| #include <utils.h> | ||||
| #include <xalloc.h> | ||||
|  |  | |||
|  | @ -17,14 +17,13 @@ | |||
|     along with this program; if not, write to the Free Software | ||||
|     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| 
 | ||||
|     $Id: process.h,v 1.1.2.5 2000/11/24 23:13:06 guus Exp $ | ||||
|     $Id: process.h,v 1.1.2.6 2001/01/07 15:25:45 guus Exp $ | ||||
| */ | ||||
| 
 | ||||
| #ifndef __TINC_PROCESS_H__ | ||||
| #define __TINC_PROCESS_H__ | ||||
| 
 | ||||
| #include "config.h" | ||||
| #include <list.h> | ||||
| 
 | ||||
| extern void setup_signals(void); | ||||
| extern int execute_script(const char *); | ||||
|  |  | |||
|  | @ -17,7 +17,7 @@ | |||
|     along with this program; if not, write to the Free Software | ||||
|     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| 
 | ||||
|     $Id: protocol.c,v 1.28.4.72 2001/01/06 18:03:40 guus Exp $ | ||||
|     $Id: protocol.c,v 1.28.4.73 2001/01/07 15:25:45 guus Exp $ | ||||
| */ | ||||
| 
 | ||||
| #include "config.h" | ||||
|  | @ -35,6 +35,7 @@ | |||
| #include <utils.h> | ||||
| #include <xalloc.h> | ||||
| #include <avl_tree.h> | ||||
| #include <list.h> | ||||
| 
 | ||||
| #include <netinet/in.h> | ||||
| 
 | ||||
|  | @ -1258,6 +1259,8 @@ cp | |||
| 
 | ||||
|   from->status.validkey = 1; | ||||
|   from->status.waitingforkey = 0; | ||||
|    | ||||
|   flush_queue(from); | ||||
| cp | ||||
|   return 0; | ||||
| } | ||||
|  |  | |||
							
								
								
									
										100
									
								
								src/route.c
									
										
									
									
									
								
							
							
						
						
									
										100
									
								
								src/route.c
									
										
									
									
									
								
							|  | @ -17,7 +17,7 @@ | |||
|     along with this program; if not, write to the Free Software | ||||
|     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||
| 
 | ||||
|     $Id: route.c,v 1.1.2.4 2001/01/05 23:53:53 guus Exp $ | ||||
|     $Id: route.c,v 1.1.2.5 2001/01/07 15:25:49 guus Exp $ | ||||
| */ | ||||
| 
 | ||||
| #include "config.h" | ||||
|  | @ -33,7 +33,36 @@ | |||
| 
 | ||||
| #include "system.h" | ||||
| 
 | ||||
| int routing_mode = RMODE_ROUTER;	/* Will be used to determine if we route by MAC or by payload's protocol */ | ||||
| int routing_mode = RMODE_ROUTER; | ||||
| 
 | ||||
| void learn_mac(connection_t *source, mac_t *address) | ||||
| { | ||||
|   connection_t *old; | ||||
|   subnet_t *subnet; | ||||
| cp | ||||
|   old = lookup_subnet_mac(address)->owner; | ||||
|    | ||||
|   if(!old) | ||||
|     { | ||||
|       subnet = new_subnet(); | ||||
|       subnet->type = SUBNET_MAC; | ||||
| //      subnet->lasttime = gettimeofday();
 | ||||
|       memcpy(&subnet->net.mac.address, address, sizeof(mac_t)); | ||||
|       subnet_add(source, subnet); | ||||
| 
 | ||||
|       if(DEBUG_LVL >= DEBUG_TRAFFIC) | ||||
|         { | ||||
|           syslog(LOG_DEBUG, _("Learned new MAC address %x:%x:%x:%x:%x:%x from %s (%s)"), | ||||
|                address->address.x[0], | ||||
|                address->address.x[1], | ||||
|                address->address.x[2], | ||||
|                address->address.x[3], | ||||
|                address->address.x[4], | ||||
|                address->address.x[5], | ||||
|                cl->name, cl->hostname); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| connection_t *route_mac(connection_t *source, vpn_packet_t *packet) | ||||
| { | ||||
|  | @ -42,17 +71,7 @@ connection_t *route_mac(connection_t *source, vpn_packet_t *packet) | |||
| cp | ||||
|   /* Learn source address */ | ||||
| 
 | ||||
|   oldsrc = lookup_subnet_mac((mac_t *)(&packet->data[0]))->owner; | ||||
|    | ||||
|   if(!oldsrc) | ||||
|     { | ||||
|       subnet = new_subnet(); | ||||
|       subnet->type = SUBNET_MAC; | ||||
|       memcpy(&subnet->net.mac.address, (mac_t *)(&packet->data[0]), sizeof(mac_t)); | ||||
|       subnet_add(source, subnet); | ||||
|     } | ||||
| 
 | ||||
|   /* FIXME: do ageing and roaming */ | ||||
|   learn_mac(source, (mac_t *)(&packet->data[0])); | ||||
|    | ||||
|   /* Lookup destination address */ | ||||
|      | ||||
|  | @ -96,46 +115,67 @@ connection_t *route_ipv6(vpn_packet_t *packet) | |||
| cp | ||||
|   if(debug_lvl > DEBUG_NOTHING) | ||||
|     { | ||||
|       syslog(LOG_WARNING, _("Cannot route packet: IPv6 routing not implemented yet")); | ||||
|       syslog(LOG_WARNING, _("Cannot route packet: IPv6 routing not yet implemented")); | ||||
|     }  | ||||
| cp | ||||
|   return NULL; | ||||
| } | ||||
| 
 | ||||
| connection_t *route_packet(connection_t *source, vpn_packet_t *packet) | ||||
| void route_outgoing(vpn_packet_t *packet) | ||||
| { | ||||
|   unsigned short int type; | ||||
|   avl_tree_t *node; | ||||
|   connection_t *cl; | ||||
| cp | ||||
|   /* FIXME: multicast? */ | ||||
| 
 | ||||
|   switch(routing_mode) | ||||
|     { | ||||
|       case RMODE_HUB: | ||||
|         return broadcast; | ||||
|          | ||||
|       case RMODE_SWITCH: | ||||
|         return route_mac(source, packet); | ||||
|          | ||||
|       case RMODE_ROUTER: | ||||
|         type = ntohs(*((unsigned short*)(&packet->data[12]))); | ||||
|         switch(type) | ||||
|           { | ||||
|             case 0x0800: | ||||
|               return route_ipv4(packet); | ||||
|               cl = route_ipv4(packet); | ||||
|               break; | ||||
|             case 0x86DD: | ||||
|               return route_ipv6(packet); | ||||
|       /*
 | ||||
|             case 0x8137: | ||||
|               return route_ipx(packet); | ||||
|             case 0x0806: | ||||
|               return route_arp(packet); | ||||
|       */ | ||||
|               cl = route_ipv6(packet); | ||||
|               break; | ||||
|             default: | ||||
|               if(debug_lvl >= DEBUG_TRAFFIC) | ||||
|                 { | ||||
|                   syslog(LOG_WARNING, _("Cannot route packet: unknown type %hx"), type); | ||||
|                 } | ||||
|               return NULL; | ||||
|               return; | ||||
|            } | ||||
|          send_packet(cl, packet); | ||||
|          break; | ||||
|          | ||||
|       case RMODE_SWITCH: | ||||
|         cl = route_mac(packet); | ||||
|         if(cl) | ||||
|           send_packet(cl, packet); | ||||
|         break; | ||||
|          | ||||
|       case RMODE_HUB: | ||||
|         for(node = connection_tree->head; node; node = node->next) | ||||
|           { | ||||
|             cl = (connection_t *)node->data; | ||||
|             if(cl->status.active) | ||||
|               send_packet(cl, packet); | ||||
|           } | ||||
|         break; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void route_incoming(connection_t *source, vpn_packet_t *packet) | ||||
| { | ||||
|   switch(routing_mode) | ||||
|     { | ||||
|       case RMODE_SWITCH: | ||||
|         learn_mac(source, &packet->data[0]); | ||||
|         break; | ||||
|     } | ||||
|    | ||||
|   accept_packet(packet); | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue