Author: adrian.chadd
Date: Sun Feb 22 17:42:29 2009
New Revision: 13837

Modified:
    playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_packet.c

Log:
Fiddle with the logging level somewhat!



Modified: playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_packet.c
==============================================================================
--- playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_packet.c        (original)
+++ playpen/LUSCA_HEAD_bgp/libsqbgp/bgp_packet.c        Sun Feb 22 17:42:29 2009
@@ -27,7 +27,7 @@
        u_short *aspaths;
        int origin;
        struct in_addr *nlri;
-       struct in_addr *nexthop;
+       struct in_addr nexthop;
        struct in_addr *withdraw;
  };
  typedef struct _bgp_update_state bgp_update_state_t;
@@ -70,7 +70,7 @@

        type = bgp_msg_type(buf, len);
        msg_len = bgp_msg_len(buf, len);
-       debug(85, 2) ("bgp_msg_complete: type %d, pktlen %d, msglen %d\n", 
type,  
len, msg_len);
+       debug(85, 3) ("bgp_msg_complete: type %d, pktlen %d, msglen %d\n", 
type,  
len, msg_len);

        if (type < 0)
                return 0;
@@ -220,7 +220,7 @@
        assert(us->withdraw == NULL);
        us->withdraw = xcalloc(len, sizeof(struct in_addr));

-       debug(85, 2) ("  bgp_handle_update_withdraw: len %d\n", len);
+       debug(85, 4) ("  bgp_handle_update_withdraw: len %d\n", len);
        while (i < len) {
                /* The "length" is the number of bits which are "valid" .. */
                netmask = (* (u_int8_t *) (buf + i));
@@ -229,7 +229,7 @@
                else
                        pl = ((netmask - 1) / 8) + 1;
                i++;
-               debug(85, 2) ("  bgp_handle_update_withdraw: netmask %d; len 
%d\n",  
netmask, pl);
+               debug(85, 4) ("  bgp_handle_update_withdraw: netmask %d; len 
%d\n",  
netmask, pl);
                /* XXX bounds check? */
                memcpy(&us->withdraw[j], buf + i, pl);
                debug(85, 2) ("  bgp_handle_update_withdraw: prefix %s/%d\n",  
inet_ntoa(us->withdraw[j]), netmask);
@@ -264,14 +264,23 @@

        /* XXX well, the length should be verified / used / bounds checked? */

-       debug(85, 2) ("  bgp_handle_update_pathattrib_aspath:");
+       debug(85, 3) ("  bgp_handle_update_pathattrib_aspath:\n");
        for (i = 2; i < len; i += 2) {
                us->aspaths[j] = ntohs(* (u_int16_t *) (buf + i));
-               debug(85, 2) (" %d", us->aspaths[j]);
+               debug(85, 3) (" - %d\n", us->aspaths[j]);
                j++;
        }
-       debug(85, 2) ("\n");
+       return 1;
+}
+
+int
+bgp_handle_update_pathattrib_nexthop(bgp_instance_t *bi,  
bgp_update_state_t *us, const char *buf, int len)
+{
+       if (len < 4)
+               return 0;

+       memcpy(&us->nexthop, buf, 4);
+       debug(85, 2) ("  nexthop: %s\n", inet_ntoa(us->nexthop));
        return 1;
  }

@@ -297,7 +306,7 @@
                        a_len =  * (u_int8_t *) (buf + i);
                        i += 1;
                }
-               debug(85, 2) ("  bgp_handle_update_pathattrib: flags %x, type 
%x,  
len %d\n", a_flags, a_type, a_len);
+               debug(85, 5) ("  bgp_handle_update_pathattrib: flags %x, type 
%x,  
len %d\n", a_flags, a_type, a_len);

                switch (a_type) {
                        case 1: /* origin */
@@ -308,6 +317,10 @@
                                if (bgp_handle_update_pathattrib_aspath(bi, us, 
buf + i, a_len) < 0)
                                        return 0;
                                break;
+                       case 3: /* next hop*/
+                               if (bgp_handle_update_pathattrib_nexthop(bi, 
us, buf + i, a_len) < 0)
+                                       return 0;
+                               break;
                        default:
                                debug(85, 2) ("  bgp_handle_path_attrib: don't 
know type %d\n",  
a_type);
                                break;
@@ -329,7 +342,7 @@
        if (len == 0)
                return 1;

-       debug(85, 2) ("  bgp_handle_update_nlri: len %d\n", len);
+       debug(85, 5) ("  bgp_handle_update_nlri: len %d\n", len);
        while (i < len) {
                bzero(&pf, sizeof(pf));
                /* The "length" is the number of bits which are "valid" .. */
@@ -339,10 +352,10 @@
                else
                        pl = ((netmask - 1) / 8) + 1;
                i++;
-               debug(85, 2) ("  bgp_handle_update_nlri: netmask %d; len %d\n", 
netmask,  
pl);
+               debug(85, 5) ("  bgp_handle_update_nlri: netmask %d; len %d\n", 
netmask,  
pl);
                /* XXX bounds check? */
                memcpy(&pf, buf + i, pl);
-               debug(85, 2) ("  bgp_handle_update_nlri: prefix %s/%d\n", 
inet_ntoa(pf),  
netmask);
+               debug(85, 3) ("  bgp_handle_update_nlri: prefix %s/%d\n", 
inet_ntoa(pf),  
netmask);
                bgp_rib_add_net(&bi->rn, pf, netmask);
                i += pl;
        }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to