summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
authorpaul <paul>2004-10-13 05:06:08 +0000
committerpaul <paul>2004-10-13 05:06:08 +0000
commitfd79ac918b8feaacebe9719adaac97dffb69137a (patch)
treed0665eb68e60da9d6e364414cdb61830f19f33d3 /bgpd
parent39db97e4e02eae08a1e18528367b6e9b07eb6a93 (diff)
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.
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/ChangeLog11
-rw-r--r--bgpd/bgp_aspath.c8
-rw-r--r--bgpd/bgp_aspath.h8
-rw-r--r--bgpd/bgp_clist.c28
-rw-r--r--bgpd/bgp_clist.h20
-rw-r--r--bgpd/bgp_community.c13
-rw-r--r--bgpd/bgp_community.h6
-rw-r--r--bgpd/bgp_damp.c18
-rw-r--r--bgpd/bgp_damp.h35
-rw-r--r--bgpd/bgp_debug.c11
-rw-r--r--bgpd/bgp_debug.h4
-rw-r--r--bgpd/bgp_dump.c4
-rw-r--r--bgpd/bgp_ecommunity.c16
-rw-r--r--bgpd/bgp_ecommunity.h6
-rw-r--r--bgpd/bgp_filter.c14
-rw-r--r--bgpd/bgp_filter.h2
-rw-r--r--bgpd/bgp_fsm.c4
-rw-r--r--bgpd/bgp_fsm.h2
-rw-r--r--bgpd/bgp_main.c2
-rw-r--r--bgpd/bgp_mplsvpn.c21
-rw-r--r--bgpd/bgp_mplsvpn.h4
-rw-r--r--bgpd/bgp_packet.c6
-rw-r--r--bgpd/bgp_packet.h8
-rw-r--r--bgpd/bgp_regex.c2
-rw-r--r--bgpd/bgp_regex.h2
-rw-r--r--bgpd/bgp_route.c65
-rw-r--r--bgpd/bgp_route.h6
-rw-r--r--bgpd/bgp_routemap.c134
-rw-r--r--bgpd/bgp_snmp.c2
-rw-r--r--bgpd/bgp_vty.c180
-rw-r--r--bgpd/bgp_zebra.c3
-rw-r--r--bgpd/bgp_zebra.h2
-rw-r--r--bgpd/bgpd.c40
-rw-r--r--bgpd/bgpd.h28
34 files changed, 390 insertions, 325 deletions
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index d5ab3282..93feb051 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 bcb8f16f..5d497751 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -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;
diff --git a/bgpd/bgp_aspath.h b/bgpd/bgp_aspath.h
index 0295fafb..3f7858be 100644
--- a/bgpd/bgp_aspath.h
+++ b/bgpd/bgp_aspath.h
@@ -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 *);
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c
index a2c12100..572d11c9 100644
--- a/bgpd/bgp_clist.c
+++ b/bgpd/bgp_clist.c
@@ -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;
diff --git a/bgpd/bgp_clist.h b/bgpd/bgp_clist.h
index ffc707c2..11db2d71 100644
--- a/bgpd/bgp_clist.h
+++ b/bgpd/bgp_clist.h
@@ -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 *,
diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c
index 54679710..1a6514bc 100644
--- a/bgpd/bgp_community.c
+++ b/bgpd/bgp_community.c
@@ -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;
diff --git a/bgpd/bgp_community.h b/bgpd/bgp_community.h
index 898ca9e8..016b0f6f 100644
--- a/bgpd/bgp_community.h
+++ b/bgpd/bgp_community.h
@@ -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 *);
diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c
index d70105f5..9b7b5dae 100644
--- a/bgpd/bgp_damp.c
+++ b/bgpd/bgp_damp.c
@@ -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;
diff --git a/bgpd/bgp_damp.h b/bgpd/bgp_damp.h
index f3b9bd6d..09b953ea 100644
--- a/bgpd/bgp_damp.h
+++ b/bgpd/bgp_damp.h
@@ -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 *);
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index 9c5208da..3196effc 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -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 = "";
diff --git a/bgpd/bgp_debug.h b/bgpd/bgp_debug.h
index 14a8c5fe..d060961e 100644
--- a/bgpd/bgp_debug.h
+++ b/bgpd/bgp_debug.h
@@ -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;
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index 9690fb56..f8637c65 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -462,7 +462,7 @@ bgp_dump_packet (struct peer *peer, int type, struct stream *packet)
}
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;
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c
index b3fc1c3a..32bf68f1 100644
--- a/bgpd/bgp_ecommunity.c
+++ b/bgpd/bgp_ecommunity.c
@@ -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;
diff --git a/bgpd/bgp_ecommunity.h b/bgpd/bgp_ecommunity.h
index e7be7865..56e9f18e 100644
--- a/bgpd/bgp_ecommunity.h
+++ b/bgpd/bgp_ecommunity.h
@@ -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 *);
diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c
index 7a8fb039..09dcc0fa 100644
--- a/bgpd/bgp_filter.c
+++ b/bgpd/bgp_filter.c
@@ -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)
diff --git a/bgpd/bgp_filter.h b/bgpd/bgp_filter.h
index 8d55a224..ec48ca17 100644
--- a/bgpd/bgp_filter.h
+++ b/bgpd/bgp_filter.h
@@ -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) ());
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index 2874a9a0..dd65facf 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -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",
diff --git a/bgpd/bgp_fsm.h b/bgpd/bgp_fsm.h
index ce816e23..20fc2d70 100644
--- a/bgpd/bgp_fsm.h
+++ b/bgpd/bgp_fsm.h
@@ -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[];
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index a4cd9ab4..05ecb720 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -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;
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 90219cfe..23b8d84b 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -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;
}
diff --git a/bgpd/bgp_mplsvpn.h b/bgpd/bgp_mplsvpn.h
index a5f3eb37..5d8d6fb0 100644
--- a/bgpd/bgp_mplsvpn.h
+++ b/bgpd/bgp_mplsvpn.h
@@ -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);
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index b4cd1301..dc5d3691 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -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)
diff --git a/bgpd/bgp_packet.h b/bgpd/bgp_packet.h
index 7bbcdb23..d9afd5c1 100644
--- a/bgpd/bgp_packet.h
+++ b/bgpd/bgp_packet.h
@@ -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
diff --git a/bgpd/bgp_regex.c b/bgpd/bgp_regex.c
index a6b65984..be84d407 100644
--- a/bgpd/bgp_regex.c
+++ b/bgpd/bgp_regex.c
@@ -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;
diff --git a/bgpd/bgp_regex.h b/bgpd/bgp_regex.h
index 0829dd9a..1320711f 100644
--- a/bgpd/bgp_regex.h
+++ b/bgpd/bgp_regex.h
@@ -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);
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 6b49e2c8..dbd29cbf 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -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 */
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 */
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 */
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 */
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 */
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,
/* 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 9aad7238..d44c5021 100644
--- a/bgpd/bgp_route.h
+++ b/bgpd/bgp_route.h
@@ -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 *);
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index c49c2e99..e2ad5e0f 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -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)
diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c
index 6e9beab4..e5bcd03b 100644
--- a/bgpd/bgp_snmp.c
+++ b/bgpd/bgp_snmp.c
@@ -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 \
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 6b3c4988..027b8ca9 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -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")
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,
}
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,
}
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,
}
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,
/* 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,
/* 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,
}
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,
/* 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,
/* 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,
}
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,
}
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,
}
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")
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")
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,
/* 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,
/* 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,
/* 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,
}
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,
/* 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,
/* 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,
}
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 */
-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,
}
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,
}
/* 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 6226a938..752617d4 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -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))
diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h
index 1620c847..d8407e8b 100644
--- a/bgpd/bgp_zebra.h
+++ b/bgpd/bgp_zebra.h
@@ -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);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 61ffe279..663f01be 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -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,
/* 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)
/* 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)
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)
/* 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)
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)
/* 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;
}
-/* 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'. */
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index ed3f4d18..4137baf2 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -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);