]> git.proxmox.com Git - mirror_frr.git/commitdiff
2004-10-13 Paul Jakma <paul@dishone.st>
authorpaul <paul>
Wed, 13 Oct 2004 05:06:08 +0000 (05:06 +0000)
committerpaul <paul>
Wed, 13 Oct 2004 05:06:08 +0000 (05:06 +0000)
* (global) more const'ification and fixups of types to clean up code.
* bgp_mplsvpn.{c,h}: (str2tag) fix abuse. Still not perfect,
          should use something like the VTY_GET_INTEGER macro, but without
          the vty_out bits..
        * bgp_routemap.c: (set_aggregator_as) use VTY_GET_INTEGER_RANGE
          (no_set_aggregator_as) ditto.
        * bgpd.c: (peer_uptime) fix unlikely bug, where no buffer is
          returned, add comments about troublesome return value.

34 files changed:
bgpd/ChangeLog
bgpd/bgp_aspath.c
bgpd/bgp_aspath.h
bgpd/bgp_clist.c
bgpd/bgp_clist.h
bgpd/bgp_community.c
bgpd/bgp_community.h
bgpd/bgp_damp.c
bgpd/bgp_damp.h
bgpd/bgp_debug.c
bgpd/bgp_debug.h
bgpd/bgp_dump.c
bgpd/bgp_ecommunity.c
bgpd/bgp_ecommunity.h
bgpd/bgp_filter.c
bgpd/bgp_filter.h
bgpd/bgp_fsm.c
bgpd/bgp_fsm.h
bgpd/bgp_main.c
bgpd/bgp_mplsvpn.c
bgpd/bgp_mplsvpn.h
bgpd/bgp_packet.c
bgpd/bgp_packet.h
bgpd/bgp_regex.c
bgpd/bgp_regex.h
bgpd/bgp_route.c
bgpd/bgp_route.h
bgpd/bgp_routemap.c
bgpd/bgp_snmp.c
bgpd/bgp_vty.c
bgpd/bgp_zebra.c
bgpd/bgp_zebra.h
bgpd/bgpd.c
bgpd/bgpd.h

index d5ab328262aa4ed518cbf52fc221449833321eed..93feb051e513581b6fdea8dd7d0721112fcd4869 100644 (file)
@@ -1,3 +1,14 @@
+2004-10-13 Paul Jakma <paul@dishone.st>
+
+       * (global) more const'ification and fixups of types to clean up code.
+       * bgp_mplsvpn.{c,h}: (str2tag) fix abuse. Still not perfect,
+          should use something like the VTY_GET_INTEGER macro, but without
+          the vty_out bits..
+        * bgp_routemap.c: (set_aggregator_as) use VTY_GET_INTEGER_RANGE
+          (no_set_aggregator_as) ditto.
+        * bgpd.c: (peer_uptime) fix unlikely bug, where no buffer is 
+          returned, add comments about troublesome return value.
+       
 2004-10-03 James R. Leu <jleu at mindspring.com>
 
        * bgp_vty.c: Router id from zebra can be manually overriden.
index bcb8f16f29397ae346b4753617ab85009fd7d514..5d4977510917cf597dbde57cbfe62c0ec5b2f42d 100644 (file)
@@ -993,10 +993,10 @@ enum as_token
 };
 
 /* Return next token and point for string parse. */
-char *
-aspath_gettoken (char *buf, enum as_token *token, u_short *asno)
+const char *
+aspath_gettoken (const char *buf, enum as_token *token, u_short *asno)
 {
-  char *p = buf;
+  const char *p = buf;
 
   /* Skip space. */
   while (isspace ((int) *p))
@@ -1055,7 +1055,7 @@ aspath_gettoken (char *buf, enum as_token *token, u_short *asno)
 }
 
 struct aspath *
