Skip to content
Browse files

less printing, still works

  • Loading branch information...
1 parent 031d4dd commit 20d9c0886beddac46f7d4ca3a5560129a03c2bc4 @astrieanna astrieanna committed
Showing with 15 additions and 20 deletions.
  1. +14 −14 sr_if.c
  2. +0 −1 sr_main.c
  3. +1 −5 sr_router.c
View
28 sr_if.c
@@ -1,7 +1,7 @@
/*-----------------------------------------------------------------------------
* file: sr_inface.
- * date: Sun Oct 06 14:13:13 PDT 2002
- * Contact: casado@stanford.edu
+ * date: Sun Oct 06 14:13:13 PDT 2002
+ * Contact: casado@stanford.edu
*
* Description:
*
@@ -25,7 +25,7 @@
#include "sr_if.h"
#include "sr_router.h"
-/*---------------------------------------------------------------------
+/*---------------------------------------------------------------------
* Method: sr_get_interface
* Scope: Global
*
@@ -54,7 +54,7 @@ struct sr_if* sr_get_interface(struct sr_instance* sr, const char* name)
return 0;
} /* -- sr_get_interface -- */
-/*---------------------------------------------------------------------
+/*---------------------------------------------------------------------
* Method: sr_add_interface(..)
* Scope: Global
*
@@ -92,13 +92,13 @@ void sr_add_interface(struct sr_instance* sr, const char* name)
if_walker->queue = NULL;
strncpy(if_walker->name,name,sr_IFACE_NAMELEN);
if_walker->next = 0;
-} /* -- sr_add_interface -- */
+} /* -- sr_add_interface -- */
-/*---------------------------------------------------------------------
+/*---------------------------------------------------------------------
* Method: sr_sat_ether_addr(..)
* Scope: Global
*
- * set the ethernet address of the LAST interface in the interface list
+ * set the ethernet address of the LAST interface in the interface list
*
*---------------------------------------------------------------------*/
@@ -108,7 +108,7 @@ void sr_set_ether_addr(struct sr_instance* sr, const unsigned char* addr)
/* -- REQUIRES -- */
assert(sr->if_list);
-
+
if_walker = sr->if_list;
while(if_walker->next)
{if_walker = if_walker->next; }
@@ -118,7 +118,7 @@ void sr_set_ether_addr(struct sr_instance* sr, const unsigned char* addr)
} /* -- sr_set_ether_addr -- */
-/*---------------------------------------------------------------------
+/*---------------------------------------------------------------------
* Method: sr_set_ether_ip(..)
* Scope: Global
*
@@ -132,7 +132,7 @@ void sr_set_ether_ip(struct sr_instance* sr, uint32_t ip_nbo)
/* -- REQUIRES -- */
assert(sr->if_list);
-
+
if_walker = sr->if_list;
while(if_walker->next)
{if_walker = if_walker->next; }
@@ -142,7 +142,7 @@ void sr_set_ether_ip(struct sr_instance* sr, uint32_t ip_nbo)
} /* -- sr_set_ether_ip -- */
-/*---------------------------------------------------------------------
+/*---------------------------------------------------------------------
* Method: sr_print_if_list(..)
* Scope: Global
*
@@ -161,17 +161,17 @@ void sr_print_if_list(struct sr_instance* sr)
}
if_walker = sr->if_list;
-
+
sr_print_if(if_walker);
while(if_walker->next)
{
- if_walker = if_walker->next;
+ if_walker = if_walker->next;
sr_print_if(if_walker);
}
} /* -- sr_print_if_list -- */
-/*---------------------------------------------------------------------
+/*---------------------------------------------------------------------
* Method: sr_print_if(..)
* Scope: Global
*
View
1 sr_main.c
@@ -115,7 +115,6 @@ int main(int argc, char **argv)
external = optarg;
break;
case 'b':
- Debug("got option b %s\n", optarg);
ruletable = optarg;
break;
} /* switch */
View
6 sr_router.c
@@ -111,7 +111,7 @@ void sr_handlepacket(struct sr_instance* sr,
struct sr_ethernet_hdr* e_hdr = 0;
e_hdr = (struct sr_ethernet_hdr*)packet;
- Debug("*** -> Received packet of length %d \n",len);
+ // Debug("*** -> Received packet of length %d \n",len);
Debug("Ethernet Header:\n");
//printEthernetHeader(e_hdr);
@@ -604,12 +604,10 @@ void sendOff(struct sr_instance *sr, struct waitingpacket *pack,
}
bool compareIPandPort(char * Ip1, char * Ip2, uint16_t port1, uint16_t port2){
- Debug("comparing: %s:%u to %s:%u\n", Ip1, port1, Ip2, port2);
return((strncmp(Ip1, Ip2, 15) == 0)&&(port1 == port2));
}
void deleteFTE(struct flowTableEntry* doomed){
- Debug("Deleted flow for %s to %s\n", doomed->srcIP, doomed->dstIP);
free(doomed);
}
@@ -617,7 +615,6 @@ struct flowTableEntry * searchForFlow(struct sr_instance* sr, char * srcIp,
uint16_t srcPort, char * dstIp, uint16_t dstPort, uint8_t protocol){
struct flowTableEntry* current = sr->flowTable;
struct flowTableEntry* prev = NULL;
- Debug("comparing: %s:%u %s:%u %u\n", srcIp, srcPort, dstIp, dstPort, protocol);
while(current != NULL){
if(!current->isImmortal && difftime(time(NULL),current->ttl) > DEATH){
if(prev == NULL){
@@ -663,7 +660,6 @@ void addFlowToTable(struct sr_instance* sr, char * srcIp,
uint16_t srcPort, char * dstIp, uint16_t dstPort, uint8_t protocol){
struct flowTableEntry* result = searchForFlow(sr, srcIp, srcPort, dstIp, dstPort, protocol);
if(result == NULL){
- Debug("Adding flow for %s to %s\n", srcIp, dstIp);
result = malloc(sizeof(struct flowTableEntry));
strncpy(result->srcIP,srcIp,15);
result->srcIPw = false;

0 comments on commit 20d9c08

Please sign in to comment.
Something went wrong with that request. Please try again.