summaryrefslogtreecommitdiff
path: root/bgpd/bgp_mplsvpn.c
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/bgp_mplsvpn.c
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/bgp_mplsvpn.c')
-rw-r--r--bgpd/bgp_mplsvpn.c21
1 files changed, 14 insertions, 7 deletions
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;
}