-aspath_str2aspath (char *str)
+aspath_str2aspath (const char *str)
 {
   enum as_token token;
   u_short as_type;
index 0295fafb51434aa203523b6a7f2d58e3555fbfb9..3f7858befe53005f319310a209dc49963ba3568a 100644 (file)
@@ -25,8 +25,10 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #define AS_CONFED_SET                4
 
 /* Private AS range defined in RFC2270.  */
-#define BGP_PRIVATE_AS_MIN       64512
-#define BGP_PRIVATE_AS_MAX       65535
+#define BGP_PRIVATE_AS_MIN       64512U
+#define BGP_PRIVATE_AS_MAX       65535U
+
+#define BGP_AS_MAX              65535U
 
 /* AS path may be include some AsSegments.  */
 struct aspath 
@@ -63,7 +65,7 @@ int aspath_cmp_left_confed (struct aspath *, struct aspath *);
 struct aspath *aspath_delete_confed_seq (struct aspath *);
 struct aspath *aspath_empty ();
 struct aspath *aspath_empty_get ();
-struct aspath *aspath_str2aspath (char *);
+struct aspath *aspath_str2aspath (const char *);
 void aspath_free (struct aspath *);
 struct aspath *aspath_intern (struct aspath *);
 void aspath_unintern (struct aspath *);
index a2c12100c8adafbface3d444810630aca80ccb0a..572d11c9e1c2b303b47d3c8039ac56c47999da42 100644 (file)
@@ -115,9 +115,9 @@ community_list_free (struct community_list *list)
 
 struct community_list *
 community_list_insert (struct community_list_handler *ch,
-                       char *name, int style)
+                       const char *name, int style)
 {
-  int i;
+  size_t i;
   long number;
   struct community_list *new;
   struct community_list *point;
@@ -209,7 +209,7 @@ community_list_insert (struct community_list_handler *ch,
 
 struct community_list *
 community_list_lookup (struct community_list_handler *ch,
-                       char *name, int style)
+                       const char *name, int style)
 {
   struct community_list *list;
   struct community_list_master *cm;
@@ -232,7 +232,8 @@ community_list_lookup (struct community_list_handler *ch,
 }
 
 struct community_list *
-community_list_get (struct community_list_handler *ch, char *name, int style)
+community_list_get (struct community_list_handler *ch, 
+                    const char *name, int style)
 {
   struct community_list *list;
 
@@ -313,7 +314,7 @@ community_list_entry_delete (struct community_list *list,
 
 /* Lookup community-list entry from the list.  */
 static struct community_entry *
-community_list_entry_lookup (struct community_list *list, void *arg,
+community_list_entry_lookup (struct community_list *list, const void *arg,
                              int direct)
 {
   struct community_entry *entry;
@@ -347,7 +348,7 @@ community_list_entry_lookup (struct community_list *list, void *arg,
 static int
 community_regexp_match (struct community *com, regex_t * reg)
 {
-  char *str;
+  const char *str;
 
   /* When there is no communities attribute it is treated as empty
      string.  */
@@ -367,7 +368,7 @@ community_regexp_match (struct community *com, regex_t * reg)
 static int
 ecommunity_regexp_match (struct ecommunity *ecom, regex_t * reg)
 {
-  char *str;
+  const char *str;
 
   /* When there is no communities attribute it is treated as empty
      string.  */
@@ -393,7 +394,7 @@ community_regexp_delete (struct community *com, regex_t * reg)
   u_int32_t comval;
   /* Maximum is "65535:65535" + '\0'. */
   char c[12];
-  char *str;
+  const char *str;
 
   if (!com)
     return NULL;
@@ -606,7 +607,7 @@ community_list_dup_check (struct community_list *list,
 /* Set community-list.  */
 int
 community_list_set (struct community_list_handler *ch,
-                    char *name, char *str, int direct, int style)
+                    const char *name, const char *str, int direct, int style)
 {
   struct community_entry *entry;
   struct community_list *list;
@@ -702,7 +703,8 @@ community_list_set (struct community_list_handler *ch,
    community-list entry belongs to the specified name.  */
 int
 community_list_unset (struct community_list_handler *ch,
-                      char *name, char *str, int direct, int style)
+                      const char *name, const char *str, 
+                      int direct, int style)
 {
   struct community_entry *entry;
   struct community_list *list;
@@ -766,7 +768,8 @@ community_list_unset (struct community_list_handler *ch,
 /* Set extcommunity-list.  */
 int
 extcommunity_list_set (struct community_list_handler *ch,
-                       char *name, char *str, int direct, int style)
+                       const char *name, const char *str, 
+                       int direct, int style)
 {
   struct community_entry *entry;
   struct community_list *list;
@@ -869,7 +872,8 @@ extcommunity_list_set (struct community_list_handler *ch,
    extcommunity-list entry belongs to the specified name.  */
 int
 extcommunity_list_unset (struct community_list_handler *ch,
-                         char *name, char *str, int direct, int style)
+                         const char *name, const char *str, 
+                         int direct, int style)
 {
   struct community_entry *entry;
   struct community_list *list;
index ffc707c2848ab7d746d58dc9f215453d02e0d83f..11db2d712d579e419f3b0c89a405e4aea56fabda 100644 (file)
@@ -121,22 +121,24 @@ extern struct community_list_handler *bgp_clist;
 /* Prototypes.  */
 struct community_list_handler *community_list_init ();
 
-int community_list_set (struct community_list_handler *ch,
-                       char *name, char *str, int direct, int style);
-int community_list_unset (struct community_list_handler *ch,
-                         char *name, char *str, int direct, int style);
-int extcommunity_list_set (struct community_list_handler *ch,
-                          char *name, char *str, int direct, int style);
-int extcommunity_list_unset (struct community_list_handler *ch,
-                            char *name, char *str, int direct, int style);
+int community_list_set (struct community_list_handler *ch, const char *name, 
+                        const char *str, int direct, int style);
+int community_list_unset (struct community_list_handler *ch, const char *name,
+                          const char *str, int direct, int style);
+int extcommunity_list_set (struct community_list_handler *ch, const char *name,
+                           const char *str, int direct, int style);
+int extcommunity_list_unset (struct community_list_handler *ch, 
+                             const char *name, const char *str, 
+                             int direct, int style);
 
 struct community_list_master *
 community_list_master_lookup (struct community_list_handler *, int);
 
 struct community_list *
-community_list_lookup (struct community_list_handler *, char *, int);
+community_list_lookup (struct community_list_handler *, const char *, int);
 
 int community_list_match (struct community *, struct community_list *);
+int ecommunity_list_match (struct ecommunity *, struct community_list *);
 int community_list_exact_match (struct community *, struct community_list *);
 struct community *
 community_list_match_delete (struct community *,
index 5467971001d12f52a95a3b115430ffbead4c03b6..1a6514bce569171dd5bc7d0c73ff9fa7684b0928 100644 (file)
@@ -401,7 +401,7 @@ community_hash_make (struct community *com)
 }
 
 int
-community_match (struct community *com1, struct community *com2)
+community_match (const struct community *com1, const struct community *com2)
 {
   int i = 0;
   int j = 0;
@@ -432,7 +432,7 @@ community_match (struct community *com1, struct community *com2)
 /* If two aspath have same value then return 1 else return 0. This
    function is used by hash package. */
 int
-community_cmp (struct community *com1, struct community *com2)
+community_cmp (const struct community *com1, const struct community *com2)
 {
   if (com1 == NULL && com2 == NULL)
     return 1;
@@ -472,10 +472,11 @@ enum community_token
 };
 
 /* Get next community token from string. */
-char *
-community_gettoken (char *buf, enum community_token *token, u_int32_t *val)
+const char *
+community_gettoken (const char *buf, enum community_token *token, 
+                    u_int32_t *val)
 {
-  char *p = buf;
+  const char *p = buf;
 
   /* Skip white space. */
   while (isspace ((int) *p))
@@ -570,7 +571,7 @@ community_gettoken (char *buf, enum community_token *token, u_int32_t *val)
 
 /* convert string to community structure */
 struct community *
-community_str2com (char *str)
+community_str2com (const char *str)
 {
   struct community *com = NULL;
   struct community *com_sort = NULL;
index 898ca9e86ef24e4394b418922c6f9cd262732470..016b0f6ffa879162eb3b3423e68ad9bfdf7eaf16 100644 (file)
@@ -56,9 +56,9 @@ struct community *community_intern (struct community *);
 void community_unintern (struct community *);
 char *community_str (struct community *);
 unsigned int community_hash_make (struct community *);
-struct community *community_str2com (char *);
-int community_match (struct community *, struct community *);
-int community_cmp (struct community *, struct community *);
+struct community *community_str2com (const char *);
+int community_match (const struct community *, const struct community *);
+int community_cmp (const struct community *, const struct community *);
 struct community *community_merge (struct community *, struct community *);
 struct community *community_delete (struct community *, struct community *);
 struct community *community_dup (struct community *);
index d70105f55a4d1cd1ff458bee43614cfc50a35ae1..9b7b5dae022d7cff32aca762595db867c81fdedc 100644 (file)
@@ -47,7 +47,7 @@ struct bgp_damp_config *damp = &bgp_damp_cfg;
 static int
 bgp_reuse_index (int penalty)
 {
-  int i;
+  unsigned int i;
   int index;
 
   i = (int)(((double) penalty / damp->reuse_limit - 1.0) * damp->scale_factor);
@@ -91,7 +91,7 @@ bgp_reuse_list_delete (struct bgp_damp_info *bdi)
 int 
 bgp_damp_decay (time_t tdiff, int penalty)
 {
-  int i;
+  unsigned int i;
 
   i = (int) ((double) tdiff / DELTA_T);
 
@@ -380,7 +380,7 @@ void
 bgp_damp_parameter_set (int hlife, int reuse, int sup, int maxsup)
 {
   double reuse_max_ratio;
-  int i;
+  unsigned int i;
   double j;
        
   damp->suppress_value = sup;
@@ -438,8 +438,8 @@ bgp_damp_parameter_set (int hlife, int reuse, int sup, int maxsup)
 }
 
 int
-bgp_damp_enable (struct bgp *bgp, afi_t afi, safi_t safi, int half,
-                int reuse, int suppress, int max)
+bgp_damp_enable (struct bgp *bgp, afi_t afi, safi_t safi, time_t half,
+                unsigned int reuse, unsigned int suppress, time_t max)
 {
   if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
     {
@@ -479,7 +479,7 @@ bgp_damp_config_clean (struct bgp_damp_config *damp)
 void
 bgp_damp_info_clean ()
 {
-  int i;
+  unsigned int i;
   struct bgp_damp_info *bdi, *next;
 
   damp->reuse_offset = 0;
@@ -537,11 +537,11 @@ bgp_config_write_damp (struct vty *vty)
               && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE
               && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS
               && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4)
-       vty_out (vty, " bgp dampening %d%s",
+       vty_out (vty, " bgp dampening %ld%s",
                 bgp_damp_cfg.half_life/60,
                 VTY_NEWLINE);
       else
-       vty_out (vty, " bgp dampening %d %d %d %d%s",
+       vty_out (vty, " bgp dampening %ld %d %d %ld%s",
                 bgp_damp_cfg.half_life/60,
                 bgp_damp_cfg.reuse_limit,
                 bgp_damp_cfg.suppress_value,
@@ -555,7 +555,7 @@ bgp_config_write_damp (struct vty *vty)
 #define BGP_UPTIME_LEN 25
 
 char *
-bgp_get_reuse_time (int penalty, char *buf, size_t len)
+bgp_get_reuse_time (unsigned int penalty, char *buf, size_t len)
 {
   time_t reuse_time = 0;
   struct tm *tm = NULL;
index f3b9bd6dbcdfc84f5ac2536ef2b555130e56abc2..09b953ea938dc528c6af11cbcecabce6407ba41b 100644 (file)
@@ -27,10 +27,10 @@ struct bgp_damp_info
   struct bgp_damp_info *prev;
 
   /* Figure-of-merit.  */
-  int penalty;
+  unsigned int penalty;
 
   /* Number of flapping.  */
-  int flap;
+  unsigned int flap;
        
   /* First flap time  */
   time_t start_time;
@@ -52,8 +52,8 @@ struct bgp_damp_info
 
   /* Last time message type. */
   u_char lastrecord;
-#define BGP_RECORD_UPDATE      1
-#define BGP_RECORD_WITHDRAW    2
+#define BGP_RECORD_UPDATE      1U
+#define BGP_RECORD_WITHDRAW    2U
 
   afi_t afi;
   safi_t safi;
@@ -63,32 +63,32 @@ struct bgp_damp_info
 struct bgp_damp_config
 {
   /* Value over which routes suppressed.  */
-  int suppress_value;
+  unsigned int suppress_value;
 
   /* Value below which suppressed routes reused.  */
-  int reuse_limit;    
+  unsigned int reuse_limit;
 
   /* Max time a route can be suppressed.  */
-  int max_suppress_time;      
+  time_t max_suppress_time;      
 
   /* Time during which accumulated penalty reduces by half.  */
-  int half_life; 
+  time_t half_life;
 
   /* Non-configurable parameters but fixed at implementation time.
    * To change this values, init_bgp_damp() should be modified.
    */
-  int tmax;              /* Max time previous instability retained */
-  int reuse_list_size;         /* Number of reuse lists */
-  int reuse_index_size;                /* Size of reuse index array */
+  time_t tmax;                  /* Max time previous instability retained */
+  unsigned int reuse_list_size;         /* Number of reuse lists */
+  unsigned int reuse_index_size; /* Size of reuse index array */
 
   /* Non-configurable parameters.  Most of these are calculated from
    * the configurable parameters above.
    */
-  unsigned int ceiling;                /* Max value a penalty can attain */
-  int decay_rate_per_tick;     /* Calculated from half-life */
-  int decay_array_size;                /* Calculated using config parameters */
+  unsigned int ceiling;                        /* Max value a penalty can attain */
+  unsigned int decay_rate_per_tick;    /* Calculated from half-life */
+  unsigned int decay_array_size; /* Calculated using config parameters */
   double scale_factor;
-  int reuse_scale_factor; 
+  unsigned int reuse_scale_factor; 
          
   /* Decay array per-set based. */ 
   double *decay_array; 
@@ -126,7 +126,8 @@ struct bgp_damp_config
 #define REUSE_LIST_SIZE          256
 #define REUSE_ARRAY_SIZE        1024
 
-int bgp_damp_enable (struct bgp *, afi_t, safi_t, int, int, int, int);
+int bgp_damp_enable (struct bgp *, afi_t, safi_t, time_t, unsigned int, 
+                     unsigned int, time_t);
 int bgp_damp_disable (struct bgp *, afi_t, safi_t);
 int bgp_damp_withdraw (struct bgp_info *, struct bgp_node *,
                       afi_t, safi_t, int);
@@ -134,7 +135,7 @@ int bgp_damp_update (struct bgp_info *, struct bgp_node *, afi_t, safi_t);
 int bgp_damp_scan (struct bgp_info *, afi_t, safi_t);
 void bgp_damp_info_free (struct bgp_damp_info *, int);
 void bgp_damp_info_clean ();
-char * bgp_get_reuse_time (int, char*, size_t);
+char * bgp_get_reuse_time (unsigned int, char*, size_t);
 int bgp_damp_decay (time_t, int);
 int bgp_config_write_damp (struct vty *);
 void bgp_damp_info_vty (struct vty *, struct bgp_info *);
index 9c5208dacc4c9b42aec1af20307d11d32b8ab2c4..3196effc458781ec3bfdbc5912763f542e8459ba 100644 (file)
@@ -66,7 +66,7 @@ struct message bgp_status_msg[] =
 int bgp_status_msg_max = BGP_STATUS_MAX;
 
 /* BGP message type string. */
-char *bgp_type_str[] =
+const char *bgp_type_str[] =
 {
   NULL,
   "OPEN",
@@ -154,8 +154,8 @@ struct message bgp_notify_capability_msg[] =
 int bgp_notify_capability_msg_max = BGP_NOTIFY_CAPABILITY_MAX;
 
 /* Origin strings. */
-char *bgp_origin_str[] = {"i","e","?"};
-char *bgp_origin_long_str[] = {"IGP","EGP","incomplete"};
+const char *bgp_origin_str[] = {"i","e","?"};
+const char *bgp_origin_long_str[] = {"IGP","EGP","incomplete"};
 
 /* Dump attribute. */
 int
@@ -233,9 +233,10 @@ bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size)
 
 /* dump notify packet */
 void
-bgp_notify_print(struct peer *peer, struct bgp_notify *bgp_notify, char *direct)
+bgp_notify_print(struct peer *peer, struct bgp_notify *bgp_notify, 
+                 const char *direct)
 {
-  char *subcode_str;
+  const char *subcode_str;
 
   subcode_str = "";
 
index 14a8c5fe6c9702cdf1ff59b00896565a2ebab50c..d060961e3f1081d429672330395af8d219233a59 100644 (file)
@@ -104,10 +104,10 @@ extern unsigned long term_bgp_debug_normal;
 #define BGP_DEBUG(a, b)                (term_bgp_debug_ ## a & BGP_DEBUG_ ## b)
 #define CONF_BGP_DEBUG(a, b)    (conf_bgp_debug_ ## a & BGP_DEBUG_ ## b)
 
-extern char *bgp_type_str[];
+const extern char *bgp_type_str[];
 
 int bgp_dump_attr (struct peer *, struct attr *, char *, size_t);
-void bgp_notify_print (struct peer *, struct bgp_notify *, char *);
+void bgp_notify_print (struct peer *, struct bgp_notify *, const char *);
 
 extern struct message bgp_status_msg[];
 extern int bgp_status_msg_max;
index 9690fb568e635c7db9c1a81bcef86781a3a1c0df..f8637c65d424137f4ffe3c3ef31916358d81ca76 100644 (file)
@@ -462,7 +462,7 @@ bgp_dump_packet (struct peer *peer, int type, struct stream *packet)
 }
 \f
 unsigned int
-bgp_dump_parse_time (char *str)
+bgp_dump_parse_time (const char *str)
 {
   int i;
   int len;
@@ -510,7 +510,7 @@ bgp_dump_parse_time (char *str)
 
 int
 bgp_dump_set (struct vty *vty, struct bgp_dump *bgp_dump, int type,
-             char *path, char *interval_str)
+             const char *path, const char *interval_str)
 {
   unsigned int interval;
   
index b3fc1c3a76c76177963a9aa43bddb5fe7dbc7cdf..32bf68f1558b1ce86b745308e4c9ad61311b9c4e 100644 (file)
@@ -245,7 +245,8 @@ ecommunity_hash_make (struct ecommunity *ecom)
 
 /* Compare two Extended Communities Attribute structure.  */
 int
-ecommunity_cmp (struct ecommunity *ecom1, struct ecommunity *ecom2)
+ecommunity_cmp (const struct ecommunity *ecom1, 
+                const struct ecommunity *ecom2)
 {
   if (ecom1->size == ecom2->size
       && memcmp (ecom1->val, ecom2->val, ecom1->size * ECOMMUNITY_SIZE) == 0)
@@ -270,8 +271,8 @@ enum ecommunity_token
 };
 
 /* Get next Extended Communities token from the string. */
-char *
-ecommunity_gettoken (char *str, struct ecommunity_val *eval,
+const char *
+ecommunity_gettoken (const char *str, struct ecommunity_val *eval,
                     enum ecommunity_token *token)
 {
   int ret;
@@ -280,7 +281,7 @@ ecommunity_gettoken (char *str, struct ecommunity_val *eval,
   int separator = 0;
   u_int32_t val_low = 0;
   u_int32_t val_high = 0;
-  char *p = str;
+  const char *p = str;
   struct in_addr ip;
   char ipstr[INET_ADDRSTRLEN + 1];
 
@@ -448,7 +449,7 @@ ecommunity_gettoken (char *str, struct ecommunity_val *eval,
                                     keyword_include = 1
 */
 struct ecommunity *
-ecommunity_str2com (char *str, int type, int keyword_included)
+ecommunity_str2com (const char *str, int type, int keyword_included)
 {
   struct ecommunity *ecom = NULL;
   enum ecommunity_token token;
@@ -537,7 +538,7 @@ ecommunity_ecom2str (struct ecommunity *ecom, int format)
   int str_size;
   int str_pnt;
   char *str_buf;
-  char *prefix;
+  const char *prefix;
   int len = 0;
   int first = 1;
 
@@ -650,7 +651,8 @@ ecommunity_ecom2str (struct ecommunity *ecom, int format)
 }
 
 int
-ecommunity_match (struct ecommunity *ecom1, struct ecommunity *ecom2)
+ecommunity_match (const struct ecommunity *ecom1, 
+                  const struct ecommunity *ecom2)
 {
   int i = 0;
   int j = 0;
index e7be7865e064c0044dd99a377669940227369775..56e9f18ee312a3b6941335b43fb129f8d377eeda 100644 (file)
@@ -68,10 +68,10 @@ struct ecommunity *ecommunity_parse (u_int8_t *, u_short);
 struct ecommunity *ecommunity_dup (struct ecommunity *);
 struct ecommunity *ecommunity_merge (struct ecommunity *, struct ecommunity *);
 struct ecommunity *ecommunity_intern (struct ecommunity *);
-int ecommunity_cmp (struct ecommunity *, struct ecommunity *);
+int ecommunity_cmp (const struct ecommunity *, const struct ecommunity *);
 void ecommunity_unintern (struct ecommunity *);
 unsigned int ecommunity_hash_make (struct ecommunity *);
-struct ecommunity *ecommunity_str2com (char *, int, int);
+struct ecommunity *ecommunity_str2com (const char *, int, int);
 char *ecommunity_ecom2str (struct ecommunity *, int);
-int ecommunity_match (struct ecommunity *, struct ecommunity *);
+int ecommunity_match (const struct ecommunity *, const struct ecommunity *);
 char *ecommunity_str (struct ecommunity *);
index 7a8fb039cffbf670adaea922a9b4d095711aec8a..09dcc0fa286b749082996d708b13b8135eb6bfbb 100644 (file)
@@ -119,7 +119,7 @@ as_filter_free (struct as_filter *asfilter)
 
 /* Make new AS filter. */
 struct as_filter *
-as_filter_make (regex_t *reg, char *reg_str, enum as_filter_type type)
+as_filter_make (regex_t *reg, const char *reg_str, enum as_filter_type type)
 {
   struct as_filter *asfilter;
 
@@ -132,7 +132,7 @@ as_filter_make (regex_t *reg, char *reg_str, enum as_filter_type type)
 }
 
 struct as_filter *
-as_filter_lookup (struct as_list *aslist, char *reg_str,
+as_filter_lookup (struct as_list *aslist, const char *reg_str,
                  enum as_filter_type type)
 {
   struct as_filter *asfilter;
@@ -158,7 +158,7 @@ as_list_filter_add (struct as_list *aslist, struct as_filter *asfilter)
 
 /* Lookup as_list from list of as_list by name. */
 struct as_list *
-as_list_lookup (char *name)
+as_list_lookup (const char *name)
 {
   struct as_list *aslist;
 
@@ -195,9 +195,9 @@ as_list_free (struct as_list *aslist)
 /* Insert new AS list to list of as_list.  Each as_list is sorted by
    the name. */
 struct as_list *
-as_list_insert (char *name)
+as_list_insert (const char *name)
 {
-  int i;
+  size_t i;
   long number;
   struct as_list *aslist;
   struct as_list *point;
@@ -279,7 +279,7 @@ as_list_insert (char *name)
 }
 
 struct as_list *
-as_list_get (char *name)
+as_list_get (const char *name)
 {
   struct as_list *aslist;
 
@@ -296,7 +296,7 @@ as_list_get (char *name)
   return aslist;
 }
 
-static char *
+static const char *
 filter_type_str (enum as_filter_type type)
 {
   switch (type)
index 8d55a224cc31851f4ace27a2ab04371becd54835..ec48ca170546a1edff902b02fc1c138ee282cfe7 100644 (file)
@@ -26,6 +26,6 @@ enum as_filter_type
 
 enum as_filter_type as_list_apply (struct as_list *, void *);
 
-struct as_list *as_list_lookup (char *);
+struct as_list *as_list_lookup (const char *);
 void as_list_add_hook (void (*func) ());
 void as_list_delete_hook (void (*func) ());
index 2874a9a08306ea03a73c4886433996a1222e2415..dd65facf2fc91a69a9151d2296d83ab7cf303ae0 100644 (file)
@@ -308,7 +308,7 @@ bgp_uptime_reset (struct peer *peer)
 }
 
 /* BGP Peer Down Cause */
-char *peer_down_str[] =
+const char *peer_down_str[] =
 {
   "",
   "Router ID changed",
@@ -828,7 +828,7 @@ struct {
   },
 };
 
-static char *bgp_event_str[] =
+static const char *bgp_event_str[] =
 {
   NULL,
   "BGP_Start",
index ce816e231fb361ff177fb7db749e9c3bb9dad825..20fc2d70180c13ce864078df41e4c6c1951e5683 100644 (file)
@@ -40,4 +40,4 @@ int bgp_event (struct thread *);
 int bgp_stop (struct peer *peer);
 void bgp_timer_set (struct peer *);
 void bgp_fsm_change_status (struct peer *peer, int status);
-extern char *peer_down_str[];
+extern const char *peer_down_str[];
index a4cd9ab4890b9ced90bb8cd6ec59e379eeb28f42..05ecb7207d53c975a0925e3b2280c89ff1177fad 100644 (file)
@@ -91,7 +91,7 @@ struct thread_master *master;
 char *config_file = NULL;
 
 /* Process ID saved for use by init system */
-char *pid_file = PATH_BGPD_PID;
+const char *pid_file = PATH_BGPD_PID;
 
 /* VTY port number and address.  */
 int vty_port = BGP_VTY_PORT;
index 90219cfe948230c87cc9c6aec062f9e196f0ee11..23b8d84b476fddcca58d8c722851912c3bc2e77f 100644 (file)
@@ -180,7 +180,7 @@ bgp_nlri_parse_vpnv4 (struct peer *peer, struct attr *attr,
 }
 
 int
-str2prefix_rd (char *str, struct prefix_rd *prd)
+str2prefix_rd (const char *str, struct prefix_rd *prd)
 {
   int ret;
   char *p;
@@ -236,15 +236,22 @@ str2prefix_rd (char *str, struct prefix_rd *prd)
 }
 
 int
-str2tag (char *str, u_char *tag)
+str2tag (const char *str, u_char *tag)
 {
-  u_int32_t l;
+  unsigned long l;
+  char *endptr;
+  u_int32_t t;
 
-  l = atol (str);
+  l = strtoul (str, &endptr, 10);
+  
+  if (*endptr == '\0' || l == ULONG_MAX || l > UINT32_MAX)
+    return 0;
 
-  tag[0] = (u_char)(l >> 12);
-  tag[1] = (u_char)(l >> 4);
-  tag[2] = (u_char)(l << 4);
+  t = (u_int32_t) l;
+  
+  tag[0] = (u_char)(t >> 12);
+  tag[1] = (u_char)(t >> 4);
+  tag[2] = (u_char)(t << 4);
 
   return 1;
 }
index a5f3eb371a1a72cb6f30cc5397b78f416b15511a..5d8d6fb0339b93fa474511d0a1c8bfb80d5b0594 100644 (file)
@@ -40,6 +40,6 @@ struct rd_ip
 void bgp_mplsvpn_init ();
 int bgp_nlri_parse_vpnv4 (struct peer *, struct attr *, struct bgp_nlri *);
 u_int32_t decode_label (u_char *);
-int str2prefix_rd (char *, struct prefix_rd *);
-int str2tag (char *, u_char *);
+int str2prefix_rd (const char *, struct prefix_rd *);
+int str2tag (const char *, u_char *);
 char *prefix_rd2str (struct prefix_rd *, char *, size_t);
index b4cd1301610e5a1d24668e44def70d410e1a74c0..dc5d36915e42d2a51a043b7215ec69e99b92637b 100644 (file)
@@ -548,7 +548,7 @@ bgp_write (struct thread *thread)
   u_char type;
   struct stream *s; 
   int num;
-  int count = 0;
+  unsigned int count = 0;
   int write_errno;
 
   /* Yes first of all get peer pointer. */
@@ -873,7 +873,7 @@ bgp_notify_send (struct peer *peer, u_char code, u_char sub_code)
   bgp_notify_send_with_data (peer, code, sub_code, NULL, 0);
 }
 
-char *
+const char *
 afi2str (afi_t afi)
 {
   if (afi == AFI_IP)
@@ -884,7 +884,7 @@ afi2str (afi_t afi)
     return "Unknown AFI";
 }
 
-char *
+const char *
 safi2str (safi_t safi)
 {
   if (safi == SAFI_UNICAST)
index 7bbcdb230457e20c30c69c954176f23238e3ad7d..d9afd5c151998226b3bba8cf8fc0c09a1f402117 100644 (file)
@@ -18,10 +18,10 @@ along with GNU Zebra; see the file COPYING.  If not, write to the Free
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
-#define BGP_NLRI_LENGTH       1
-#define BGP_TOTAL_ATTR_LEN    2
-#define BGP_UNFEASIBLE_LEN    2
-#define BGP_WRITE_PACKET_MAX 10
+#define BGP_NLRI_LENGTH       1U
+#define BGP_TOTAL_ATTR_LEN    2U
+#define BGP_UNFEASIBLE_LEN    2U
+#define BGP_WRITE_PACKET_MAX 10U
 
 /* When to refresh */
 #define REFRESH_IMMEDIATE 1
index a6b6598429d755d7865c3a5d3ca8ace3b3fdd1ce..be84d4071cff7e775af2c964e3cbee92b8af9727 100644 (file)
@@ -34,7 +34,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    (^|[,{}() ]|$) */
 
 regex_t *
-bgp_regcomp (char *regstr)
+bgp_regcomp (const char *regstr)
 {
   /* Convert _ character to generic regular expression. */
   int i, j;
index 0829dd9abe4c17b1b56135794d1f68bd85c84bd1..1320711f2f53369e775f269f882c78f39eaafc57 100644 (file)
@@ -27,5 +27,5 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #endif /* HAVE_GNU_REGEX */
 
 void bgp_regex_free (regex_t *regex);
-regex_t *bgp_regcomp (char *str);
+regex_t *bgp_regcomp (const char *str);
 int bgp_regexec (regex_t *regex, struct aspath *aspath);
index 6b49e2c86ab62e280d5772994ae1e4b641034a1b..dbd29cbf52e1aa593ea76e27c2e4ddba9f1219b2 100644 (file)
@@ -1399,7 +1399,7 @@ bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
   struct attr *attr_new2;
   struct bgp_info *ri;
   struct bgp_info *new;
-  char *reason;
+  const char *reason;
   char buf[SU_ADDRSTRLEN];
 
   /* Do not insert announces from a rsclient into its own 'bgp_table'. */
@@ -1612,7 +1612,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
   struct attr *attr_new;
   struct bgp_info *ri;
   struct bgp_info *new;
-  char *reason;
+  const char *reason;
   char buf[SU_ADDRSTRLEN];
 
   bgp = peer->bgp;
@@ -2920,8 +2920,8 @@ bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi,
 /* Configure static BGP network.  When user don't run zebra, static
    route should be installed as valid.  */
 int
-bgp_static_set (struct vty *vty, struct bgp *bgp, char *ip_str, u_int16_t afi,
-               u_char safi, char *rmap, int backdoor)
+bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, 
+                u_int16_t afi, u_char safi, const char *rmap, int backdoor)
 {
   int ret;
   struct prefix p;
@@ -3012,7 +3012,7 @@ bgp_static_set (struct vty *vty, struct bgp *bgp, char *ip_str, u_int16_t afi,
 
 /* Configure static BGP network. */
 int
-bgp_static_unset (struct vty *vty, struct bgp *bgp, char *ip_str,
+bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
                  u_int16_t afi, u_char safi)
 {
   int ret;
@@ -3106,8 +3106,8 @@ bgp_static_delete (struct bgp *bgp)
 }
 
 int
-bgp_static_set_vpnv4 (struct vty *vty, char *ip_str, char *rd_str,
-                     char *tag_str)
+bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str,
+                     const char *tag_str)
 {
   int ret;
   struct prefix p;
@@ -3174,8 +3174,8 @@ bgp_static_set_vpnv4 (struct vty *vty, char *ip_str, char *rd_str,
 
 /* Configure static BGP network. */
 int
-bgp_static_unset_vpnv4 (struct vty *vty, char *ip_str, char *rd_str,
-                       char *tag_str)
+bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, 
+                        const char *rd_str, const char *tag_str)
 {
   int ret;
   struct bgp *bgp;
@@ -4034,7 +4034,8 @@ bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi,
 #define AGGREGATE_AS_SET       1
 
 int
-bgp_aggregate_set (struct vty *vty, char *prefix_str, afi_t afi, safi_t safi,
+bgp_aggregate_set (struct vty *vty, const char *prefix_str, 
+                   afi_t afi, safi_t safi,
                   u_char summary_only, u_char as_set)
 {
   int ret;
@@ -4082,7 +4083,8 @@ bgp_aggregate_set (struct vty *vty, char *prefix_str, afi_t afi, safi_t safi,
 }
 
 int
-bgp_aggregate_unset (struct vty *vty, char *prefix_str, afi_t afi, safi_t safi)
+bgp_aggregate_unset (struct vty *vty, const char *prefix_str, 
+                     afi_t afi, safi_t safi)
 {
   int ret;
   struct prefix p;
@@ -5864,9 +5866,9 @@ route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
 /* Display specified route of BGP table. */
 int
 bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, 
-                         struct bgp_table *rib, char *ip_str, 
-               afi_t afi, safi_t safi, struct prefix_rd *prd,
-               int prefix_check)
+                         struct bgp_table *rib, const char *ip_str,
+                         afi_t afi, safi_t safi, struct prefix_rd *prd,
+                         int prefix_check)
 {
   int ret;
   int header;
@@ -5952,7 +5954,7 @@ bgp_show_route_in_table (struct vty *vty, struct bgp *bgp,
 
 /* Display specified route of Main RIB */
 int
-bgp_show_route (struct vty *vty, char *view_name, char *ip_str,
+bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
                afi_t afi, safi_t safi, struct prefix_rd *prd,
                int prefix_check)
 {
@@ -6390,7 +6392,7 @@ bgp_show_regexp_clean (struct vty *vty)
 }
 
 int
-bgp_show_regexp (struct vty *vty, int argc, char **argv, afi_t afi,
+bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
                 safi_t safi, enum bgp_show_type type)
 {
   int i;
@@ -6532,7 +6534,7 @@ DEFUN (show_ipv6_mbgp_regexp,
 #endif /* HAVE_IPV6 */
 \f
 int
-bgp_show_prefix_list (struct vty *vty, char *prefix_list_str, afi_t afi,
+bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi,
                      safi_t safi, enum bgp_show_type type)
 {
   struct prefix_list *plist;
@@ -6649,7 +6651,7 @@ DEFUN (show_ipv6_mbgp_prefix_list,
 #endif /* HAVE_IPV6 */
 \f
 int
-bgp_show_filter_list (struct vty *vty, char *filter, afi_t afi,
+bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi,
                      safi_t safi, enum bgp_show_type type)
 {
   struct as_list *as_list;
@@ -6765,7 +6767,7 @@ DEFUN (show_ipv6_mbgp_filter_list,
 #endif /* HAVE_IPV6 */
 \f
 int
-bgp_show_route_map (struct vty *vty, char *rmap_str, afi_t afi,
+bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi,
                    safi_t safi, enum bgp_show_type type)
 {
   struct route_map *rmap;
@@ -6974,8 +6976,8 @@ DEFUN (show_ipv6_mbgp_community_all,
 #endif /* HAVE_IPV6 */
 \f
 int
-bgp_show_community (struct vty *vty, int argc, char **argv, int exact,
-                                         u_int16_t afi, u_char safi)
+bgp_show_community (struct vty *vty, int argc, const char **argv, int exact,
+                    u_int16_t afi, u_char safi)
 {
   struct community *com;
   struct buffer *b;
@@ -7977,7 +7979,7 @@ ALIAS (show_ipv6_mbgp_community_exact,
 #endif /* HAVE_IPV6 */
 \f
 int
-bgp_show_community_list (struct vty *vty, char *com, int exact,
+bgp_show_community_list (struct vty *vty, const char *com, int exact,
                         u_int16_t afi, u_char safi)
 {
   struct community_list *list;
@@ -8168,7 +8170,7 @@ bgp_show_prefix_longer_clean (struct vty *vty)
 }
 
 int
-bgp_show_prefix_longer (struct vty *vty, char *prefix, afi_t afi,
+bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
                        safi_t safi, enum bgp_show_type type)
 {
   int ret;
@@ -8313,7 +8315,8 @@ DEFUN (show_ipv6_mbgp_prefix_longer,
 #endif /* HAVE_IPV6 */
 
 struct peer *
-peer_lookup_in_view (struct vty *vty, char *view_name, char *ip_str)
+peer_lookup_in_view (struct vty *vty, const char *view_name, 
+                     const char *ip_str)
 {
   int ret;
   struct bgp *bgp;
@@ -9695,8 +9698,8 @@ bgp_distance_free (struct bgp_distance *bdistance)
 }
 
 int
-bgp_distance_set (struct vty *vty, char *distance_str, char *ip_str,
-                 char *access_list_str)
+bgp_distance_set (struct vty *vty, const char *distance_str, 
+                  const char *ip_str, const char *access_list_str)
 {
   int ret;
   struct prefix_ipv4 p;
@@ -9742,8 +9745,8 @@ bgp_distance_set (struct vty *vty, char *distance_str, char *ip_str,
 }
 
 int
-bgp_distance_unset (struct vty *vty, char *distance_str, char *ip_str,
-                   char *access_list_str)
+bgp_distance_unset (struct vty *vty, const char *distance_str, 
+                    const char *ip_str, const char *access_list_str)
 {
   int ret;
   struct prefix_ipv4 p;
@@ -10060,9 +10063,9 @@ DEFUN (show_ip_bgp_flap_statistics,
 \f
 /* Display specified route of BGP table. */
 int
-bgp_clear_damp_route (struct vty *vty, char *view_name, char *ip_str,
-                     afi_t afi, safi_t safi, struct prefix_rd *prd,
-                     int prefix_check)
+bgp_clear_damp_route (struct vty *vty, const char *view_name, 
+                      const char *ip_str, afi_t afi, safi_t safi, 
+                      struct prefix_rd *prd, int prefix_check)
 {
   int ret;
   struct prefix match;
index 9aad72383baddb3eefa04bc488c371cf5774300f..d44c5021c720c2b181d1612888f28a58d6f6c2c5 100644 (file)
@@ -149,9 +149,11 @@ void bgp_static_update (struct bgp *, struct prefix *, struct bgp_static *,
                        afi_t, safi_t);
 void bgp_static_withdraw (struct bgp *, struct prefix *, afi_t, safi_t);
                      
-int bgp_static_set_vpnv4 (struct vty *vty, char *, char *, char *);
+int bgp_static_set_vpnv4 (struct vty *vty, const char *, 
+                          const char *, const char *);
 
-int bgp_static_unset_vpnv4 (struct vty *, char *, char *, char *);
+int bgp_static_unset_vpnv4 (struct vty *, const char *, 
+                            const char *, const char *);
 
 int bgp_config_write_network (struct vty *, struct bgp *, afi_t, safi_t, int *);
 int bgp_config_write_distance (struct vty *, struct bgp *);
index c49c2e9974aba96c4dc125b0483cf499546694e7..e2ad5e0fc8a2c87411c02e47d8649f7b32ea2493 100644 (file)
@@ -160,7 +160,7 @@ route_match_peer (void *rule, struct prefix *prefix, route_map_object_t type,
 }
 
 void *
-route_match_peer_compile (char *arg)
+route_match_peer_compile (const char *arg)
 {
   union sockunion *su;
   int ret;
@@ -218,7 +218,7 @@ route_match_ip_address (void *rule, struct prefix *prefix,
 /* Route map `ip address' match statement.  `arg' should be
    access-list name. */
 void *
-route_match_ip_address_compile (char *arg)
+route_match_ip_address_compile (const char *arg)
 {
   return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
 }
@@ -270,7 +270,7 @@ route_match_ip_next_hop (void *rule, struct prefix *prefix,
 /* Route map `ip next-hop' match statement. `arg' is
    access-list name. */
 void *
-route_match_ip_next_hop_compile (char *arg)
+route_match_ip_next_hop_compile (const char *arg)
 {
   return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
 }
@@ -312,7 +312,7 @@ route_match_ip_address_prefix_list (void *rule, struct prefix *prefix,
 }
 
 void *
-route_match_ip_address_prefix_list_compile (char *arg)
+route_match_ip_address_prefix_list_compile (const char *arg)
 {
   return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
 }
@@ -359,7 +359,7 @@ route_match_ip_next_hop_prefix_list (void *rule, struct prefix *prefix,
 }
 
 void *
-route_match_ip_next_hop_prefix_list_compile (char *arg)
+route_match_ip_next_hop_prefix_list_compile (const char *arg)
 {
   return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
 }
@@ -403,16 +403,21 @@ route_match_metric (void *rule, struct prefix *prefix,
 
 /* Route map `match metric' match statement. `arg' is MED value */
 void *
-route_match_metric_compile (char *arg)
+route_match_metric_compile (const char *arg)
 {
   u_int32_t *med;
   char *endptr = NULL;
   unsigned long tmpval;
 
   tmpval = strtoul (arg, &endptr, 10);
-  if (*endptr != '\0' || tmpval == ULONG_MAX)
+  if (*endptr != '\0' || tmpval == ULONG_MAX || tmpval > UINT32_MAX)
     return NULL;
+    
   med = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t));
+  
+  if (!med)
+    return med;
+  
   *med = tmpval;
   return med;
 }
@@ -460,7 +465,7 @@ route_match_aspath (void *rule, struct prefix *prefix,
 
 /* Compile function for as-path match. */
 void *
-route_match_aspath_compile (char *arg)
+route_match_aspath_compile (const char *arg)
 {
   return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
 }
@@ -500,7 +505,7 @@ route_match_aspath (void *rule, struct prefix *prefix, void *object)
 
 /* Compile function for as-path match. */
 void *
-route_match_aspath_compile (char *arg)
+route_match_aspath_compile (const char *arg)
 {
   regex_t *regex;
 
@@ -571,7 +576,7 @@ route_match_community (void *rule, struct prefix *prefix,
 
 /* Compile function for community match. */
 void *
-route_match_community_compile (char *arg)
+route_match_community_compile (const char *arg)
 {
   struct rmap_community *rcom;
   int len;
@@ -639,7 +644,7 @@ route_match_ecommunity (void *rule, struct prefix *prefix,
 
 /* Compile function for extcommunity match. */
 void *
-route_match_ecommunity_compile (char *arg)
+route_match_ecommunity_compile (const char *arg)
 {
   return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
 }
@@ -684,7 +689,7 @@ route_match_origin (void *rule, struct prefix *prefix,
 }
 
 void *
-route_match_origin_compile (char *arg)
+route_match_origin_compile (const char *arg)
 {
   u_char *origin;
 
@@ -772,7 +777,7 @@ route_set_ip_nexthop (void *rule, struct prefix *prefix,
 /* Route map `ip nexthop' compile function.  Given string is converted
    to struct in_addr structure. */
 void *
-route_set_ip_nexthop_compile (char *arg)
+route_set_ip_nexthop_compile (const char *arg)
 {
   struct rmap_ip_nexthop_set *rins;
   struct in_addr *address = NULL;
@@ -849,22 +854,27 @@ route_set_local_pref (void *rule, struct prefix *prefix,
 
 /* set local preference compilation. */
 void *
-route_set_local_pref_compile (char *arg)
+route_set_local_pref_compile (const char *arg)
 {
+  unsigned long tmp;
   u_int32_t *local_pref;
   char *endptr = NULL;
 
   /* Local preference value shoud be integer. */
   if (! all_digit (arg))
     return NULL;
-
-  local_pref = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t));
-  *local_pref = strtoul (arg, &endptr, 10);
-  if (*endptr != '\0' || *local_pref == ULONG_MAX)
-    {
-      XFREE (MTYPE_ROUTE_MAP_COMPILED, local_pref);
-      return NULL;
-    }
+  
+  tmp = strtoul (arg, &endptr, 10);
+  if (*endptr != '\0' || tmp == ULONG_MAX || tmp > UINT32_MAX)
+    return NULL;
+   
+  local_pref = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t)); 
+  
+  if (!local_pref)
+    return local_pref;
+  
+  *local_pref = tmp;
+  
   return local_pref;
 }
 
@@ -909,8 +919,9 @@ route_set_weight (void *rule, struct prefix *prefix, route_map_object_t type,
 
 /* set local preference compilation. */
 void *
-route_set_weight_compile (char *arg)
+route_set_weight_compile (const char *arg)
 {
+  unsigned long tmp;
   u_int32_t *weight;
   char *endptr = NULL;
 
@@ -918,13 +929,18 @@ route_set_weight_compile (char *arg)
   if (! all_digit (arg))
     return NULL;
 
+
+  tmp = strtoul (arg, &endptr, 10);
+  if (*endptr != '\0' || tmp == ULONG_MAX || tmp > UINT32_MAX)
+    return NULL;
+  
   weight = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t));
-  *weight = strtoul (arg, &endptr, 10);
-  if (*endptr != '\0' || *weight == ULONG_MAX)
-    {
-      XFREE (MTYPE_ROUTE_MAP_COMPILED, weight);
-      return NULL;
-    }
+  
+  if (weight == NULL)
+    return weight;
+  
+  *weight = tmp;  
+  
   return weight;
 }
 
@@ -995,7 +1011,7 @@ route_set_metric (void *rule, struct prefix *prefix,
 
 /* set metric compilation. */
 void *
-route_set_metric_compile (char *arg)
+route_set_metric_compile (const char *arg)
 {
   u_int32_t metric;
   char *endptr = NULL;
@@ -1068,7 +1084,7 @@ route_set_aspath_prepend (void *rule, struct prefix *prefix, route_map_object_t
 
 /* Compile function for as-path prepend. */
 void *
-route_set_aspath_prepend_compile (char *arg)
+route_set_aspath_prepend_compile (const char *arg)
 {
   struct aspath *aspath;
 
@@ -1149,7 +1165,7 @@ route_set_community (void *rule, struct prefix *prefix,
 
 /* Compile function for set community. */
 void *
-route_set_community_compile (char *arg)
+route_set_community_compile (const char *arg)
 {
   struct rmap_com_set *rcs;
   struct community *com = NULL;
@@ -1256,7 +1272,7 @@ route_set_community_delete (void *rule, struct prefix *prefix,
 
 /* Compile function for set community. */
 void *
-route_set_community_delete_compile (char *arg)
+route_set_community_delete_compile (const char *arg)
 {
   char *p;
   char *str;
@@ -1328,7 +1344,7 @@ route_set_ecommunity_rt (void *rule, struct prefix *prefix,
 
 /* Compile function for set community. */
 void *
-route_set_ecommunity_rt_compile (char *arg)
+route_set_ecommunity_rt_compile (const char *arg)
 {
   struct ecommunity *ecom;
 
@@ -1381,7 +1397,7 @@ route_set_ecommunity_soo (void *rule, struct prefix *prefix,
 
 /* Compile function for set community. */
 void *
-route_set_ecommunity_soo_compile (char *arg)
+route_set_ecommunity_soo_compile (const char *arg)
 {
   struct ecommunity *ecom;
 
@@ -1431,7 +1447,7 @@ route_set_origin (void *rule, struct prefix *prefix, route_map_object_t type, vo
 
 /* Compile function for origin set. */
 void *
-route_set_origin_compile (char *arg)
+route_set_origin_compile (const char *arg)
 {
   u_char *origin;
 
@@ -1483,7 +1499,7 @@ route_set_atomic_aggregate (void *rule, struct prefix *prefix,
 
 /* Compile function for atomic aggregate. */
 void *
-route_set_atomic_aggregate_compile (char *arg)
+route_set_atomic_aggregate_compile (const char *arg)
 {
   return (void *)1;
 }
@@ -1532,7 +1548,7 @@ route_set_aggregator_as (void *rule, struct prefix *prefix,
 }
 
 void *
-route_set_aggregator_as_compile (char *arg)
+route_set_aggregator_as_compile (const char *arg)
 {
   struct aggregator *aggregator;
   char as[10];
@@ -1585,7 +1601,7 @@ route_match_ipv6_address (void *rule, struct prefix *prefix,
 }
 
 void *
-route_match_ipv6_address_compile (char *arg)
+route_match_ipv6_address_compile (const char *arg)
 {
   return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
 }
@@ -1633,7 +1649,7 @@ route_match_ipv6_next_hop (void *rule, struct prefix *prefix,
 }
 
 void *
-route_match_ipv6_next_hop_compile (char *arg)
+route_match_ipv6_next_hop_compile (const char *arg)
 {
   struct in6_addr *address;
   int ret;
@@ -1685,7 +1701,7 @@ route_match_ipv6_address_prefix_list (void *rule, struct prefix *prefix,
 }
 
 void *
-route_match_ipv6_address_prefix_list_compile (char *arg)
+route_match_ipv6_address_prefix_list_compile (const char *arg)
 {
   return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
 }
@@ -1734,7 +1750,7 @@ route_set_ipv6_nexthop_global (void *rule, struct prefix *prefix,
 /* Route map `ip next-hop' compile function.  Given string is converted
    to struct in_addr structure. */
 void *
-route_set_ipv6_nexthop_global_compile (char *arg)
+route_set_ipv6_nexthop_global_compile (const char *arg)
 {
   int ret;
   struct in6_addr *address;
@@ -1798,7 +1814,7 @@ route_set_ipv6_nexthop_local (void *rule, struct prefix *prefix,
 /* Route map `ip nexthop' compile function.  Given string is converted
    to struct in_addr structure. */
 void *
-route_set_ipv6_nexthop_local_compile (char *arg)
+route_set_ipv6_nexthop_local_compile (const char *arg)
 {
   int ret;
   struct in6_addr *address;
@@ -1856,7 +1872,7 @@ route_set_vpnv4_nexthop (void *rule, struct prefix *prefix,
 }
 
 void *
-route_set_vpnv4_nexthop_compile (char *arg)
+route_set_vpnv4_nexthop_compile (const char *arg)
 {
   int ret;
   struct in_addr *address;
@@ -1912,7 +1928,7 @@ route_set_originator_id (void *rule, struct prefix *prefix, route_map_object_t t
 
 /* Compile function for originator-id set. */
 void *
-route_set_originator_id_compile (char *arg)
+route_set_originator_id_compile (const char *arg)
 {
   int ret;
   struct in_addr *address;
@@ -1949,7 +1965,7 @@ struct route_map_rule_cmd route_set_originator_id_cmd =
 /* Add bgp route map rule. */
 int
 bgp_route_match_add (struct vty *vty, struct route_map_index *index,
-                   char *command, char *arg)
+                    const char *command, const char *arg)
 {
   int ret;
 
@@ -1974,7 +1990,7 @@ bgp_route_match_add (struct vty *vty, struct route_map_index *index,
 /* Delete bgp route map rule. */
 int
 bgp_route_match_delete (struct vty *vty, struct route_map_index *index,
-                       char *command, char *arg)
+                       const char *command, const char *arg)
 {
   int ret;
 
@@ -1999,7 +2015,7 @@ bgp_route_match_delete (struct vty *vty, struct route_map_index *index,
 /* Add bgp route map rule. */
 int
 bgp_route_set_add (struct vty *vty, struct route_map_index *index,
-                  char *command, char *arg)
+                  const char *command, const char *arg)
 {
   int ret;
 
@@ -2024,7 +2040,7 @@ bgp_route_set_add (struct vty *vty, struct route_map_index *index,
 /* Delete bgp route map rule. */
 int
 bgp_route_set_delete (struct vty *vty, struct route_map_index *index,
-                     char *command, char *arg)
+                     const char *command, const char *arg)
 {
   int ret;
 
@@ -2048,7 +2064,7 @@ bgp_route_set_delete (struct vty *vty, struct route_map_index *index,
 
 /* Hook function for updating route_map assignment. */
 void
-bgp_route_map_update (char *unused)
+bgp_route_map_update (const char *unused)
 {
   int i;
   afi_t afi;
@@ -3083,16 +3099,10 @@ DEFUN (set_aggregator_as,
   int ret;
   as_t as;
   struct in_addr address;
-  char *endptr = NULL;
   char *argstr;
 
-  as = strtoul (argv[0], &endptr, 10);
-  if (as == 0 || as == ULONG_MAX || *endptr != '\0')
-    {
-      vty_out (vty, "AS path value malformed%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
-
+  VTY_GET_INTEGER_RANGE ("AS Path", as, argv[0], 1, BGP_AS_MAX)
+  
   ret = inet_aton (argv[1], &address);
   if (ret == 0)
     {
@@ -3123,18 +3133,12 @@ DEFUN (no_set_aggregator_as,
   int ret;
   as_t as;
   struct in_addr address;
-  char *endptr = NULL;
   char *argstr;
 
   if (argv == 0)
     return bgp_route_set_delete (vty, vty->index, "aggregator as", NULL);
   
-  as = strtoul (argv[0], &endptr, 10);
-  if (as == 0 || as == ULONG_MAX || *endptr != '\0')
-    {
-      vty_out (vty, "AS path value malformed%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
+  VTY_GET_INTEGER_RANGE ("AS Path", as, argv[0], 1, BGP_AS_MAX)  
 
   ret = inet_aton (argv[1], &address);
   if (ret == 0)
index 6e9beab426a48fb1e708504c573670c1a1369309..e5bcd03baf9c2ba9b9c13054aea65bcf0236037b 100644 (file)
@@ -627,7 +627,7 @@ bgp4PathAttrLookup (struct variable *v, oid name[], size_t *length,
   struct bgp_info *min;
   struct bgp_node *rn;
   union sockunion su;
-  int len;
+  unsigned int len;
   struct in_addr paddr;
 
 #define BGP_PATHATTR_ENTRY_OFFSET \
index 6b3c4988d5d51fa12b2a70cc1a1ce26017b7ba51..027b8ca98e5daa05309b79bcb95a06089d82cd36 100644 (file)
@@ -84,7 +84,7 @@ peer_address_self_check (union sockunion *su)
 
 /* Utility function for looking up peer from VTY.  */
 struct peer *
-peer_lookup_vty (struct vty *vty, char *ip_str)
+peer_lookup_vty (struct vty *vty, const char *ip_str)
 {
   int ret;
   struct bgp *bgp;
@@ -111,7 +111,7 @@ peer_lookup_vty (struct vty *vty, char *ip_str)
 
 /* Utility function for looking up peer or peer group.  */
 struct peer *
-peer_and_group_lookup_vty (struct vty *vty, char *peer_str)
+peer_and_group_lookup_vty (struct vty *vty, const char *peer_str)
 {
   int ret;
   struct bgp *bgp;
@@ -144,7 +144,7 @@ peer_and_group_lookup_vty (struct vty *vty, char *peer_str)
 int
 bgp_vty_return (struct vty *vty, int ret)
 {
-  char *str = NULL;
+  const char *str = NULL;
 
   switch (ret)
     {
@@ -297,7 +297,7 @@ DEFUN (router_bgp,
   int ret;
   as_t as;
   struct bgp *bgp;
-  char *name = NULL;
+  const char *name = NULL;
 
   VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, 65535);
 
@@ -350,7 +350,7 @@ DEFUN (no_router_bgp,
 {
   as_t as;
   struct bgp *bgp;
-  char *name = NULL;
+  const char *name = NULL;
 
   VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, 65535);
 
@@ -1143,8 +1143,8 @@ ALIAS (no_bgp_default_local_preference,
        "Configure default local preference value\n")
 \f
 static int
-peer_remote_as_vty (struct vty *vty, char *peer_str, char *as_str, afi_t afi,
-                   safi_t safi)
+peer_remote_as_vty (struct vty *vty, const char *peer_str, 
+                    const char *as_str, afi_t afi, safi_t safi)
 {
   int ret;
   struct bgp *bgp;
@@ -1508,7 +1508,8 @@ DEFUN (no_neighbor_set_peer_group,
 }
 \f
 int
-peer_flag_modify_vty (struct vty *vty, char *ip_str, u_int16_t flag, int set)
+peer_flag_modify_vty (struct vty *vty, const char *ip_str, 
+                      u_int16_t flag, int set)
 {
   int ret;
   struct peer *peer;
@@ -1526,13 +1527,13 @@ peer_flag_modify_vty (struct vty *vty, char *ip_str, u_int16_t flag, int set)
 }
 
 int
-peer_flag_set_vty (struct vty *vty, char *ip_str, u_int16_t flag)
+peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
 {
   return peer_flag_modify_vty (vty, ip_str, flag, 1);
 }
 
 int
-peer_flag_unset_vty (struct vty *vty, char *ip_str, u_int16_t flag)
+peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
 {
   return peer_flag_modify_vty (vty, ip_str, flag, 0);
 }
@@ -1652,7 +1653,7 @@ DEFUN (no_neighbor_dont_capability_negotiate,
 }
 \f
 int
-peer_af_flag_modify_vty (struct vty *vty, char *peer_str, afi_t afi,
+peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
                         safi_t safi, u_int32_t flag, int set)
 {
   int ret;
@@ -1671,14 +1672,14 @@ peer_af_flag_modify_vty (struct vty *vty, char *peer_str, afi_t afi,
 }
 
 int
-peer_af_flag_set_vty (struct vty *vty, char *peer_str, afi_t afi,
+peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
                      safi_t safi, u_int32_t flag)
 {
   return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
 }
 
 int
-peer_af_flag_unset_vty (struct vty *vty, char *peer_str, afi_t afi,
+peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
                        safi_t safi, u_int32_t flag)
 {
   return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
@@ -1929,7 +1930,8 @@ DEFUN (no_neighbor_route_reflector_client,
 }
 \f
 int
-peer_rsclient_set_vty (struct vty *vty, char *peer_str, int afi, int safi)
+peer_rsclient_set_vty (struct vty *vty, const char *peer_str, 
+                       int afi, int safi)
 {
   int ret;
   struct bgp *bgp;
@@ -2010,7 +2012,8 @@ peer_rsclient_set_vty (struct vty *vty, char *peer_str, int afi, int safi)
 }
 
 int
-peer_rsclient_unset_vty (struct vty *vty, char *peer_str, int afi, int safi)
+peer_rsclient_unset_vty (struct vty *vty, const char *peer_str, 
+                         int afi, int safi)
 {
   int ret;
   struct bgp *bgp;
@@ -2466,10 +2469,11 @@ DEFUN (neighbor_transparent_nexthop,
 \f
 /* EBGP multihop configuration. */
 int
-peer_ebgp_multihop_set_vty (struct vty *vty, char *ip_str, char *ttl_str)
+peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, 
+                            const char *ttl_str)
 {
   struct peer *peer;
-  int ttl;
+  unsigned int ttl;
 
   peer = peer_and_group_lookup_vty (vty, ip_str);
   if (! peer)
@@ -2486,7 +2490,7 @@ peer_ebgp_multihop_set_vty (struct vty *vty, char *ip_str, char *ttl_str)
 }
 
 int
-peer_ebgp_multihop_unset_vty (struct vty *vty, char *ip_str) 
+peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) 
 {
   struct peer *peer;
 
@@ -2632,7 +2636,8 @@ ALIAS (no_neighbor_description,
 \f
 /* Neighbor update-source. */
 int
-peer_update_source_vty (struct vty *vty, char *peer_str, char *source_str)
+peer_update_source_vty (struct vty *vty, const char *peer_str, 
+                        const char *source_str)
 {
   struct peer *peer;
   union sockunion *su;
@@ -2682,8 +2687,9 @@ DEFUN (no_neighbor_update_source,
 }
 \f
 int
-peer_default_originate_set_vty (struct vty *vty, char *peer_str, afi_t afi,
-                               safi_t safi, char *rmap, int set)
+peer_default_originate_set_vty (struct vty *vty, const char *peer_str, 
+                                afi_t afi, safi_t safi, 
+                                const char *rmap, int set)
 {
   int ret;
   struct peer *peer;
@@ -2749,7 +2755,8 @@ ALIAS (no_neighbor_default_originate,
 \f
 /* Set neighbor's BGP port.  */
 int
-peer_port_vty (struct vty *vty, char *ip_str, int afi, char *port_str)
+peer_port_vty (struct vty *vty, const char *ip_str, int afi, 
+               const char *port_str)
 {
   struct peer *peer;
   u_int16_t port;
@@ -2808,7 +2815,8 @@ ALIAS (no_neighbor_port,
 \f
 /* neighbor weight. */
 int
-peer_weight_set_vty (struct vty *vty, char *ip_str, char *weight_str)
+peer_weight_set_vty (struct vty *vty, const char *ip_str, 
+                     const char *weight_str)
 {
   int ret;
   struct peer *peer;
@@ -2826,7 +2834,7 @@ peer_weight_set_vty (struct vty *vty, char *ip_str, char *weight_str)
 }
 
 int
-peer_weight_unset_vty (struct vty *vty, char *ip_str)
+peer_weight_unset_vty (struct vty *vty, const char *ip_str)
 {
   struct peer *peer;
 
@@ -2914,8 +2922,8 @@ DEFUN (no_neighbor_strict_capability,
 }
 \f
 int
-peer_timers_set_vty (struct vty *vty, char *ip_str, char *keep_str,
-                    char *hold_str)
+peer_timers_set_vty (struct vty *vty, const char *ip_str, 
+                     const char *keep_str, const char *hold_str)
 {
   int ret;
   struct peer *peer;
@@ -2935,7 +2943,7 @@ peer_timers_set_vty (struct vty *vty, char *ip_str, char *keep_str,
 }
 \f
 int
-peer_timers_unset_vty (struct vty *vty, char *ip_str)
+peer_timers_unset_vty (struct vty *vty, const char *ip_str)
 {
   int ret;
   struct peer *peer;
@@ -2973,7 +2981,8 @@ DEFUN (no_neighbor_timers,
 }
 \f
 int
-peer_timers_connect_set_vty (struct vty *vty, char *ip_str, char *time_str)
+peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, 
+                             const char *time_str)
 {
   int ret;
   struct peer *peer;
@@ -2991,7 +3000,7 @@ peer_timers_connect_set_vty (struct vty *vty, char *ip_str, char *time_str)
 }
 
 int
-peer_timers_connect_unset_vty (struct vty *vty, char *ip_str)
+peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
 {
   int ret;
   struct peer *peer;
@@ -3040,8 +3049,8 @@ ALIAS (no_neighbor_timers_connect,
        "Connect timer\n")
 \f
 int
-peer_advertise_interval_vty (struct vty *vty, char *ip_str, char *time_str,
-                            int set)  
+peer_advertise_interval_vty (struct vty *vty, const char *ip_str, 
+                             const char *time_str, int set)  
 {
   int ret;
   struct peer *peer;
@@ -3094,7 +3103,7 @@ ALIAS (no_neighbor_advertise_interval,
        "time in seconds\n")
 \f
 int
-peer_version_vty (struct vty *vty, char *ip_str, char *str)
+peer_version_vty (struct vty *vty, const char *ip_str, const char *str)
 {
   int ret;
   struct peer *peer;
@@ -3145,7 +3154,7 @@ DEFUN (no_neighbor_version,
 \f
 /* neighbor interface */
 int
-peer_interface_vty (struct vty *vty, char *ip_str, char *str)
+peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
 {
   int ret;
   struct peer *peer;
@@ -3187,8 +3196,9 @@ DEFUN (no_neighbor_interface,
 \f
 /* Set distribute list to the peer. */
 int
-peer_distribute_set_vty (struct vty *vty, char *ip_str, afi_t afi, safi_t safi,
-                        char *name_str, char *direct_str)
+peer_distribute_set_vty (struct vty *vty, const char *ip_str, 
+                         afi_t afi, safi_t safi,
+                        const char *name_str, const char *direct_str)
 {
   int ret;
   struct peer *peer;
@@ -3210,8 +3220,8 @@ peer_distribute_set_vty (struct vty *vty, char *ip_str, afi_t afi, safi_t safi,
 }
 
 int
-peer_distribute_unset_vty (struct vty *vty, char *ip_str, afi_t afi,
-                          safi_t safi, char *direct_str)
+peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
+                          safi_t safi, const char *direct_str)
 {
   int ret;
   struct peer *peer;
@@ -3267,8 +3277,9 @@ DEFUN (no_neighbor_distribute_list,
 \f
 /* Set prefix list to the peer. */
 int
-peer_prefix_list_set_vty (struct vty *vty, char *ip_str, afi_t afi,
-                         safi_t safi, char *name_str, char *direct_str)
+peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
+                         safi_t safi, const char *name_str, 
+                          const char *direct_str)
 {
   int ret;
   struct peer *peer;
@@ -3290,8 +3301,8 @@ peer_prefix_list_set_vty (struct vty *vty, char *ip_str, afi_t afi,
 }
 
 int
-peer_prefix_list_unset_vty (struct vty *vty, char *ip_str, afi_t afi,
-                           safi_t safi, char *direct_str)
+peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
+                           safi_t safi, const char *direct_str)
 {
   int ret;
   struct peer *peer;
@@ -3342,8 +3353,9 @@ DEFUN (no_neighbor_prefix_list,
 }
 \f
 int
-peer_aslist_set_vty (struct vty *vty, char *ip_str, afi_t afi, safi_t safi,
-                    char *name_str, char *direct_str)
+peer_aslist_set_vty (struct vty *vty, const char *ip_str, 
+                     afi_t afi, safi_t safi,
+                    const char *name_str, const char *direct_str)
 {
   int ret;
   struct peer *peer;
@@ -3365,8 +3377,9 @@ peer_aslist_set_vty (struct vty *vty, char *ip_str, afi_t afi, safi_t safi,
 }
 
 int
-peer_aslist_unset_vty (struct vty *vty, char *ip_str, afi_t afi, safi_t safi,
-                      char *direct_str)
+peer_aslist_unset_vty (struct vty *vty, const char *ip_str, 
+                       afi_t afi, safi_t safi,
+                      const char *direct_str)
 {
   int ret;
   struct peer *peer;
@@ -3418,8 +3431,9 @@ DEFUN (no_neighbor_filter_list,
 \f
 /* Set route-map to the peer. */
 int
-peer_route_map_set_vty (struct vty *vty, char *ip_str, afi_t afi, safi_t safi,
-                       char *name_str, char *direct_str)
+peer_route_map_set_vty (struct vty *vty, const char *ip_str, 
+                        afi_t afi, safi_t safi,
+                       const char *name_str, const char *direct_str)
 {
   int ret;
   struct peer *peer;
@@ -3445,8 +3459,8 @@ peer_route_map_set_vty (struct vty *vty, char *ip_str, afi_t afi, safi_t safi,
 }
 
 int
-peer_route_map_unset_vty (struct vty *vty, char *ip_str, afi_t afi,
-                         safi_t safi, char *direct_str)
+peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
+                         safi_t safi, const char *direct_str)
 {
   int ret;
   struct peer *peer;
@@ -3506,8 +3520,8 @@ DEFUN (no_neighbor_route_map,
 \f
 /* Set unsuppress-map to the peer. */
 int
-peer_unsuppress_map_set_vty (struct vty *vty, char *ip_str, afi_t afi,
-                            safi_t safi, char *name_str)
+peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
+                            safi_t safi, const char *name_str)
 {
   int ret;
   struct peer *peer;
@@ -3523,7 +3537,7 @@ peer_unsuppress_map_set_vty (struct vty *vty, char *ip_str, afi_t afi,
 
 /* Unset route-map from the peer. */
 int
-peer_unsuppress_map_unset_vty (struct vty *vty, char *ip_str, afi_t afi,
+peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
                               safi_t safi)
 {
   int ret;
@@ -3564,9 +3578,9 @@ DEFUN (no_neighbor_unsuppress_map,
 }
 \f
 int
-peer_maximum_prefix_set_vty (struct vty *vty, char *ip_str, afi_t afi,
-                            safi_t safi, char *num_str,  char *threshold_str,
-                             int warning)
+peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
+                            safi_t safi, const char *num_str,  
+                             const char *threshold_str, int warning)
 {
   int ret;
   struct peer *peer;
@@ -3589,7 +3603,7 @@ peer_maximum_prefix_set_vty (struct vty *vty, char *ip_str, afi_t afi,
 }
 
 int
-peer_maximum_prefix_unset_vty (struct vty *vty, char *ip_str, afi_t afi,
+peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
                               safi_t safi)
 {
   int ret;
@@ -3711,7 +3725,7 @@ DEFUN (neighbor_allowas_in,
 {
   int ret;
   struct peer *peer;
-  int allow_num;
+  unsigned int allow_num;
 
   peer = peer_and_group_lookup_vty (vty, argv[0]);
   if (! peer)
@@ -3863,7 +3877,7 @@ bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
 /* `clear ip bgp' functions. */
 int
 bgp_clear (struct vty *vty, struct bgp *bgp,  afi_t afi, safi_t safi,
-           enum clear_sort sort,enum bgp_clear_type stype, char *arg)
+           enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
 {
   int ret;
   struct peer *peer;
@@ -4005,8 +4019,9 @@ bgp_clear (struct vty *vty, struct bgp *bgp,  afi_t afi, safi_t safi,
 }
 
 int
-bgp_clear_vty (struct vty *vty, char *name, afi_t afi, safi_t safi,
-               enum clear_sort sort, enum bgp_clear_type stype, char *arg)  
+bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
+               enum clear_sort sort, enum bgp_clear_type stype, 
+               const char *arg)
 {
   int ret;
   struct bgp *bgp;
@@ -6412,7 +6427,8 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
 }
 
 int 
-bgp_show_summary_vty (struct vty *vty, char *name, afi_t afi, safi_t safi)
+bgp_show_summary_vty (struct vty *vty, const char *name, 
+                      afi_t afi, safi_t safi)
 {
   struct bgp *bgp;
 
@@ -6602,7 +6618,7 @@ DEFUN (show_ipv6_mbgp_summary,
 }
 #endif /* HAVE_IPV6 */
 \f
-char *
+const char *
 afi_safi_print (afi_t afi, safi_t safi)
 {
   if (afi == AFI_IP && safi == SAFI_UNICAST)
@@ -7187,8 +7203,8 @@ bgp_show_neighbor (struct vty *vty, struct bgp *bgp,
 }
 
 int 
-bgp_show_neighbor_vty (struct vty *vty, char *name, enum show_type type,
-                      char *ip_str)
+bgp_show_neighbor_vty (struct vty *vty, const char *name, 
+                       enum show_type type, const char *ip_str)
 {
   int ret;
   struct bgp *bgp;
@@ -7505,7 +7521,7 @@ bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
 {
   char timebuf[BGP_UPTIME_LEN];
   char rmbuf[14];
-  char *rmname;
+  const char *rmname;
   struct peer *peer;
   struct listnode *nn;
   int len;
@@ -7576,7 +7592,8 @@ bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
 }
 
 int
-bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi)
+bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp, 
+                           afi_t afi, safi_t safi)
 {
   struct peer *peer;
   struct listnode *nn;
@@ -7618,7 +7635,8 @@ bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t s
 }
 
 int
-bgp_show_rsclient_summary_vty (struct vty *vty, char *name, afi_t afi, safi_t safi)
+bgp_show_rsclient_summary_vty (struct vty *vty, const char *name, 
+                               afi_t afi, safi_t safi)
 {
   struct bgp *bgp;
 
@@ -7760,7 +7778,7 @@ ALIAS (show_bgp_instance_rsclient_summary,
 /* Utility function to convert user input route type string to route
    type.  */
 static int
-bgp_str2route_type (int afi, char *str)
+bgp_str2route_type (int afi, const char *str)
 {
   if (! str)
     return 0;
@@ -8306,7 +8324,7 @@ bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
                               safi_t safi, int *write)
 {
   int i;
-  char *str[] = { "system", "kernel", "connected", "static", "rip",
+  const char *str[] = { "system", "kernel", "connected", "static", "rip",
                  "ripng", "ospf", "ospf6", "isis", "bgp"};
 
   /* Unicast redistribution only.  */
@@ -9325,7 +9343,7 @@ bgp_vty_init ()
 /* VTY functions.  */
 
 /* Direction value to string conversion.  */
-char *
+const char *
 community_direct_str (int direct)
 {
   switch (direct)
@@ -9365,8 +9383,8 @@ community_list_perror (struct vty *vty, int ret)
 
 /* VTY interface for community_set() function.  */
 int
-community_list_set_vty (struct vty *vty, int argc, char **argv, int style,
-                       int reject_all_digit_name)
+community_list_set_vty (struct vty *vty, int argc, const char **argv, 
+                        int style, int reject_all_digit_name)
 {
   int ret;
   int direct;
@@ -9418,7 +9436,7 @@ community_list_set_vty (struct vty *vty, int argc, char **argv, int style,
 
 /* Community-list delete with name.  */
 int
-community_list_unset_all_vty (struct vty *vty, char *name)
+community_list_unset_all_vty (struct vty *vty, const char *name)
 {
   int ret;
 
@@ -9434,7 +9452,8 @@ community_list_unset_all_vty (struct vty *vty, char *name)
 
 /* Communiyt-list entry delete.  */
 int
-community_list_unset_vty (struct vty *vty, int argc, char **argv, int style)
+community_list_unset_vty (struct vty *vty, int argc, const char **argv, 
+                          int style)
 {
   int ret;
   int direct;
@@ -9738,8 +9757,8 @@ DEFUN (show_ip_community_list_arg,
 }
 \f
 int
-extcommunity_list_set_vty (struct vty *vty, int argc, char **argv, int style,
-                          int reject_all_digit_name)
+extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv, 
+                           int style, int reject_all_digit_name)
 {
   int ret;
   int direct;
@@ -9786,7 +9805,7 @@ extcommunity_list_set_vty (struct vty *vty, int argc, char **argv, int style,
 }
 
 int
-extcommunity_list_unset_all_vty (struct vty *vty, char *name)
+extcommunity_list_unset_all_vty (struct vty *vty, const char *name)
 {
   int ret;
 
@@ -9801,7 +9820,8 @@ extcommunity_list_unset_all_vty (struct vty *vty, char *name)
 }
 
 int
-extcommunity_list_unset_vty (struct vty *vty, int argc, char **argv, int style)
+extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv, 
+                             int style)
 {
   int ret;
   int direct;
@@ -10077,10 +10097,10 @@ DEFUN (show_ip_extcommunity_list_arg,
 }
 \f
 /* Return configuration string of community-list entry.  */
-static char *
+static const char *
 community_list_config_str (struct community_entry *entry)
 {
-  char *str;
+  const char *str;
 
   if (entry->any)
     str = "";
index 6226a9383fe547fa0f93b56a800be2b77bfe5a45..752617d4c2d723647096e6d903aaa3d33d2b6d4e 100644 (file)
@@ -842,7 +842,8 @@ bgp_redistribute_set (struct bgp *bgp, afi_t afi, int type)
 
 /* Redistribute with route-map specification.  */
 int
-bgp_redistribute_rmap_set (struct bgp *bgp, afi_t afi, int type, char *name)
+bgp_redistribute_rmap_set (struct bgp *bgp, afi_t afi, int type, 
+                           const char *name)
 {
   if (bgp->rmap[afi][type].name
       && (strcmp (bgp->rmap[afi][type].name, name) == 0))
index 1620c8478a0d3b41d856c58ec58743de966a1a28..d8407e8b6faa6b9342b33b7b9a302ff9e3249995 100644 (file)
@@ -25,7 +25,7 @@ void bgp_zebra_announce (struct prefix *, struct bgp_info *, struct bgp *);
 void bgp_zebra_withdraw (struct prefix *, struct bgp_info *);
 
 int bgp_redistribute_set (struct bgp *, afi_t, int);
-int bgp_redistribute_rmap_set (struct bgp *, afi_t, int, char *);
+int bgp_redistribute_rmap_set (struct bgp *, afi_t, int, const char *);
 int bgp_redistribute_metric_set (struct bgp *, afi_t, int, u_int32_t);
 int bgp_redistribute_unset (struct bgp *, afi_t, int);
 int bgp_redistribute_routemap_unset (struct bgp *, afi_t, int);
index 61ffe2799db44886560f686fa99e6d33141527ca..663f01be12609c70669a525ccf78222ba1e84c8e 100644 (file)
@@ -1197,7 +1197,7 @@ peer_group_free (struct peer_group *group)
 }
 
 struct peer_group *
-peer_group_lookup (struct bgp *bgp, char *name)
+peer_group_lookup (struct bgp *bgp, const char *name)
 {
   struct peer_group *group;
   struct listnode *nn;
@@ -1211,7 +1211,7 @@ peer_group_lookup (struct bgp *bgp, char *name)
 }
 
 struct peer_group *
-peer_group_get (struct bgp *bgp, char *name)
+peer_group_get (struct bgp *bgp, const char *name)
 {
   struct peer_group *group;
 
@@ -1490,7 +1490,7 @@ peer_group2peer_config_copy (struct peer_group *group, struct peer *peer,
 
 /* Peer group's remote AS configuration.  */
 int
-peer_group_remote_as (struct bgp *bgp, char *group_name, as_t *as)
+peer_group_remote_as (struct bgp *bgp, const char *group_name, as_t *as)
 {
   struct peer_group *group;
   struct peer *peer;
@@ -1738,7 +1738,7 @@ peer_group_unbind (struct bgp *bgp, struct peer *peer,
 \f
 /* BGP instance creation by `router bgp' commands. */
 struct bgp *
-bgp_create (as_t *as, char *name)
+bgp_create (as_t *as, const char *name)
 {
   struct bgp *bgp;
   afi_t afi;
@@ -1747,7 +1747,7 @@ bgp_create (as_t *as, char *name)
   bgp = XCALLOC (MTYPE_BGP, sizeof (struct bgp));
 
   bgp->peer_self = peer_new ();
-  bgp->peer_self->host = "Static announcement";
+  bgp->peer_self->host = strdup ("Static announcement");
 
   bgp->peer = list_new ();
   bgp->peer->cmp = (int (*)(void *, void *)) peer_cmp;
@@ -1800,7 +1800,7 @@ bgp_get_default ()
 
 /* Lookup BGP entry. */
 struct bgp *
-bgp_lookup (as_t as, char *name)
+bgp_lookup (as_t as, const char *name)
 {
   struct bgp *bgp;
   struct listnode *nn;
@@ -1815,7 +1815,7 @@ bgp_lookup (as_t as, char *name)
 
 /* Lookup BGP structure by view name. */
 struct bgp *
-bgp_lookup_by_name (char *name)
+bgp_lookup_by_name (const char *name)
 {
   struct bgp *bgp;
   struct listnode *nn;
@@ -1829,7 +1829,7 @@ bgp_lookup_by_name (char *name)
 
 /* Called from VTY commands. */
 int
-bgp_get (struct bgp **bgp_val, as_t *as, char *name)
+bgp_get (struct bgp **bgp_val, as_t *as, const char *name)
 {
   struct bgp *bgp;
 
@@ -2536,7 +2536,7 @@ peer_description_unset (struct peer *peer)
 \f
 /* Neighbor update-source. */
 int
-peer_update_source_if_set (struct peer *peer, char *ifname)
+peer_update_source_if_set (struct peer *peer, const char *ifname)
 {
   struct peer_group *group;
   struct listnode *nn;
@@ -2756,7 +2756,7 @@ peer_update_source_unset (struct peer *peer)
 \f
 int
 peer_default_originate_set (struct peer *peer, afi_t afi, safi_t safi,
-                           char *rmap)
+                           const char *rmap)
 {
   struct peer_group *group;
   struct listnode *nn;
@@ -3079,7 +3079,7 @@ peer_version_unset (struct peer *peer)
 \f
 /* neighbor interface */
 int
-peer_interface_set (struct peer *peer, char *str)
+peer_interface_set (struct peer *peer, const char *str)
 {
   if (peer->ifname)
     free (peer->ifname);
@@ -3273,7 +3273,7 @@ peer_local_as_unset (struct peer *peer)
 /* Set distribute list to the peer. */
 int
 peer_distribute_set (struct peer *peer, afi_t afi, safi_t safi, int direct, 
-                    char *name)
+                    const char *name)
 {
   struct bgp_filter *filter;
   struct peer_group *group;
@@ -3432,7 +3432,7 @@ peer_distribute_update (struct access_list *access)
 /* Set prefix list to the peer. */
 int
 peer_prefix_list_set (struct peer *peer, afi_t afi, safi_t safi, int direct, 
-                     char *name)
+                     const char *name)
 {
   struct bgp_filter *filter;
   struct peer_group *group;
@@ -3589,7 +3589,7 @@ peer_prefix_list_update (struct prefix_list *plist)
 \f
 int
 peer_aslist_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
-                char *name)
+                const char *name)
 {
   struct bgp_filter *filter;
   struct peer_group *group;
@@ -3745,7 +3745,7 @@ peer_aslist_update ()
 /* Set route-map to the peer. */
 int
 peer_route_map_set (struct peer *peer, afi_t afi, safi_t safi, int direct, 
-                   char *name)
+                   const char *name)
 {
   struct bgp_filter *filter;
   struct peer_group *group;
@@ -3850,7 +3850,8 @@ peer_route_map_unset (struct peer *peer, afi_t afi, safi_t safi, int direct)
 \f
 /* Set unsuppress-map to the peer. */
 int
-peer_unsuppress_map_set (struct peer *peer, afi_t afi, safi_t safi, char *name)
+peer_unsuppress_map_set (struct peer *peer, afi_t afi, safi_t safi, 
+                         const char *name)
 {
   struct bgp_filter *filter;
   struct peer_group *group;
@@ -4110,7 +4111,8 @@ peer_clear_soft (struct peer *peer, afi_t afi, safi_t safi,
   return 0;
 }
 \f
-/* Display peer uptime. */
+/* Display peer uptime.*/
+/* XXX: why does this function return char * when it takes buffer? */
 char *
 peer_uptime (time_t uptime2, char *buf, size_t len)
 {
@@ -4121,7 +4123,9 @@ peer_uptime (time_t uptime2, char *buf, size_t len)
   if (len < BGP_UPTIME_LEN)
     {
       zlog_warn ("peer_uptime (): buffer shortage %d", len);
-      return "";
+      /* XXX: should return status instead of buf... */
+      snprintf (buf, len, "<error> "); 
+      return buf;
     }
 
   /* If there is no connection has been done before print `never'. */
index ed3f4d18394e2c794c7154fa3bc9cbdc40c3c729..4137baf2e24cb30fb4d0995ac541a9fa84c65035 100644 (file)
@@ -766,11 +766,11 @@ int bgp_nexthop_set (union sockunion *, union sockunion *,
                     struct bgp_nexthop *, struct peer *);
 struct bgp_master *bgp_get_master ();
 struct bgp *bgp_get_default ();
-struct bgp *bgp_lookup (as_t, char *);
-struct bgp *bgp_lookup_by_name (char *);
+struct bgp *bgp_lookup (as_t, const char *);
+struct bgp *bgp_lookup_by_name (const char *);
 struct peer *peer_lookup (struct bgp *, union sockunion *);
-struct peer_group *peer_group_lookup (struct bgp *, char *);
-struct peer_group *peer_group_get (struct bgp *, char *);
+struct peer_group *peer_group_lookup (struct bgp *, const char *);
+struct peer_group *peer_group_get (struct bgp *, const char *);
 struct peer *peer_lookup_with_open (union sockunion *, as_t, struct in_addr *,
                                    int *);
 int peer_sort (struct peer *peer);
@@ -788,7 +788,7 @@ int bgp_option_set (int);
 int bgp_option_unset (int);
 int bgp_option_check (int);
 
-int bgp_get (struct bgp **, as_t *, char *);
+int bgp_get (struct bgp **, as_t *, const char *);
 int bgp_delete (struct bgp *);
 
 int bgp_flag_set (struct bgp *, int);
@@ -817,7 +817,7 @@ int bgp_default_local_preference_unset (struct bgp *);
 int peer_rsclient_active (struct peer *);
 
 int peer_remote_as (struct bgp *, union sockunion *, as_t *, afi_t, safi_t);
-int peer_group_remote_as (struct bgp *, char *, as_t *);
+int peer_group_remote_as (struct bgp *, const char *, as_t *);
 int peer_delete (struct peer *peer);
 int peer_group_delete (struct peer_group *);
 int peer_group_remote_as_delete (struct peer_group *);
@@ -843,11 +843,11 @@ int peer_ebgp_multihop_unset (struct peer *);
 int peer_description_set (struct peer *, char *);
 int peer_description_unset (struct peer *);
 
-int peer_update_source_if_set (struct peer *, char *);
+int peer_update_source_if_set (struct peer *, const char *);
 int peer_update_source_addr_set (struct peer *, union sockunion *);
 int peer_update_source_unset (struct peer *);
 
-int peer_default_originate_set (struct peer *, afi_t, safi_t, char *);
+int peer_default_originate_set (struct peer *, afi_t, safi_t, const char *);
 int peer_default_originate_unset (struct peer *, afi_t, safi_t);
 
 int peer_port_set (struct peer *, u_int16_t);
@@ -868,10 +868,10 @@ int peer_advertise_interval_unset (struct peer *);
 int peer_version_set (struct peer *, int);
 int peer_version_unset (struct peer *);
 
-int peer_interface_set (struct peer *, char *);
+int peer_interface_set (struct peer *, const char *);
 int peer_interface_unset (struct peer *);
 
-int peer_distribute_set (struct peer *, afi_t, safi_t, int, char *);
+int peer_distribute_set (struct peer *, afi_t, safi_t, int, const char *);
 int peer_distribute_unset (struct peer *, afi_t, safi_t, int);
 
 int peer_allowas_in_set (struct peer *, afi_t, safi_t, int);
@@ -880,16 +880,16 @@ int peer_allowas_in_unset (struct peer *, afi_t, safi_t);
 int peer_local_as_set (struct peer *, as_t, int);
 int peer_local_as_unset (struct peer *);
 
-int peer_prefix_list_set (struct peer *, afi_t, safi_t, int, char *);
+int peer_prefix_list_set (struct peer *, afi_t, safi_t, int, const char *);
 int peer_prefix_list_unset (struct peer *, afi_t, safi_t, int);
 
-int peer_aslist_set (struct peer *, afi_t, safi_t, int, char *);
+int peer_aslist_set (struct peer *, afi_t, safi_t, int, const char *);
 int peer_aslist_unset (struct peer *,afi_t, safi_t, int);
 
-int peer_route_map_set (struct peer *, afi_t, safi_t, int, char *);
+int peer_route_map_set (struct peer *, afi_t, safi_t, int, const char *);
 int peer_route_map_unset (struct peer *, afi_t, safi_t, int);
 
-int peer_unsuppress_map_set (struct peer *, afi_t, safi_t, char *);
+int peer_unsuppress_map_set (struct peer *, afi_t, safi_t, const char *);
 int peer_unsuppress_map_unset (struct peer *, afi_t, safi_t);
 
 int peer_maximum_prefix_set (struct peer *, afi_t, safi_t, u_int32_t, u_char, int);