mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 10:37:29 +00:00
2004-10-13 Paul Jakma <paul@dishone.st>
* (global) more const'ification. * sockunion.c: (sockunion_su2str) buffer should be sized SU_ADDRSTRLEN. (sockunion_log) do not return stack variables, strdup buf before return. * vty.h: Fix up the VTY_GET_INTEGER macros. Testing caller supplied values against ULONG_MAX is daft, when caller probably has passed a type that can not hold ULONG_MAX. use a temporary long instead. Add VTY_GET_LONG, make VTY_GET_INTEGER_RANGE use it, make VTY_GET_INTEGER a define for VTY_GET_INTEGER_RANGE.
This commit is contained in:
parent
fd79ac918b
commit
42d498658d
@ -1,3 +1,16 @@
|
|||||||
|
2004-10-13 Paul Jakma <paul@dishone.st>
|
||||||
|
|
||||||
|
* (global) more const'ification.
|
||||||
|
* sockunion.c: (sockunion_su2str) buffer should be sized
|
||||||
|
SU_ADDRSTRLEN.
|
||||||
|
(sockunion_log) do not return stack variables, strdup buf before
|
||||||
|
return.
|
||||||
|
* vty.h: Fix up the VTY_GET_INTEGER macros. Testing caller supplied
|
||||||
|
values against ULONG_MAX is daft, when caller probably has passed
|
||||||
|
a type that can not hold ULONG_MAX. use a temporary long instead.
|
||||||
|
Add VTY_GET_LONG, make VTY_GET_INTEGER_RANGE use it, make
|
||||||
|
VTY_GET_INTEGER a define for VTY_GET_INTEGER_RANGE.
|
||||||
|
|
||||||
2004-10-11 Hasso Tepper <hasso at quagga.net>
|
2004-10-11 Hasso Tepper <hasso at quagga.net>
|
||||||
|
|
||||||
* command.h: Sync DEFUNSH with other macros.
|
* command.h: Sync DEFUNSH with other macros.
|
||||||
|
@ -78,7 +78,7 @@ struct cmd_node config_node =
|
|||||||
/* Utility function to concatenate argv argument into a single string
|
/* Utility function to concatenate argv argument into a single string
|
||||||
with inserting ' ' character between each argument. */
|
with inserting ' ' character between each argument. */
|
||||||
char *
|
char *
|
||||||
argv_concat (char **argv, int argc, int shift)
|
argv_concat (const char **argv, int argc, int shift)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int len;
|
int len;
|
||||||
|
@ -286,7 +286,7 @@ void install_default (enum node_type);
|
|||||||
void install_element (enum node_type, struct cmd_element *);
|
void install_element (enum node_type, struct cmd_element *);
|
||||||
void sort_node ();
|
void sort_node ();
|
||||||
|
|
||||||
char *argv_concat (char **, int, int);
|
char *argv_concat (const char **, int, int);
|
||||||
vector cmd_make_strvec (const char *);
|
vector cmd_make_strvec (const char *);
|
||||||
void cmd_free_strvec (vector);
|
void cmd_free_strvec (vector);
|
||||||
vector cmd_describe_command ();
|
vector cmd_describe_command ();
|
||||||
|
@ -175,7 +175,7 @@ sockunion2str (union sockunion *su, char *buf, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
union sockunion *
|
union sockunion *
|
||||||
sockunion_str2su (char *str)
|
sockunion_str2su (const char *str)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
union sockunion *su;
|
union sockunion *su;
|
||||||
@ -211,7 +211,7 @@ sockunion_str2su (char *str)
|
|||||||
char *
|
char *
|
||||||
sockunion_su2str (union sockunion *su)
|
sockunion_su2str (union sockunion *su)
|
||||||
{
|
{
|
||||||
char str[INET6_ADDRSTRLEN];
|
char str[SU_ADDRSTRLEN];
|
||||||
|
|
||||||
switch (su->sa.sa_family)
|
switch (su->sa.sa_family)
|
||||||
{
|
{
|
||||||
@ -314,7 +314,7 @@ sockunion_log (union sockunion *su)
|
|||||||
snprintf (buf, SU_ADDRSTRLEN, "af_unknown %d ", su->sa.sa_family);
|
snprintf (buf, SU_ADDRSTRLEN, "af_unknown %d ", su->sa.sa_family);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return buf;
|
return (strdup (buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sockunion_connect returns
|
/* sockunion_connect returns
|
||||||
@ -676,7 +676,7 @@ sockunion_print (union sockunion *su)
|
|||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
{
|
{
|
||||||
char buf [64];
|
char buf [SU_ADDRSTRLEN];
|
||||||
|
|
||||||
printf ("%s\n", inet_ntop (AF_INET6, &(su->sin6.sin6_addr),
|
printf ("%s\n", inet_ntop (AF_INET6, &(su->sin6.sin6_addr),
|
||||||
buf, sizeof (buf)));
|
buf, sizeof (buf)));
|
||||||
|
@ -93,7 +93,7 @@ int sockunion_cmp (union sockunion *, union sockunion *);
|
|||||||
int sockunion_same (union sockunion *, union sockunion *);
|
int sockunion_same (union sockunion *, union sockunion *);
|
||||||
|
|
||||||
char *sockunion_su2str (union sockunion *su);
|
char *sockunion_su2str (union sockunion *su);
|
||||||
union sockunion *sockunion_str2su (char *str);
|
union sockunion *sockunion_str2su (const char *str);
|
||||||
struct in_addr sockunion_get_in_addr (union sockunion *su);
|
struct in_addr sockunion_get_in_addr (union sockunion *su);
|
||||||
int sockunion_accept (int sock, union sockunion *);
|
int sockunion_accept (int sock, union sockunion *);
|
||||||
int sockunion_stream_socket (union sockunion *);
|
int sockunion_stream_socket (union sockunion *);
|
||||||
|
39
lib/vty.h
39
lib/vty.h
@ -158,30 +158,33 @@ struct vty
|
|||||||
#define PRINTF_ATTRIBUTE(a,b)
|
#define PRINTF_ATTRIBUTE(a,b)
|
||||||
#endif /* __GNUC__ */
|
#endif /* __GNUC__ */
|
||||||
|
|
||||||
/* Utility macro to convert VTY argument to unsigned integer. */
|
/* Utility macros to convert VTY argument to unsigned long or integer. */
|
||||||
#define VTY_GET_INTEGER(NAME,V,STR) \
|
#define VTY_GET_LONG(NAME,V,STR) \
|
||||||
{ \
|
{ \
|
||||||
char *endptr = NULL; \
|
char *endptr = NULL; \
|
||||||
(V) = strtoul ((STR), &endptr, 10); \
|
(V) = strtoul ((STR), &endptr, 10); \
|
||||||
if ((V) == ULONG_MAX || *endptr != '\0') \
|
if (*endptr != '\0' || (V) == ULONG_MAX) \
|
||||||
{ \
|
{ \
|
||||||
vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE); \
|
vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE); \
|
||||||
return CMD_WARNING; \
|
return CMD_WARNING; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define VTY_GET_INTEGER_RANGE(NAME,V,STR,MIN,MAX) \
|
#define VTY_GET_INTEGER_RANGE(NAME,V,STR,MIN,MAX) \
|
||||||
{ \
|
{ \
|
||||||
char *endptr = NULL; \
|
unsigned long tmpl; \
|
||||||
(V) = strtoul ((STR), &endptr, 10); \
|
VTY_GET_LONG(NAME, tmpl, STR) \
|
||||||
if ((V) == ULONG_MAX || *endptr != '\0' \
|
if ( tmpl < (MIN) || tmpl > (MAX)) \
|
||||||
|| (V) < (MIN) || (V) > (MAX)) \
|
{ \
|
||||||
{ \
|
|
||||||
vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE); \
|
vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE); \
|
||||||
return CMD_WARNING; \
|
return CMD_WARNING; \
|
||||||
} \
|
} \
|
||||||
|
(V) = tmpl; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define VTY_GET_INTEGER(NAME,V,STR) \
|
||||||
|
VTY_GET_INTEGER_RANGE(NAME,V,STR,0U,UINT32_MAX)
|
||||||
|
|
||||||
/* Exported variables */
|
/* Exported variables */
|
||||||
extern char integrate_default[];
|
extern char integrate_default[];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user