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.
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index d5ab328..93feb05 100644
--- a/bgpd/ChangeLog
+++ b/bgpd/ChangeLog
@@ -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.
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index bcb8f16..5d49775 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -993,10 +993,10 @@
};
/* 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 @@
}
struct aspath *
-aspath_str2aspath (char *str)
+aspath_str2aspath (const char *str)
{
enum as_token token;
u_short as_type;
diff --git a/bgpd/bgp_aspath.h b/bgpd/bgp_aspath.h
index 0295faf..3f7858b 100644
--- a/bgpd/bgp_aspath.h
+++ b/bgpd/bgp_aspath.h
@@ -25,8 +25,10 @@
#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 @@
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 *);
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c
index a2c1210..572d11c 100644
--- a/bgpd/bgp_clist.c
+++ b/bgpd/bgp_clist.c
@@ -115,9 +115,9 @@
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 @@
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 @@
}
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 @@
/* 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 @@
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 @@
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 @@
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 @@
/* 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 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 @@
/* 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 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;
diff --git a/bgpd/bgp_clist.h b/bgpd/bgp_clist.h
index ffc707c..11db2d7 100644
--- a/bgpd/bgp_clist.h
+++ b/bgpd/bgp_clist.h
@@ -121,22 +121,24 @@
/* 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 *,
diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c
index 5467971..1a6514b 100644
--- a/bgpd/bgp_community.c
+++ b/bgpd/bgp_community.c
@@ -401,7 +401,7 @@
}
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 @@
/* 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 @@
};
/* 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 @@
/* 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;
diff --git a/bgpd/bgp_community.h b/bgpd/bgp_community.h
index 898ca9e..016b0f6 100644
--- a/bgpd/bgp_community.h
+++ b/bgpd/bgp_community.h
@@ -56,9 +56,9 @@
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 *);
diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c
index d70105f..9b7b5da 100644
--- a/bgpd/bgp_damp.c
+++ b/bgpd/bgp_damp.c
@@ -47,7 +47,7 @@
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 @@
int
bgp_damp_decay (time_t tdiff, int penalty)
{
- int i;
+ unsigned int i;
i = (int) ((double) tdiff / DELTA_T);
@@ -380,7 +380,7 @@
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 @@
}
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 @@
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_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 @@
#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;
diff --git a/bgpd/bgp_damp.h b/bgpd/bgp_damp.h
index f3b9bd6..09b953e 100644
--- a/bgpd/bgp_damp.h
+++ b/bgpd/bgp_damp.h
@@ -27,10 +27,10 @@
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 @@
/* 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_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 @@
#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_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 *);
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index 9c5208d..3196eff 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -66,7 +66,7 @@
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 @@
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 @@
/* 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 = "";
diff --git a/bgpd/bgp_debug.h b/bgpd/bgp_debug.h
index 14a8c5f..d060961 100644
--- a/bgpd/bgp_debug.h
+++ b/bgpd/bgp_debug.h
@@ -104,10 +104,10 @@
#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;
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index 9690fb5..f8637c6 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -462,7 +462,7 @@
}
unsigned int
-bgp_dump_parse_time (char *str)
+bgp_dump_parse_time (const char *str)
{
int i;
int len;
@@ -510,7 +510,7 @@
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;
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c
index b3fc1c3..32bf68f 100644
--- a/bgpd/bgp_ecommunity.c
+++ b/bgpd/bgp_ecommunity.c
@@ -245,7 +245,8 @@
/* 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 @@
};
/* 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 @@
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 @@
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 @@
int str_size;
int str_pnt;
char *str_buf;
- char *prefix;
+ const char *prefix;
int len = 0;
int first = 1;
@@ -650,7 +651,8 @@
}
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;
diff --git a/bgpd/bgp_ecommunity.h b/bgpd/bgp_ecommunity.h
index e7be786..56e9f18 100644
--- a/bgpd/bgp_ecommunity.h
+++ b/bgpd/bgp_ecommunity.h
@@ -68,10 +68,10 @@
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 *);
diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c
index 7a8fb03..09dcc0f 100644
--- a/bgpd/bgp_filter.c
+++ b/bgpd/bgp_filter.c
@@ -119,7 +119,7 @@
/* 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 @@
}
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 @@
/* 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 @@
/* 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 @@
}
struct as_list *
-as_list_get (char *name)
+as_list_get (const char *name)
{
struct as_list *aslist;
@@ -296,7 +296,7 @@
return aslist;
}
-static char *
+static const char *
filter_type_str (enum as_filter_type type)
{
switch (type)
diff --git a/bgpd/bgp_filter.h b/bgpd/bgp_filter.h
index 8d55a22..ec48ca1 100644
--- a/bgpd/bgp_filter.h
+++ b/bgpd/bgp_filter.h
@@ -26,6 +26,6 @@
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) ());
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index 2874a9a..dd65fac 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -308,7 +308,7 @@
}
/* BGP Peer Down Cause */
-char *peer_down_str[] =
+const char *peer_down_str[] =
{
"",
"Router ID changed",
@@ -828,7 +828,7 @@
},
};
-static char *bgp_event_str[] =
+static const char *bgp_event_str[] =
{
NULL,
"BGP_Start",
diff --git a/bgpd/bgp_fsm.h b/bgpd/bgp_fsm.h
index ce816e2..20fc2d7 100644
--- a/bgpd/bgp_fsm.h
+++ b/bgpd/bgp_fsm.h
@@ -40,4 +40,4 @@
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[];
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index a4cd9ab..05ecb72 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -91,7 +91,7 @@
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;
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 90219cf..23b8d84 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -180,7 +180,7 @@
}
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 @@
}
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;
}
diff --git a/bgpd/bgp_mplsvpn.h b/bgpd/bgp_mplsvpn.h
index a5f3eb3..5d8d6fb 100644
--- a/bgpd/bgp_mplsvpn.h
+++ b/bgpd/bgp_mplsvpn.h
@@ -40,6 +40,6 @@
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);
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index b4cd130..dc5d369 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -548,7 +548,7 @@
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_with_data (peer, code, sub_code, NULL, 0);
}
-char *
+const char *
afi2str (afi_t afi)
{
if (afi == AFI_IP)
@@ -884,7 +884,7 @@
return "Unknown AFI";
}
-char *
+const char *
safi2str (safi_t safi)
{
if (safi == SAFI_UNICAST)
diff --git a/bgpd/bgp_packet.h b/bgpd/bgp_packet.h
index 7bbcdb2..d9afd5c 100644
--- a/bgpd/bgp_packet.h
+++ b/bgpd/bgp_packet.h
@@ -18,10 +18,10 @@
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
diff --git a/bgpd/bgp_regex.c b/bgpd/bgp_regex.c
index a6b6598..be84d40 100644
--- a/bgpd/bgp_regex.c
+++ b/bgpd/bgp_regex.c
@@ -34,7 +34,7 @@
(^|[,{}() ]|$) */
regex_t *
-bgp_regcomp (char *regstr)
+bgp_regcomp (const char *regstr)
{
/* Convert _ character to generic regular expression. */
int i, j;
diff --git a/bgpd/bgp_regex.h b/bgpd/bgp_regex.h
index 0829dd9..1320711 100644
--- a/bgpd/bgp_regex.h
+++ b/bgpd/bgp_regex.h
@@ -27,5 +27,5 @@
#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);
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 6b49e2c..dbd29cb 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -1399,7 +1399,7 @@
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 @@
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 @@
/* 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 @@
/* 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 @@
}
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 @@
/* 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 @@
#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 @@
}
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 @@
/* 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 @@
/* 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 @@
}
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 @@
#endif /* HAVE_IPV6 */
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 @@
#endif /* HAVE_IPV6 */
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 @@
#endif /* HAVE_IPV6 */
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 @@
#endif /* HAVE_IPV6 */
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 @@
#endif /* HAVE_IPV6 */
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 @@
}
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 @@
#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 @@
}
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 @@
}
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 @@
/* 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;
diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h
index 9aad723..d44c502 100644
--- a/bgpd/bgp_route.h
+++ b/bgpd/bgp_route.h
@@ -149,9 +149,11 @@
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 *);
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index c49c2e9..e2ad5e0 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -160,7 +160,7 @@
}
void *
-route_match_peer_compile (char *arg)
+route_match_peer_compile (const char *arg)
{
union sockunion *su;
int ret;
@@ -218,7 +218,7 @@
/* 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 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 @@
}
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 @@
}
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 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
}
void *
-route_match_origin_compile (char *arg)
+route_match_origin_compile (const char *arg)
{
u_char *origin;
@@ -772,7 +777,7 @@
/* 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 @@
/* 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 @@
/* 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 @@
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 @@
/* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
}
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 @@
}
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 @@
}
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 @@
}
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 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 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 @@
}
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 @@
/* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
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 @@
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)
diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c
index 6e9beab..e5bcd03 100644
--- a/bgpd/bgp_snmp.c
+++ b/bgpd/bgp_snmp.c
@@ -627,7 +627,7 @@
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 \
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 6b3c498..027b8ca 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -84,7 +84,7 @@
/* 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 @@
/* 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 @@
int
bgp_vty_return (struct vty *vty, int ret)
{
- char *str = NULL;
+ const char *str = NULL;
switch (ret)
{
@@ -297,7 +297,7 @@
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 @@
{
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 @@
"Configure default local preference value\n")
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 @@
}
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 @@
}
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 @@
}
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 @@
}
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 @@
}
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 @@
}
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 @@
/* 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 @@
}
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 @@
/* 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 @@
}
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 @@
/* 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 @@
/* 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 @@
}
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 @@
}
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 @@
}
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 @@
}
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 @@
}
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 @@
"Connect timer\n")
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 @@
"time in seconds\n")
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 @@
/* 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 @@
/* 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 @@
}
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 @@
/* 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 @@
}
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 @@
}
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 @@
}
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 @@
/* 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 @@
}
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 @@
/* 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 @@
/* 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 @@
}
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 @@
}
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 @@
{
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 @@
/* `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 @@
}
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 @@
}
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 @@
}
#endif /* HAVE_IPV6 */
-char *
+const char *
afi_safi_print (afi_t afi, safi_t safi)
{
if (afi == AFI_IP && safi == SAFI_UNICAST)
@@ -7187,8 +7203,8 @@
}
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 @@
{
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 @@
}
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 @@
}
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 @@
/* 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 @@
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 @@
/* VTY functions. */
/* Direction value to string conversion. */
-char *
+const char *
community_direct_str (int direct)
{
switch (direct)
@@ -9365,8 +9383,8 @@
/* 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 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 @@
/* 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 @@
}
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 @@
}
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 @@
}
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 @@
}
/* 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 = "";
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 6226a93..752617d 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -842,7 +842,8 @@
/* 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))
diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h
index 1620c84..d8407e8 100644
--- a/bgpd/bgp_zebra.h
+++ b/bgpd/bgp_zebra.h
@@ -25,7 +25,7 @@
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);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 61ffe27..663f01b 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -1197,7 +1197,7 @@
}
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 @@
}
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 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 @@
/* 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 = 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
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 @@
/* 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 @@
/* 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 @@
/* 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 @@
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 @@
/* 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 @@
/* 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 @@
return 0;
}
-/* 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 @@
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'. */
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index ed3f4d1..4137baf 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -766,11 +766,11 @@
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_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 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_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_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_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);