#include "cmdline_parse.h"
#include "cmdline_parse_ipaddr.h"
-struct cmdline_token_ops cmdline_token_ipaddr_ops = {
- .parse = cmdline_parse_ipaddr,
- .complete_get_nb = NULL,
- .complete_get_elt = NULL,
- .get_help = cmdline_get_help_ipaddr,
-};
-
#define INADDRSZ 4
#define IN6ADDRSZ 16
return (1);
}
-int
-cmdline_parse_ipaddr(cmdline_parse_token_hdr_t *tk, const char *buf, void *res)
+static int
+cmdline_parse_ipaddr(cmdline_parse_token_hdr_t *tk, const char *buf, void *res,
+ unsigned ressize)
{
struct cmdline_token_ipaddr *tk2 = (struct cmdline_token_ipaddr *)tk;
unsigned int token_len = 0;
char *prefix, *prefix_end;
long prefixlen;
+ if (res && ressize < sizeof(cmdline_ipaddr_t))
+ return -1;
+
/* if token is too big... */
token_len = snprintf(ip_str, sizeof(ip_str), "%s", buf);
if (token_len >= sizeof(ip_str))
}
-int cmdline_get_help_ipaddr(cmdline_parse_token_hdr_t *tk, char *dstbuf,
- unsigned int size)
+static int
+cmdline_help_ipaddr(cmdline_parse_token_hdr_t *tk, char *dstbuf,
+ unsigned int size)
{
struct cmdline_token_ipaddr *tk2 = (struct cmdline_token_ipaddr *)tk;
}
return 0;
}
+
+struct cmdline_token_ops cmdline_token_ipaddr_ops = {
+ .parse = cmdline_parse_ipaddr,
+ .complete_start = NULL,
+ .complete_iterate = NULL,
+ .complete_end = NULL,
+ .help = cmdline_help_ipaddr,
+};
+