From 5e205a8b185bb88d46ef0040385b3f756d3d6369 Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Mon, 20 Jul 2015 14:23:35 -0400 Subject: [PATCH] Move radclient to use fr_pton_port for its host and port parsing fr_pton_port seems to work, whereas what was there before didn't... --- src/main/radclient.c | 55 +++++++++----------------------------------- 1 file changed, 11 insertions(+), 44 deletions(-) diff --git a/src/main/radclient.c b/src/main/radclient.c index ef73bbd2a24e..370686072ac1 100644 --- a/src/main/radclient.c +++ b/src/main/radclient.c @@ -1151,16 +1151,16 @@ static int recv_one_packet(int wait_time) int main(int argc, char **argv) { - int c; - char const *radius_dir = RADDBDIR; - char const *dict_dir = DICTDIR; - char filesecret[256]; - FILE *fp; - int do_summary = false; - int persec = 0; - int parallel = 1; + int c; + char const *radius_dir = RADDBDIR; + char const *dict_dir = DICTDIR; + char filesecret[256]; + FILE *fp; + int do_summary = false; + int persec = 0; + int parallel = 1; rc_request_t *this; - int force_af = AF_UNSPEC; + int force_af = AF_UNSPEC; /* * It's easier having two sets of flags to set the @@ -1386,45 +1386,12 @@ int main(int argc, char **argv) /* * Resolve hostname. */ - if (force_af == AF_UNSPEC) force_af = AF_INET; - server_ipaddr.af = force_af; if (strcmp(argv[1], "-") != 0) { - char *p; - char const *hostname = argv[1]; - char const *portname = argv[1]; - char buffer[256]; - - if (*argv[1] == '[') { /* IPv6 URL encoded */ - p = strchr(argv[1], ']'); - if ((size_t) (p - argv[1]) >= sizeof(buffer)) { - usage(); - } - - memcpy(buffer, argv[1] + 1, p - argv[1] - 1); - buffer[p - argv[1] - 1] = '\0'; - - hostname = buffer; - portname = p + 1; - - } - p = strchr(portname, ':'); - if (p && (strchr(p + 1, ':') == NULL)) { - *p = '\0'; - portname = p + 1; - } else { - portname = NULL; - } - - if (ip_hton(&server_ipaddr, force_af, hostname, false) < 0) { - ERROR("Failed to find IP address for host %s: %s", hostname, strerror(errno)); + if (fr_pton_port(&server_ipaddr, &server_port, argv[1], -1, force_af, true) < 0) { + ERROR("%s", fr_strerror()); exit(1); } - /* - * Strip port from hostname if needed. - */ - if (portname) server_port = atoi(portname); - /* * Work backwards from the port to determine the packet type */