diff options
Diffstat (limited to 'networking')
31 files changed, 444 insertions, 434 deletions
diff --git a/networking/arping.c b/networking/arping.c index bf0a77c..2e1adf0 100644 --- a/networking/arping.c +++ b/networking/arping.c @@ -302,9 +302,9 @@ int arping_main(int argc, char **argv) break; case 'I': if (optarg == NULL) - show_usage(); - if (xstrlen(optarg) > IF_NAMESIZE) { - error_msg("Interface name `%s' must be less than %d", optarg, + bb_show_usage(); + if (bb_strlen(optarg) > IF_NAMESIZE) { + bb_error_msg("Interface name `%s' must be less than %d", optarg, IF_NAMESIZE); exit(2); } @@ -319,20 +319,20 @@ int arping_main(int argc, char **argv) case 'h': case '?': default: - show_usage(); + bb_show_usage(); } } argc -= optind; argv += optind; if (argc != 1) - show_usage(); + bb_show_usage(); target = *argv; if (s < 0) { - error_msg("socket"); + bb_error_msg("socket"); exit(socket_errno); } @@ -342,21 +342,21 @@ int arping_main(int argc, char **argv) memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, device, IFNAMSIZ - 1); if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) { - error_msg("Interface %s not found", device); + bb_error_msg("Interface %s not found", device); exit(2); } ifindex = ifr.ifr_ifindex; if (ioctl(s, SIOCGIFFLAGS, (char *) &ifr)) { - error_msg("SIOCGIFFLAGS"); + bb_error_msg("SIOCGIFFLAGS"); exit(2); } if (!(ifr.ifr_flags & IFF_UP)) { - error_msg("Interface %s is down", device); + bb_error_msg("Interface %s is down", device); exit(2); } if (ifr.ifr_flags & (IFF_NOARP | IFF_LOOPBACK)) { - error_msg("Interface %s is not ARPable", device); + bb_error_msg("Interface %s is not ARPable", device); exit(dad ? 0 : 2); } } @@ -366,14 +366,14 @@ int arping_main(int argc, char **argv) hp = gethostbyname2(target, AF_INET); if (!hp) { - error_msg("invalid or unknown target %s", target); + bb_error_msg("invalid or unknown target %s", target); exit(2); } memcpy(&dst, hp->h_addr, 4); } if (source && !inet_aton(source, &src)) { - error_msg("invalid source address %s", source); + bb_error_msg("invalid source address %s", source); exit(2); } @@ -385,21 +385,21 @@ int arping_main(int argc, char **argv) int probe_fd = socket(AF_INET, SOCK_DGRAM, 0); if (probe_fd < 0) { - error_msg("socket"); + bb_error_msg("socket"); exit(2); } if (device) { if (setsockopt (probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device, strlen(device) + 1) == -1) - error_msg("WARNING: interface %s is ignored", device); + bb_error_msg("WARNING: interface %s is ignored", device); } memset(&saddr, 0, sizeof(saddr)); saddr.sin_family = AF_INET; if (src.s_addr) { saddr.sin_addr = src; if (bind(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)) == -1) { - error_msg("bind"); + bb_error_msg("bind"); exit(2); } } else if (!dad) { @@ -415,12 +415,12 @@ int arping_main(int argc, char **argv) perror("WARNING: setsockopt(SO_DONTROUTE)"); if (connect(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)) == -1) { - error_msg("connect"); + bb_error_msg("connect"); exit(2); } if (getsockname(probe_fd, (struct sockaddr *) &saddr, &alen) == -1) { - error_msg("getsockname"); + bb_error_msg("getsockname"); exit(2); } src = saddr.sin_addr; @@ -432,7 +432,7 @@ int arping_main(int argc, char **argv) me.sll_ifindex = ifindex; me.sll_protocol = htons(ETH_P_ARP); if (bind(s, (struct sockaddr *) &me, sizeof(me)) == -1) { - error_msg("bind"); + bb_error_msg("bind"); exit(2); } @@ -440,12 +440,12 @@ int arping_main(int argc, char **argv) int alen = sizeof(me); if (getsockname(s, (struct sockaddr *) &me, &alen) == -1) { - error_msg("getsockname"); + bb_error_msg("getsockname"); exit(2); } } if (me.sll_halen == 0) { - error_msg("Interface \"%s\" is not ARPable (no ll address)", device); + bb_error_msg("Interface \"%s\" is not ARPable (no ll address)", device); exit(dad ? 0 : 2); } he = me; @@ -458,7 +458,7 @@ int arping_main(int argc, char **argv) } if (!src.s_addr && !dad) { - error_msg("no src address in the non-DAD mode"); + bb_error_msg("no src address in the non-DAD mode"); exit(2); } diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index 44e91c3..3943890 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c @@ -77,7 +77,7 @@ static ftp_host_info_t *ftp_init(void) static int ftpcmd(const char *s1, const char *s2, FILE *stream, char *buf) { if (verbose_flag) { - error_msg("cmd %s%s", s1, s2); + bb_error_msg("cmd %s%s", s1, s2); } if (s1) { @@ -90,7 +90,7 @@ static int ftpcmd(const char *s1, const char *s2, FILE *stream, char *buf) do { if (fgets(buf, 510, stream) == NULL) { - perror_msg_and_die("fgets()"); + bb_perror_msg_and_die("fgets()"); } } while (! isdigit(buf[0]) || buf[3] != ' '); @@ -125,11 +125,11 @@ static FILE *ftp_login(ftp_host_info_t *server) control_fd = xconnect(server->host, server->port); control_stream = fdopen(control_fd, "r+"); if (control_stream == NULL) { - perror_msg_and_die("Couldnt open control stream"); + bb_perror_msg_and_die("Couldnt open control stream"); } if (ftpcmd(NULL, NULL, control_stream, buf) != 220) { - error_msg_and_die("%s", buf + 4); + bb_error_msg_and_die("%s", buf + 4); } /* Login to the server */ @@ -138,11 +138,11 @@ static FILE *ftp_login(ftp_host_info_t *server) break; case 331: if (ftpcmd("PASS ", server->password, control_stream, buf) != 230) { - error_msg_and_die("PASS error: %s", buf + 4); + bb_error_msg_and_die("PASS error: %s", buf + 4); } break; default: - error_msg_and_die("USER error: %s", buf + 4); + bb_error_msg_and_die("USER error: %s", buf + 4); } ftpcmd("TYPE I", NULL, control_stream, buf); @@ -161,12 +161,12 @@ static int ftp_recieve(FILE *control_stream, const char *host, const char *local int fd_local; off_t beg_range = 0; - filename = get_last_path_component(server_path); + filename = bb_get_last_path_component(server_path); local_file = concat_path_file(local_path, filename); /* Connect to the data socket */ if (ftpcmd("PASV", NULL, control_stream, buf) != 227) { - error_msg_and_die("PASV error: %s", buf + 4); + bb_error_msg_and_die("PASV error: %s", buf + 4); } fd_data = xconnect_ftpdata(host, buf); @@ -177,7 +177,7 @@ static int ftp_recieve(FILE *control_stream, const char *host, const char *local if (do_continue) { struct stat sbuf; if (lstat(local_file, &sbuf) < 0) { - perror_msg_and_die("fstat()"); + bb_perror_msg_and_die("fstat()"); } if (sbuf.st_size > 0) { beg_range = sbuf.st_size; @@ -196,25 +196,25 @@ static int ftp_recieve(FILE *control_stream, const char *host, const char *local } if (ftpcmd("RETR ", server_path, control_stream, buf) > 150) { - error_msg_and_die("RETR error: %s", buf + 4); + bb_error_msg_and_die("RETR error: %s", buf + 4); } /* only make a local file if we know that one exists on the remote server */ if (do_continue) { - fd_local = xopen(local_file, O_APPEND | O_WRONLY); + fd_local = bb_xopen(local_file, O_APPEND | O_WRONLY); } else { - fd_local = xopen(local_file, O_CREAT | O_TRUNC | O_WRONLY); + fd_local = bb_xopen(local_file, O_CREAT | O_TRUNC | O_WRONLY); } /* Copy the file */ - if (copyfd(fd_data, fd_local, filesize) == -1) { + if (bb_copyfd(fd_data, fd_local, filesize) == -1) { exit(EXIT_FAILURE); } /* close it all down */ close(fd_data); if (ftpcmd(NULL, NULL, control_stream, buf) != 226) { - error_msg_and_die("ftp error: %s", buf + 4); + bb_error_msg_and_die("ftp error: %s", buf + 4); } ftpcmd("QUIT", NULL, control_stream, buf); @@ -233,16 +233,16 @@ static int ftp_send(FILE *control_stream, const char *host, const char *server_p /* Connect to the data socket */ if (ftpcmd("PASV", NULL, control_stream, buf) != 227) { - error_msg_and_die("PASV error: %s", buf + 4); + bb_error_msg_and_die("PASV error: %s", buf + 4); } fd_data = xconnect_ftpdata(host, buf); if (ftpcmd("CWD ", server_path, control_stream, buf) != 250) { - error_msg_and_die("CWD error: %s", buf + 4); + bb_error_msg_and_die("CWD error: %s", buf + 4); } /* get the local file */ - fd_local = xopen(local_path, O_RDONLY); + fd_local = bb_xopen(local_path, O_RDONLY); fstat(fd_local, &sbuf); sprintf(buf, "ALLO %lu", sbuf.st_size); @@ -253,7 +253,7 @@ static int ftp_send(FILE *control_stream, const char *host, const char *server_p break; default: close(fd_local); - error_msg_and_die("ALLO error: %s", buf + 4); + bb_error_msg_and_die("ALLO error: %s", buf + 4); break; } @@ -264,18 +264,18 @@ static int ftp_send(FILE *control_stream, const char *host, const char *server_p break; default: close(fd_local); - error_msg_and_die("STOR error: %s", buf + 4); + bb_error_msg_and_die("STOR error: %s", buf + 4); } /* transfer the file */ - if (copyfd(fd_local, fd_data, 0) == -1) { + if (bb_copyfd(fd_local, fd_data, 0) == -1) { exit(EXIT_FAILURE); } /* close it all down */ close(fd_data); if (ftpcmd(NULL, NULL, control_stream, buf) != 226) { - error_msg_and_die("error: %s", buf + 4); + bb_error_msg_and_die("error: %s", buf + 4); } ftpcmd("QUIT", NULL, control_stream, buf); @@ -307,12 +307,12 @@ int ftpgetput_main(int argc, char **argv) }; #ifdef CONFIG_FTPPUT - if (applet_name[3] == 'p') { + if (bb_applet_name[3] == 'p') { ftp_action = ftp_send; } #endif #ifdef CONFIG_FTPGET - if (applet_name[3] == 'g') { + if (bb_applet_name[3] == 'g') { ftp_action = ftp_recieve; } #endif @@ -342,7 +342,7 @@ int ftpgetput_main(int argc, char **argv) verbose_flag = 1; break; default: - show_usage(); + bb_show_usage(); } } @@ -350,7 +350,7 @@ int ftpgetput_main(int argc, char **argv) * Process the non-option command line arguments */ if (argc - optind != 3) { - show_usage(); + bb_show_usage(); } /* Connect/Setup/Configure the FTP session */ diff --git a/networking/hostname.c b/networking/hostname.c index f7c9fc4..6522bb2 100644 --- a/networking/hostname.c +++ b/networking/hostname.c @@ -1,6 +1,6 @@ /* vi: set sw=4 ts=4: */ /* - * $Id: hostname.c,v 1.34 2002/11/10 22:07:48 bug1 Exp $ + * $Id: hostname.c,v 1.35 2003/03/19 09:12:37 mjn3 Exp $ * Mini hostname implementation for busybox * * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> @@ -46,12 +46,12 @@ static void do_sethostname(char *s, int isfile) if (!isfile) { if (sethostname(s, strlen(s)) < 0) { if (errno == EPERM) - error_msg_and_die("you must be root to change the hostname"); + bb_error_msg_and_die("you must be root to change the hostname"); else - perror_msg_and_die("sethostname"); + bb_perror_msg_and_die("sethostname"); } } else { - f = xfopen(s, "r"); + f = bb_xfopen(s, "r"); while (fgets(buf, 255, f) != NULL) { if (buf[0] =='#') { continue; @@ -75,7 +75,7 @@ int hostname_main(int argc, char **argv) char *p = NULL; if (argc < 1) - show_usage(); + bb_show_usage(); while ((opt = getopt(argc, argv, "dfisF:")) > 0) { switch (opt) { @@ -89,7 +89,7 @@ int hostname_main(int argc, char **argv) filename = optarg; break; default: - show_usage(); + bb_show_usage(); } } diff --git a/networking/httpd.c b/networking/httpd.c index fb37224..e62168d 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -178,12 +178,12 @@ static const char home[] = "/www"; #define CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP /* require from libbb.a for linking */ -const char *applet_name = "httpd"; +const char *bb_applet_name = "httpd"; -void show_usage(void) +void bb_show_usage(void) { fprintf(stderr, "Usage: %s [-p <port>] [-c configFile] [-d/-e <string>] " - "[-r realm] [-u user]\n", applet_name); + "[-r realm] [-u user]\n", bb_applet_name); exit(1); } #endif @@ -395,7 +395,7 @@ static int conf_sort(const void *p1, const void *p2) } #ifdef DEBUG if(!test) - error_msg_and_die("sort: can`t found compares!"); + bb_error_msg_and_die("sort: can`t found compares!"); #endif return test; } @@ -423,7 +423,7 @@ static void parse_conf(const char *path, int flag) cf = p0 = alloca(strlen(path) + sizeof(httpd_conf) + 2); if(p0 == NULL) { if(flag == FIRST_PARSE) - error_msg_and_die(memory_exhausted); + bb_error_msg_and_die(bb_msg_memory_exhausted); return; } sprintf(p0, "%s/%s", path, httpd_conf); @@ -433,7 +433,7 @@ static void parse_conf(const char *path, int flag) if(flag != FIRST_PARSE) return; /* subdir config not found */ if(p0 == NULL) /* if -c option gived */ - perror_msg_and_die("%s", cf); + bb_perror_msg_and_die("%s", cf); p0 = NULL; cf = httpd_conf; /* set -c ./httpd_conf */ } @@ -543,7 +543,7 @@ static void parse_conf(const char *path, int flag) pcur = alloca((n + 1) * sizeof(Htaccess *)); if(pcur == NULL) { if(flag == FIRST_PARSE) - error_msg_and_die(memory_exhausted); + bb_error_msg_and_die(bb_msg_memory_exhausted); return; } n = 0; @@ -557,7 +557,7 @@ static void parse_conf(const char *path, int flag) config->Httpd_conf_parsed = *pcur; for(cur = *pcur; cur; cur = cur->next) { #ifdef DEBUG - error_msg("%s: %s:%s", cf, cur->before_colon, cur->after_colon); + bb_error_msg("%s: %s:%s", cf, cur->before_colon, cur->after_colon); #endif cur->next = *++pcur; } @@ -829,10 +829,10 @@ static int openServer(void) listen(fd, 9); signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */ } else { - perror_msg_and_die("bind"); + bb_perror_msg_and_die("bind"); } } else { - perror_msg_and_die("create socket"); + bb_perror_msg_and_die("create socket"); } return fd; } @@ -905,7 +905,7 @@ static int sendHeaders(HttpResponseNum responseNum) #ifdef DEBUG if (config->debugHttpd) fprintf(stderr, "Headers: '%s'", buf); #endif - return full_write(a_c_w, buf, len); + return bb_full_write(a_c_w, buf, len); } /**************************************************************************** @@ -1105,7 +1105,7 @@ static int sendCgi(const char *url, outFd = toCgi[1]; close(fromCgi[1]); close(toCgi[0]); - if (body) full_write(outFd, body, bodyLen); + if (body) bb_full_write(outFd, body, bodyLen); close(outFd); while (1) { @@ -1129,9 +1129,9 @@ static int sendCgi(const char *url, #ifdef DEBUG if (config->debugHttpd) { if (WIFEXITED(status)) - error_msg("piped has exited with status=%d", WEXITSTATUS(status)); + bb_error_msg("piped has exited with status=%d", WEXITSTATUS(status)); if (WIFSIGNALED(status)) - error_msg("piped has exited with signal=%d", WTERMSIG(status)); + bb_error_msg("piped has exited with signal=%d", WTERMSIG(status)); } #endif pid = -1; @@ -1141,7 +1141,7 @@ static int sendCgi(const char *url, int s = a_c_w; // There is something to read - count = full_read(inFd, buf, sizeof(buf)-1); + count = bb_full_read(inFd, buf, sizeof(buf)-1); // If a read returns 0 at this point then some type of error has // occurred. Bail now. if (count == 0) break; @@ -1149,14 +1149,14 @@ static int sendCgi(const char *url, if (firstLine) { /* check to see if the user script added headers */ if (strncmp(buf, "HTTP/1.0 200 OK\n", 4) != 0) { - full_write(s, "HTTP/1.0 200 OK\n", 16); + bb_full_write(s, "HTTP/1.0 200 OK\n", 16); } if (strstr(buf, "ontent-") == 0) { - full_write(s, "Content-type: text/plain\n\n", 26); + bb_full_write(s, "Content-type: text/plain\n\n", 26); } firstLine=0; } - full_write(s, buf, count); + bb_full_write(s, buf, count); #ifdef DEBUG if (config->debugHttpd) fprintf(stderr, "cgi read %d bytes\n", count); @@ -1223,14 +1223,14 @@ static int sendFile(const char *url, char *buf) int count; sendHeaders(HTTP_OK); - while ((count = full_read(f, buf, MAX_MEMORY_BUFF)) > 0) { - full_write(a_c_w, buf, count); + while ((count = bb_full_read(f, buf, MAX_MEMORY_BUFF)) > 0) { + bb_full_write(a_c_w, buf, count); } close(f); } else { #ifdef DEBUG if (config->debugHttpd) - perror_msg("Unable to open '%s'", url); + bb_perror_msg("Unable to open '%s'", url); #endif sendHeaders(HTTP_NOT_FOUND); } @@ -1399,7 +1399,7 @@ BAD_REQUEST: but CGI script can`t be a directory */ } - /* algorithm stolen from libbb simplify_path(), + /* algorithm stolen from libbb bb_simplify_path(), but don`t strdup and reducing trailing slash */ purl = test = url; @@ -1517,7 +1517,7 @@ FORBIDDEN: /* protect listing /cgi-bin */ if (length > 0) { body = malloc(length + 1); if (body) { - length = full_read(a_c_r, body, length); + length = bb_full_read(a_c_r, body, length); if(length < 0) // closed length = 0; body[length] = 0; // always null terminate for safety @@ -1629,7 +1629,7 @@ static int miniHttpd(int server) config->port = ntohs(fromAddr.sin_port); #ifdef DEBUG if (config->debugHttpd) { - error_msg("connection from IP=%s, port %u\n", + bb_error_msg("connection from IP=%s, port %u\n", config->rmt_ip, config->port); } #endif @@ -1748,7 +1748,7 @@ int httpd_main(int argc, char *argv[]) case 'p': config->port = atoi(optarg); if(config->port <= 0 || config->port > 0xffff) - error_msg_and_die("invalid %s for -p", optarg); + bb_error_msg_and_die("invalid %s for -p", optarg); break; #endif #ifdef CONFIG_FEATURE_HTTPD_DECODE_URL_STR @@ -1780,13 +1780,13 @@ int httpd_main(int argc, char *argv[]) break; #endif default: - error_msg("%s", httpdVersion); - show_usage(); + bb_error_msg("%s", httpdVersion); + bb_show_usage(); } } if(chdir(home_httpd)) { - perror_msg_and_die("can`t chdir to %s", home_httpd); + bb_perror_msg_and_die("can`t chdir to %s", home_httpd); } #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY server = openServer(); @@ -1809,7 +1809,7 @@ int httpd_main(int argc, char *argv[]) #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY if (!config->debugHttpd) { if (daemon(1, 0) < 0) /* don`t change curent directory */ - perror_msg_and_die("daemon"); + bb_perror_msg_and_die("daemon"); } return miniHttpd(server); #else diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 95cc07a..c09c48c 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c @@ -15,7 +15,7 @@ * Foundation; either version 2 of the License, or (at * your option) any later version. * - * $Id: ifconfig.c,v 1.22 2003/01/14 08:54:07 andersen Exp $ + * $Id: ifconfig.c,v 1.23 2003/03/19 09:12:38 mjn3 Exp $ * */ @@ -323,14 +323,14 @@ int ifconfig_main(int argc, char **argv) #ifdef CONFIG_FEATURE_IFCONFIG_STATUS return display_interfaces(argc ? *argv : NULL); #else - error_msg_and_die + bb_error_msg_and_die ("ifconfig was not compiled with interface status display support."); #endif } /* Create a channel to the NET kernel. */ if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - perror_msg_and_die("socket"); + bb_perror_msg_and_die("socket"); } /* get interface name */ @@ -366,11 +366,11 @@ int ifconfig_main(int argc, char **argv) mask = op->arg_flags; a1op = Arg1Opt + (op - OptArray); if (mask & A_NETMASK & did_flags) { - show_usage(); + bb_show_usage(); } if (*++argv == NULL) { if (mask & A_ARG_REQ) { - show_usage(); + bb_show_usage(); } else { --argv; mask &= A_SET_AFTER; /* just for broadcast */ @@ -421,7 +421,7 @@ int ifconfig_main(int argc, char **argv) /* Create a channel to the NET kernel. */ if ((sockfd6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { - perror_msg_and_die("socket6"); + bb_perror_msg_and_die("socket6"); } if (ioctl(sockfd6, SIOGIFINDEX, &ifr) < 0) { perror("SIOGIFINDEX"); @@ -454,11 +454,11 @@ int ifconfig_main(int argc, char **argv) } else { /* A_CAST_HOST_COPY_IN_ETHER */ /* This is the "hw" arg case. */ if (strcmp("ether", *argv) || (*++argv == NULL)) { - show_usage(); + bb_show_usage(); } safe_strncpy(host, *argv, (sizeof host)); if (in_ether(host, &sa)) { - error_msg("invalid hw-addr %s", host); + bb_error_msg("invalid hw-addr %s", host); ++goterr; continue; } diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 0511a5b..9bbb904 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c @@ -244,7 +244,7 @@ static char *parse(char *command, interface_defn_t *ifd) varvalue = get_var(command, nextpercent - command, ifd); if (varvalue) { - addstr(&result, &len, &pos, varvalue, xstrlen(varvalue)); + addstr(&result, &len, &pos, varvalue, bb_strlen(varvalue)); } else { #ifdef CONFIG_FEATURE_IFUPDOWN_IP /* Sigh... Add a special case for 'ip' to convert from @@ -255,7 +255,7 @@ static char *parse(char *command, interface_defn_t *ifd) if (varvalue && (res=count_netmask_bits(varvalue)) > 0) { char argument[255]; sprintf(argument, "%d", res); - addstr(&result, &len, &pos, argument, xstrlen(argument)); + addstr(&result, &len, &pos, argument, bb_strlen(argument)); command = nextpercent + 1; break; } @@ -734,9 +734,9 @@ static interfaces_file_t *read_interfaces(char *filename) defn->mappings = NULL; defn->ifaces = NULL; - f = xfopen(filename, "r"); + f = bb_xfopen(filename, "r"); - while ((buf = get_line_from_file(f)) != NULL) { + while ((buf = bb_get_line_from_file(f)) != NULL) { char *buf_ptr = buf; /* Ignore comments */ @@ -762,7 +762,7 @@ static interfaces_file_t *read_interfaces(char *filename) currmap->match = xrealloc(currmap->match, sizeof(currmap->match) * currmap->max_matches); } - currmap->match[currmap->n_matches++] = xstrdup(firstword); + currmap->match[currmap->n_matches++] = bb_xstrdup(firstword); } currmap->max_mappings = 0; currmap->n_mappings = 0; @@ -802,26 +802,26 @@ static interfaces_file_t *read_interfaces(char *filename) method_name = next_word(&buf_ptr); if (buf_ptr == NULL) { - error_msg("too few parameters for line \"%s\"", buf); + bb_error_msg("too few parameters for line \"%s\"", buf); return NULL; } if (buf_ptr[0] != '\0') { - error_msg("too many parameters \"%s\"", buf); + bb_error_msg("too many parameters \"%s\"", buf); return NULL; } - currif->iface = xstrdup(iface_name); + currif->iface = bb_xstrdup(iface_name); currif->address_family = get_address_family(addr_fams, address_family_name); if (!currif->address_family) { - error_msg("unknown address type \"%s\"", buf); + bb_error_msg("unknown address type \"%s\"", buf); return NULL; } currif->method = get_method(currif->address_family, method_name); if (!currif->method) { - error_msg("unknown method \"%s\"", buf); + bb_error_msg("unknown method \"%s\"", buf); return NULL; } @@ -836,7 +836,7 @@ static interfaces_file_t *read_interfaces(char *filename) while (*where != NULL) { if (duplicate_if(*where, currif)) { - error_msg("duplicate interface \"%s\"", buf); + bb_error_msg("duplicate interface \"%s\"", buf); return NULL; } where = &(*where)->next; @@ -852,7 +852,7 @@ static interfaces_file_t *read_interfaces(char *filename) /* Check the interface isnt already listed */ if (find_list_string(defn->autointerfaces, firstword)) { - perror_msg_and_die("interface declared auto twice \"%s\"", buf); + bb_perror_msg_and_die("interface declared auto twice \"%s\"", buf); } /* Add the interface to the list */ @@ -865,8 +865,8 @@ static interfaces_file_t *read_interfaces(char *filename) { int i; - if (xstrlen(buf_ptr) == 0) { - error_msg("option with empty value \"%s\"", buf); + if (bb_strlen(buf_ptr) == 0) { + bb_error_msg("option with empty value \"%s\"", buf); return NULL; } @@ -876,7 +876,7 @@ static interfaces_file_t *read_interfaces(char *filename) && strcmp(firstword, "post-down") != 0) { for (i = 0; i < currif->n_options; i++) { if (strcmp(currif->option[i].name, firstword) == 0) { - error_msg("duplicate option \"%s\"", buf); + bb_error_msg("duplicate option \"%s\"", buf); return NULL; } } @@ -889,8 +889,8 @@ static interfaces_file_t *read_interfaces(char *filename) opt = xrealloc(currif->option, sizeof(*opt) * currif->max_options); currif->option = opt; } - currif->option[currif->n_options].name = xstrdup(firstword); - currif->option[currif->n_options].value = xstrdup(next_word(&buf_ptr)); + currif->option[currif->n_options].name = bb_xstrdup(firstword); + currif->option[currif->n_options].value = bb_xstrdup(next_word(&buf_ptr)); if (!currif->option[currif->n_options].name) { perror(filename); return NULL; @@ -905,34 +905,34 @@ static interfaces_file_t *read_interfaces(char *filename) #ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING if (strcmp(firstword, "script") == 0) { if (currmap->script != NULL) { - error_msg("duplicate script in mapping \"%s\"", buf); + bb_error_msg("duplicate script in mapping \"%s\"", buf); return NULL; } else { - currmap->script = xstrdup(next_word(&buf_ptr)); + currmap->script = bb_xstrdup(next_word(&buf_ptr)); } } else if (strcmp(firstword, "map") == 0) { if (currmap->max_mappings == currmap->n_mappings) { currmap->max_mappings = currmap->max_mappings * 2 + 1; currmap->mapping = xrealloc(currmap->mapping, sizeof(char *) * currmap->max_mappings); } - currmap->mapping[currmap->n_mappings] = xstrdup(next_word(&buf_ptr)); + currmap->mapping[currmap->n_mappings] = bb_xstrdup(next_word(&buf_ptr)); currmap->n_mappings++; } else { - error_msg("misplaced option \"%s\"", buf); + bb_error_msg("misplaced option \"%s\"", buf); return NULL; } #endif break; case NONE: default: - error_msg("misplaced option \"%s\"", buf); + bb_error_msg("misplaced option \"%s\"", buf); return NULL; } } free(buf); } if (ferror(f) != 0) { - perror_msg_and_die("%s", filename); + bb_perror_msg_and_die("%s", filename); } fclose(f); @@ -945,7 +945,7 @@ static char *setlocalenv(char *format, char *name, char *value) char *here; char *there; - result = xmalloc(xstrlen(format) + xstrlen(name) + xstrlen(value) + 1); + result = xmalloc(bb_strlen(format) + bb_strlen(name) + bb_strlen(value) + 1); sprintf(result, format, name, value); @@ -960,7 +960,7 @@ static char *setlocalenv(char *format, char *name, char *value) here++; } } - memmove(here, there, xstrlen(there) + 1); + memmove(here, there, bb_strlen(there) + 1); return result; } @@ -1010,7 +1010,7 @@ static void set_environ(interface_defn_t *iface, char *mode) static int doit(char *str) { if (verbose || no_act) { - error_msg("%s", str); + bb_error_msg("%s", str); } if (!no_act) { pid_t child; @@ -1045,7 +1045,7 @@ static int execute_all(interface_defn_t *ifd, execfn *exec, const char *opt) } } - buf = xmalloc(xstrlen(opt) + 19); + buf = xmalloc(bb_strlen(opt) + 19); sprintf(buf, "/etc/network/if-%s.d", opt); run_parts(&buf, 2); free(buf); @@ -1155,7 +1155,7 @@ static int run_mapping(char *physical, char *logical, int len, mapping_defn_t * waitpid(pid, &status, 0); if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { if (fgets(logical, len, out)) { - char *pch = logical + xstrlen(logical) - 1; + char *pch = logical + bb_strlen(logical) - 1; while (pch >= logical && isspace(*pch)) *(pch--) = '\0'; @@ -1169,7 +1169,7 @@ static int run_mapping(char *physical, char *logical, int len, mapping_defn_t * static llist_t *find_iface_state(llist_t *state_list, const char *iface) { - unsigned short iface_len = xstrlen(iface); + unsigned short iface_len = bb_strlen(iface); llist_t *search = state_list; while (search) { @@ -1199,7 +1199,7 @@ extern int ifupdown_main(int argc, char **argv) int force = 0; int i; - if (applet_name[2] == 'u') { + if (bb_applet_name[2] == 'u') { /* ifup command */ cmds = iface_up; } else { @@ -1214,7 +1214,7 @@ extern int ifupdown_main(int argc, char **argv) #endif switch (i) { case 'i': /* interfaces */ - interfaces = xstrdup(optarg); + interfaces = bb_xstrdup(optarg); break; case 'v': /* verbose */ verbose = 1; @@ -1234,18 +1234,18 @@ extern int ifupdown_main(int argc, char **argv) force = 1; break; default: - show_usage(); + bb_show_usage(); break; } } if (argc - optind > 0) { if (do_all) { - show_usage(); + bb_show_usage(); } } else { if (!do_all) { - show_usage(); + bb_show_usage(); } } @@ -1297,13 +1297,13 @@ extern int ifupdown_main(int argc, char **argv) if (cmds == iface_up) { /* ifup */ if (iface_state) { - error_msg("interface %s already configured", iface); + bb_error_msg("interface %s already configured", iface); continue; } } else { /* ifdown */ if (iface_state) { - error_msg("interface %s not configured", iface); + bb_error_msg("interface %s not configured", iface); continue; } } @@ -1319,7 +1319,7 @@ extern int ifupdown_main(int argc, char **argv) if (fnmatch(currmap->match[i], liface, 0) != 0) continue; if (verbose) { - error_msg("Running mapping script %s on %s", currmap->script, liface); + bb_error_msg("Running mapping script %s on %s", currmap->script, liface); } run_mapping(iface, liface, sizeof(liface), currmap); break; @@ -1336,7 +1336,7 @@ extern int ifupdown_main(int argc, char **argv) currif->iface = iface; if (verbose) { - error_msg("Configuring interface %s=%s (%s)", iface, liface, currif->address_family->name); + bb_error_msg("Configuring interface %s=%s (%s)", iface, liface, currif->address_family->name); } /* Call the cmds function pointer, does either iface_up() or iface_down() */ @@ -1351,12 +1351,12 @@ extern int ifupdown_main(int argc, char **argv) } if (!okay && !force) { - error_msg("Ignoring unknown interface %s=%s.", iface, liface); + bb_error_msg("Ignoring unknown interface %s=%s.", iface, liface); } else { llist_t *iface_state = find_iface_state(state_list, iface); if (cmds == iface_up) { - char *newiface = xmalloc(xstrlen(iface) + 1 + xstrlen(liface) + 1); + char *newiface = xmalloc(bb_strlen(iface) + 1 + bb_strlen(liface) + 1); sprintf(newiface, "%s=%s", iface, liface); if (iface_state == NULL) { state_list = llist_add_to(state_list, newiface); @@ -1387,10 +1387,10 @@ extern int ifupdown_main(int argc, char **argv) if (state_fp) fclose(state_fp); - state_fp = xfopen(statefile, "a+"); + state_fp = bb_xfopen(statefile, "a+"); if (ftruncate(fileno(state_fp), 0) < 0) { - error_msg_and_die("failed to truncate statefile %s: %s", statefile, strerror(errno)); + bb_error_msg_and_die("failed to truncate statefile %s: %s", statefile, strerror(errno)); } rewind(state_fp); diff --git a/networking/inetd.c b/networking/inetd.c index 2769c01..33b97ba 100644 --- a/networking/inetd.c +++ b/networking/inetd.c @@ -519,7 +519,7 @@ enter(struct servtab *cp) sep = (struct servtab *)malloc(sizeof (*sep)); if (sep == NULL) { - syslog_err_and_discard_dg(SOCK_STREAM, memory_exhausted); + syslog_err_and_discard_dg(SOCK_STREAM, bb_msg_memory_exhausted); } *sep = *cp; sep->se_fd = -1; @@ -835,7 +835,7 @@ inetd_main(int argc, char *argv[]) if (global_queuelen < 8) global_queuelen=8; break; default: - show_usage(); // "[-q len] [conf]" + bb_show_usage(); // "[-q len] [conf]" } argc -= optind; argv += optind; @@ -844,7 +844,7 @@ inetd_main(int argc, char *argv[]) CONFIG = argv[0]; daemon(0, 0); - openlog(applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON); + openlog(bb_applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON); { FILE *fp; diff --git a/networking/ip.c b/networking/ip.c index e7cab74..a0781bd 100644 --- a/networking/ip.c +++ b/networking/ip.c @@ -72,7 +72,7 @@ void ip_parse_common_args(int *argcp, char ***argvp) } else if (matches(opt, "-oneline") == 0) { ++oneline; } else { - show_usage(); + bb_show_usage(); } argc--; argv++; } @@ -109,7 +109,7 @@ int ip_main(int argc, char **argv) #endif } if (ret) { - show_usage(); + bb_show_usage(); } return(EXIT_SUCCESS); } diff --git a/networking/ipcalc.c b/networking/ipcalc.c index f130f3b..2c23d17 100644 --- a/networking/ipcalc.c +++ b/networking/ipcalc.c @@ -82,24 +82,24 @@ int ipcalc_main(int argc, char **argv) mode |= SILENT; #endif else { - show_usage(); + bb_show_usage(); } } if (mode & (BROADCAST | NETWORK)) { if (argc - optind > 2) { - show_usage(); + bb_show_usage(); } } else { if (argc - optind != 1) { - show_usage(); + bb_show_usage(); } } ipaddr = inet_addr(argv[optind]); if (ipaddr == INADDR_NONE) { - IPCALC_MSG(error_msg_and_die("bad IP address: %s\n", argv[optind]), + IPCALC_MSG(bb_error_msg_and_die("bad IP address: %s\n", argv[optind]), exit(EXIT_FAILURE)); } @@ -109,7 +109,7 @@ int ipcalc_main(int argc, char **argv) } if (ipaddr == INADDR_NONE) { - IPCALC_MSG(error_msg_and_die("bad netmask: %s\n", argv[optind + 1]), + IPCALC_MSG(bb_error_msg_and_die("bad netmask: %s\n", argv[optind + 1]), exit(EXIT_FAILURE)); } @@ -138,7 +138,7 @@ int ipcalc_main(int argc, char **argv) hostinfo = gethostbyaddr((char *) &ipaddr, sizeof(ipaddr), AF_INET); if (!hostinfo) { - IPCALC_MSG(error_msg("cannot find hostname for %s", argv[optind]); + IPCALC_MSG(bb_error_msg("cannot find hostname for %s", argv[optind]); herror(NULL); putc('\n', stderr);,); exit(EXIT_FAILURE); diff --git a/networking/libiproute/ip_parse_common_args.c b/networking/libiproute/ip_parse_common_args.c index 4b4355a..21e9f74 100644 --- a/networking/libiproute/ip_parse_common_args.c +++ b/networking/libiproute/ip_parse_common_args.c @@ -48,7 +48,7 @@ void ip_parse_common_args(int *argcp, char ***argvp) argc--; argv++; if (! argv[1]) - show_usage(); + bb_show_usage(); if (strcmp(argv[1], "inet") == 0) preferred_family = AF_INET; else if (strcmp(argv[1], "inet6") == 0) @@ -66,7 +66,7 @@ void ip_parse_common_args(int *argcp, char ***argvp) } else if (matches(opt, "-oneline") == 0) { ++oneline; } else { - show_usage(); + bb_show_usage(); } argc--; argv++; } diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 8eba90c..44e871e 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c @@ -125,7 +125,7 @@ static int print_linkinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg memset(tb, 0, sizeof(tb)); parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len); if (tb[IFLA_IFNAME] == NULL) { - error_msg("nil ifname"); + bb_error_msg("nil ifname"); return -1; } if (filter.label && @@ -217,7 +217,7 @@ static int print_addrinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg return 0; len -= NLMSG_LENGTH(sizeof(*ifa)); if (len < 0) { - error_msg("wrong nlmsg len %d", len); + bb_error_msg("wrong nlmsg len %d", len); return -1; } @@ -489,17 +489,17 @@ extern int ipaddr_list_or_flush(int argc, char **argv, int flush) exit(1); if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETLINK) < 0) { - perror_msg_and_die("Cannot send dump request"); + bb_perror_msg_and_die("Cannot send dump request"); } if (rtnl_dump_filter(&rth, store_nlmsg, &linfo, NULL, NULL) < 0) { - error_msg_and_die("Dump terminated"); + bb_error_msg_and_die("Dump terminated"); } if (filter_dev) { filter.ifindex = ll_name_to_index(filter_dev); if (filter.ifindex <= 0) { - error_msg("Device \"%s\" does not exist.", filter_dev); + bb_error_msg("Device \"%s\" does not exist.", filter_dev); return -1; } } @@ -539,11 +539,11 @@ extern int ipaddr_list_or_flush(int argc, char **argv, int flush) if (filter.family != AF_PACKET) { if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) { - perror_msg_and_die("Cannot send dump request"); + bb_perror_msg_and_die("Cannot send dump request"); } if (rtnl_dump_filter(&rth, store_nlmsg, &ainfo, NULL, NULL) < 0) { - error_msg_and_die("Dump terminated"); + bb_error_msg_and_die("Dump terminated"); } } @@ -749,11 +749,11 @@ static int ipaddr_modify(int cmd, int argc, char **argv) } if (d == NULL) { - error_msg("Not enough information: \"dev\" argument is required."); + bb_error_msg("Not enough information: \"dev\" argument is required."); return -1; } if (l && matches(d, l) != 0) { - error_msg_and_die("\"dev\" (%s) must match \"label\" (%s).", d, l); + bb_error_msg_and_die("\"dev\" (%s) must match \"label\" (%s).", d, l); } if (peer_len == 0 && local_len && cmd != RTM_DELADDR) { @@ -767,7 +767,7 @@ static int ipaddr_modify(int cmd, int argc, char **argv) inet_prefix brd; int i; if (req.ifa.ifa_family != AF_INET) { - error_msg("Broadcast can be set only for IPv4 addresses"); + bb_error_msg("Broadcast can be set only for IPv4 addresses"); return -1; } brd = peer; @@ -791,7 +791,7 @@ static int ipaddr_modify(int cmd, int argc, char **argv) ll_init_map(&rth); if ((req.ifa.ifa_index = ll_name_to_index(d)) == 0) { - error_msg("Cannot find device \"%s\"", d); + bb_error_msg("Cannot find device \"%s\"", d); return -1; } @@ -821,5 +821,5 @@ extern int do_ipaddr(int argc, char **argv) case 5: /* flush */ return ipaddr_list_or_flush(argc-1, argv+1, 1); } - error_msg_and_die("Unknown command %s", *argv); + bb_error_msg_and_die("Unknown command %s", *argv); } diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c index 1cfaf6d..f826ba0 100644 --- a/networking/libiproute/iplink.c +++ b/networking/libiproute/iplink.c @@ -42,7 +42,7 @@ static int do_link; static int on_off(char *msg) { - error_msg("Error: argument of \"%s\" must be \"on\" or \"off\"", msg); + bb_error_msg("Error: argument of \"%s\" must be \"on\" or \"off\"", msg); return -1; } @@ -211,7 +211,7 @@ static int parse_address(char *dev, int hatype, int halen, char *lla, struct ifr if (alen < 0) return -1; if (alen != halen) { - error_msg("Wrong address (%s) length: expected %d bytes", lla, halen); + bb_error_msg("Wrong address (%s) length: expected %d bytes", lla, halen); return -1; } return 0; @@ -293,7 +293,7 @@ static int do_set(int argc, char **argv) } if (!dev) { - error_msg("Not enough of information: \"dev\" argument is required."); + bb_error_msg("Not enough of information: \"dev\" argument is required."); exit(-1); } @@ -358,6 +358,6 @@ int do_iplink(int argc, char **argv) } else return ipaddr_list_link(0, NULL); - error_msg("Command \"%s\" is unknown, try \"ip link help\".", *argv); + bb_error_msg("Command \"%s\" is unknown, try \"ip link help\".", *argv); exit(-1); } diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index be4435f..3dcafdb 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c @@ -85,7 +85,7 @@ static int print_route(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) return 0; len -= NLMSG_LENGTH(sizeof(*r)); if (len < 0) { - error_msg("wrong nlmsg len %d", len); + bb_error_msg("wrong nlmsg len %d", len); return -1; } @@ -385,7 +385,7 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv) if (d) { if ((idx = ll_name_to_index(d)) == 0) { - error_msg("Cannot find device \"%s\"", d); + bb_error_msg("Cannot find device \"%s\"", d); return -1; } addattr32(&req.n, sizeof(req), RTA_OIF, idx); @@ -549,7 +549,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) if (id) { if ((idx = ll_name_to_index(id)) == 0) { - error_msg("Cannot find device \"%s\"", id); + bb_error_msg("Cannot find device \"%s\"", id); return -1; } filter.iif = idx; @@ -557,7 +557,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) } if (od) { if ((idx = ll_name_to_index(od)) == 0) { - error_msg("Cannot find device \"%s\"", od); + bb_error_msg("Cannot find device \"%s\"", od); } filter.oif = idx; filter.oifmask = -1; @@ -587,7 +587,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) } filter.flushed = 0; if (rtnl_dump_filter(&rth, print_route, stdout, NULL, NULL) < 0) { - error_msg("Flush terminated\n"); + bb_error_msg("Flush terminated\n"); return -1; } if (filter.flushed == 0) { @@ -606,16 +606,16 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) if (filter.tb != -1) { if (rtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE) < 0) { - perror_msg_and_die("Cannot send dump request"); + bb_perror_msg_and_die("Cannot send dump request"); } } else { if (rtnl_rtcache_request(&rth, do_ipv6) < 0) { - perror_msg_and_die("Cannot send dump request"); + bb_perror_msg_and_die("Cannot send dump request"); } } if (rtnl_dump_filter(&rth, print_route, stdout, NULL, NULL) < 0) { - error_msg_and_die("Dump terminated"); + bb_error_msg_and_die("Dump terminated"); } exit(0); @@ -703,7 +703,7 @@ static int iproute_get(int argc, char **argv) } if (req.r.rtm_dst_len == 0) { - error_msg_and_die("need at least destination address"); + bb_error_msg_and_die("need at least destination address"); } if (rtnl_open(&rth, 0) < 0) @@ -716,14 +716,14 @@ static int iproute_get(int argc, char **argv) if (idev) { if ((idx = ll_name_to_index(idev)) == 0) { - error_msg("Cannot find device \"%s\"", idev); + bb_error_msg("Cannot find device \"%s\"", idev); return -1; } addattr32(&req.n, sizeof(req), RTA_IIF, idx); } if (odev) { if ((idx = ll_name_to_index(odev)) == 0) { - error_msg("Cannot find device \"%s\"", odev); + bb_error_msg("Cannot find device \"%s\"", odev); return -1; } addattr32(&req.n, sizeof(req), RTA_OIF, idx); @@ -744,16 +744,16 @@ static int iproute_get(int argc, char **argv) struct rtattr * tb[RTA_MAX+1]; if (print_route(NULL, &req.n, (void*)stdout) < 0) { - error_msg_and_die("An error :-)"); + bb_error_msg_and_die("An error :-)"); } if (req.n.nlmsg_type != RTM_NEWROUTE) { - error_msg("Not a route?"); + bb_error_msg("Not a route?"); return -1; } len -= NLMSG_LENGTH(sizeof(*r)); if (len < 0) { - error_msg("Wrong len %d", len); + bb_error_msg("Wrong len %d", len); return -1; } @@ -764,7 +764,7 @@ static int iproute_get(int argc, char **argv) tb[RTA_PREFSRC]->rta_type = RTA_SRC; r->rtm_src_len = 8*RTA_PAYLOAD(tb[RTA_PREFSRC]); } else if (!tb[RTA_SRC]) { - error_msg("Failed to connect the route"); + bb_error_msg("Failed to connect the route"); return -1; } if (!odev && tb[RTA_OIF]) { @@ -785,7 +785,7 @@ static int iproute_get(int argc, char **argv) } if (print_route(NULL, &req.n, (void*)stdout) < 0) { - error_msg_and_die("An error :-)"); + bb_error_msg_and_die("An error :-)"); } exit(0); @@ -830,7 +830,7 @@ int do_iproute(int argc, char **argv) case 11: /* flush */ return iproute_list_or_flush(argc-1, argv+1, 1); default: - error_msg_and_die("Unknown command %s", *argv); + bb_error_msg_and_die("Unknown command %s", *argv); } return iproute_modify(cmd, flags, argc-1, argv+1); diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c index 1eb1779..eae5bb0 100644 --- a/networking/libiproute/iptunnel.c +++ b/networking/libiproute/iptunnel.c @@ -47,7 +47,7 @@ static int do_ioctl_get_ifindex(char *dev) strcpy(ifr.ifr_name, dev); fd = socket(AF_INET, SOCK_DGRAM, 0); if (ioctl(fd, SIOCGIFINDEX, &ifr)) { - perror_msg("ioctl"); + bb_perror_msg("ioctl"); return 0; } close(fd); @@ -62,7 +62,7 @@ static int do_ioctl_get_iftype(char *dev) strcpy(ifr.ifr_name, dev); fd = socket(AF_INET, SOCK_DGRAM, 0); if (ioctl(fd, SIOCGIFHWADDR, &ifr)) { - perror_msg("ioctl"); + bb_perror_msg("ioctl"); return -1; } close(fd); @@ -78,7 +78,7 @@ static char *do_ioctl_get_ifname(int idx) ifr.ifr_ifindex = idx; fd = socket(AF_INET, SOCK_DGRAM, 0); if (ioctl(fd, SIOCGIFNAME, &ifr)) { - perror_msg("ioctl"); + bb_perror_msg("ioctl"); return NULL; } close(fd); @@ -98,7 +98,7 @@ static int do_get_ioctl(char *basedev, struct ip_tunnel_parm *p) fd = socket(AF_INET, SOCK_DGRAM, 0); err = ioctl(fd, SIOCGETTUNNEL, &ifr); if (err) { - perror_msg("ioctl"); + bb_perror_msg("ioctl"); } close(fd); return err; @@ -119,7 +119,7 @@ static int do_add_ioctl(int cmd, char *basedev, struct ip_tunnel_parm *p) fd = socket(AF_INET, SOCK_DGRAM, 0); err = ioctl(fd, cmd, &ifr); if (err) { - perror_msg("ioctl"); + bb_perror_msg("ioctl"); } close(fd); return err; @@ -140,7 +140,7 @@ static int do_del_ioctl(char *basedev, struct ip_tunnel_parm *p) fd = socket(AF_INET, SOCK_DGRAM, 0); err = ioctl(fd, SIOCDELTUNNEL, &ifr); if (err) { - perror_msg("ioctl"); + bb_perror_msg("ioctl"); } close(fd); return err; @@ -166,26 +166,26 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) if (strcmp(*argv, "ipip") == 0 || strcmp(*argv, "ip/ip") == 0) { if (p->iph.protocol && p->iph.protocol != IPPROTO_IPIP) { - error_msg("You managed to ask for more than one tunnel mode."); + bb_error_msg("You managed to ask for more than one tunnel mode."); exit(-1); } p->iph.protocol = IPPROTO_IPIP; } else if (strcmp(*argv, "gre") == 0 || strcmp(*argv, "gre/ip") == 0) { if (p->iph.protocol && p->iph.protocol != IPPROTO_GRE) { - error_msg("You managed to ask for more than one tunnel mode."); + bb_error_msg("You managed to ask for more than one tunnel mode."); exit(-1); } p->iph.protocol = IPPROTO_GRE; } else if (strcmp(*argv, "sit") == 0 || strcmp(*argv, "ipv6/ip") == 0) { if (p->iph.protocol && p->iph.protocol != IPPROTO_IPV6) { - error_msg("You managed to ask for more than one tunnel mode."); + bb_error_msg("You managed to ask for more than one tunnel mode."); exit(-1); } p->iph.protocol = IPPROTO_IPV6; } else { - error_msg("Cannot guess tunnel mode."); + bb_error_msg("Cannot guess tunnel mode."); exit(-1); } } else if (strcmp(*argv, "key") == 0) { @@ -197,7 +197,7 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) p->i_key = p->o_key = get_addr32(*argv); else { if (get_unsigned(&uval, *argv, 0)<0) { - error_msg("invalid value of \"key\""); + bb_error_msg("invalid value of \"key\""); exit(-1); } p->i_key = p->o_key = htonl(uval); @@ -210,7 +210,7 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) p->o_key = get_addr32(*argv); else { if (get_unsigned(&uval, *argv, 0)<0) { - error_msg("invalid value of \"ikey\""); + bb_error_msg("invalid value of \"ikey\""); exit(-1); } p->i_key = htonl(uval); @@ -223,7 +223,7 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) p->o_key = get_addr32(*argv); else { if (get_unsigned(&uval, *argv, 0)<0) { - error_msg("invalid value of \"okey\""); + bb_error_msg("invalid value of \"okey\""); exit(-1); } p->o_key = htonl(uval); @@ -308,7 +308,7 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) if (p->iph.protocol == IPPROTO_IPIP || p->iph.protocol == IPPROTO_IPV6) { if ((p->i_flags & GRE_KEY) || (p->o_flags & GRE_KEY)) { - error_msg("Keys are not allowed with ipip and sit."); + bb_error_msg("Keys are not allowed with ipip and sit."); return -1; } } @@ -328,7 +328,7 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) p->o_flags |= GRE_KEY; } if (IN_MULTICAST(ntohl(p->iph.daddr)) && !p->iph.saddr) { - error_msg("Broadcast tunnel requires a source address."); + bb_error_msg("Broadcast tunnel requires a source address."); return -1; } return 0; @@ -343,7 +343,7 @@ static int do_add(int cmd, int argc, char **argv) return -1; if (p.iph.ttl && p.iph.frag_off == 0) { - error_msg("ttl != 0 and noptmudisc are incompatible"); + bb_error_msg("ttl != 0 and noptmudisc are incompatible"); return -1; } @@ -355,7 +355,7 @@ static int do_add(int cmd, int argc, char **argv) case IPPROTO_IPV6: return do_add_ioctl(cmd, "sit0", &p); default: - error_msg("cannot determine tunnel mode (ipip, gre or sit)"); + bb_error_msg("cannot determine tunnel mode (ipip, gre or sit)"); return -1; } return -1; @@ -464,7 +464,7 @@ static int do_tunnels_list(struct ip_tunnel_parm *p) buf[sizeof(buf) - 1] = 0; if ((ptr = strchr(buf, ':')) == NULL || (*ptr++ = 0, sscanf(buf, "%s", name) != 1)) { - error_msg("Wrong format of /proc/net/dev. Sorry."); + bb_error_msg("Wrong format of /proc/net/dev. Sorry."); return -1; } if (sscanf(ptr, "%ld%ld%ld%ld%ld%ld%ld%*d%ld%ld%ld%ld%ld%ld%ld", @@ -477,7 +477,7 @@ static int do_tunnels_list(struct ip_tunnel_parm *p) continue; type = do_ioctl_get_iftype(name); if (type == -1) { - error_msg("Failed to get type of [%s]", name); + bb_error_msg("Failed to get type of [%s]", name); continue; } if (type != ARPHRD_TUNNEL && type != ARPHRD_IPGRE && type != ARPHRD_SIT) @@ -543,6 +543,6 @@ int do_iptunnel(int argc, char **argv) } else return do_show(0, NULL); - error_msg("Command \"%s\" is unknown, try \"ip tunnel help\".", *argv); + bb_error_msg("Command \"%s\" is unknown, try \"ip tunnel help\".", *argv); exit(-1); } diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c index fbc555d..0441193 100644 --- a/networking/libiproute/libnetlink.c +++ b/networking/libiproute/libnetlink.c @@ -34,7 +34,7 @@ int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions) rth->fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (rth->fd < 0) { - perror_msg("Cannot open netlink socket"); + bb_perror_msg("Cannot open netlink socket"); return -1; } @@ -43,20 +43,20 @@ int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions) rth->local.nl_groups = subscriptions; if (bind(rth->fd, (struct sockaddr*)&rth->local, sizeof(rth->local)) < 0) { - perror_msg("Cannot bind netlink socket"); + bb_perror_msg("Cannot bind netlink socket"); return -1; } addr_len = sizeof(rth->local); if (getsockname(rth->fd, (struct sockaddr*)&rth->local, &addr_len) < 0) { - perror_msg("Cannot getsockname"); + bb_perror_msg("Cannot getsockname"); return -1; } if (addr_len != sizeof(rth->local)) { - error_msg("Wrong address length %d", addr_len); + bb_error_msg("Wrong address length %d", addr_len); return -1; } if (rth->local.nl_family != AF_NETLINK) { - error_msg("Wrong address family %d", rth->local.nl_family); + bb_error_msg("Wrong address family %d", rth->local.nl_family); return -1; } rth->seq = time(NULL); @@ -144,15 +144,15 @@ int rtnl_dump_filter(struct rtnl_handle *rth, if (status < 0) { if (errno == EINTR) continue; - perror_msg("OVERRUN"); + bb_perror_msg("OVERRUN"); continue; } if (status == 0) { - error_msg("EOF on netlink"); + bb_error_msg("EOF on netlink"); return -1; } if (msg.msg_namelen != sizeof(nladdr)) { - error_msg_and_die("sender address length == %d", msg.msg_namelen); + bb_error_msg_and_die("sender address length == %d", msg.msg_namelen); } h = (struct nlmsghdr*)buf; @@ -176,10 +176,10 @@ int rtnl_dump_filter(struct rtnl_handle *rth, if (h->nlmsg_type == NLMSG_ERROR) { struct nlmsgerr *l_err = (struct nlmsgerr*)NLMSG_DATA(h); if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) { - error_msg("ERROR truncated"); + bb_error_msg("ERROR truncated"); } else { errno = -l_err->error; - perror_msg("RTNETLINK answers"); + bb_perror_msg("RTNETLINK answers"); } return -1; } @@ -192,11 +192,11 @@ skip_it: h = NLMSG_NEXT(h, status); } if (msg.msg_flags & MSG_TRUNC) { - error_msg("Message truncated"); + bb_error_msg("Message truncated"); continue; } if (status) { - error_msg_and_die("!!!Remnant of size %d", status); + bb_error_msg_and_die("!!!Remnant of size %d", status); } } } @@ -231,7 +231,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, status = sendmsg(rtnl->fd, &msg, 0); if (status < 0) { - perror_msg("Cannot talk to rtnetlink"); + bb_perror_msg("Cannot talk to rtnetlink"); return -1; } @@ -245,15 +245,15 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, if (errno == EINTR) { continue; } - perror_msg("OVERRUN"); + bb_perror_msg("OVERRUN"); continue; } if (status == 0) { - error_msg("EOF on netlink"); + bb_error_msg("EOF on netlink"); return -1; } if (msg.msg_namelen != sizeof(nladdr)) { - error_msg_and_die("sender address length == %d", msg.msg_namelen); + bb_error_msg_and_die("sender address length == %d", msg.msg_namelen); } for (h = (struct nlmsghdr*)buf; status >= sizeof(*h); ) { int l_err; @@ -262,10 +262,10 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, if (l<0 || len>status) { if (msg.msg_flags & MSG_TRUNC) { - error_msg("Truncated message"); + bb_error_msg("Truncated message"); return -1; } - error_msg_and_die("!!!malformed message: len=%d", len); + bb_error_msg_and_die("!!!malformed message: len=%d", len); } if (h->nlmsg_pid != rtnl->local.nl_pid || @@ -282,7 +282,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, if (h->nlmsg_type == NLMSG_ERROR) { struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h); if (l < sizeof(struct nlmsgerr)) { - error_msg("ERROR truncated"); + bb_error_msg("ERROR truncated"); } else { errno = -err->error; if (errno == 0) { @@ -291,7 +291,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, } return 0; } - perror_msg("RTNETLINK answers"); + bb_perror_msg("RTNETLINK answers"); } return -1; } @@ -300,17 +300,17 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, return 0; } - error_msg("Unexpected reply!!!"); + bb_error_msg("Unexpected reply!!!"); status -= NLMSG_ALIGN(len); h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); } if (msg.msg_flags & MSG_TRUNC) { - error_msg("Message truncated"); + bb_error_msg("Message truncated"); continue; } if (status) { - error_msg_and_die("!!!Remnant of size %d", status); + bb_error_msg_and_die("!!!Remnant of size %d", status); } } } @@ -346,15 +346,15 @@ int rtnl_listen(struct rtnl_handle *rtnl, if (status < 0) { if (errno == EINTR) continue; - perror_msg("OVERRUN"); + bb_perror_msg("OVERRUN"); continue; } if (status == 0) { - error_msg("EOF on netlink"); + bb_error_msg("EOF on netlink"); return -1; } if (msg.msg_namelen != sizeof(nladdr)) { - error_msg_and_die("Sender address length == %d", msg.msg_namelen); + bb_error_msg_and_die("Sender address length == %d", msg.msg_namelen); } for (h = (struct nlmsghdr*)buf; status >= sizeof(*h); ) { int err; @@ -363,10 +363,10 @@ int rtnl_listen(struct rtnl_handle *rtnl, if (l<0 || len>status) { if (msg.msg_flags & MSG_TRUNC) { - error_msg("Truncated message"); + bb_error_msg("Truncated message"); return -1; } - error_msg_and_die("!!!malformed message: len=%d", len); + bb_error_msg_and_die("!!!malformed message: len=%d", len); } err = handler(&nladdr, h, jarg); @@ -378,11 +378,11 @@ int rtnl_listen(struct rtnl_handle *rtnl, h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); } if (msg.msg_flags & MSG_TRUNC) { - error_msg("Message truncated"); + bb_error_msg("Message truncated"); continue; } if (status) { - error_msg_and_die("!!!Remnant of size %d", status); + bb_error_msg_and_die("!!!Remnant of size %d", status); } } } @@ -410,7 +410,7 @@ int rtnl_from_file(FILE *rtnl, if (status < 0) { if (errno == EINTR) continue; - perror_msg("rtnl_from_file: fread"); + bb_perror_msg("rtnl_from_file: fread"); return -1; } if (status == 0) @@ -421,7 +421,7 @@ int rtnl_from_file(FILE *rtnl, l = len - sizeof(*h); if (l<0 || len>sizeof(buf)) { - error_msg("!!!malformed message: len=%d @%lu", + bb_error_msg("!!!malformed message: len=%d @%lu", len, ftell(rtnl)); return -1; } @@ -429,11 +429,11 @@ int rtnl_from_file(FILE *rtnl, status = fread(NLMSG_DATA(h), 1, NLMSG_ALIGN(l), rtnl); if (status < 0) { - perror_msg("rtnl_from_file: fread"); + bb_perror_msg("rtnl_from_file: fread"); return -1; } if (status < l) { - error_msg("rtnl-from_file: truncated message"); + bb_error_msg("rtnl-from_file: truncated message"); return -1; } @@ -514,7 +514,7 @@ int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len) rta = RTA_NEXT(rta,len); } if (len) { - error_msg("!!!Deficit %d, rta_len=%d", len, rta->rta_len); + bb_error_msg("!!!Deficit %d, rta_len=%d", len, rta->rta_len); } return 0; } diff --git a/networking/libiproute/ll_addr.c b/networking/libiproute/ll_addr.c index 39e561f..ada685f 100644 --- a/networking/libiproute/ll_addr.c +++ b/networking/libiproute/ll_addr.c @@ -44,7 +44,7 @@ int ll_addr_a2n(unsigned char *lladdr, int len, char *arg) if (strchr(arg, '.')) { inet_prefix pfx; if (get_addr_1(&pfx, arg, AF_INET)) { - error_msg("\"%s\" is invalid lladdr.", arg); + bb_error_msg("\"%s\" is invalid lladdr.", arg); return -1; } if (len < 4) { @@ -63,11 +63,11 @@ int ll_addr_a2n(unsigned char *lladdr, int len, char *arg) cp++; } if (sscanf(arg, "%x", &temp) != 1) { - error_msg("\"%s\" is invalid lladdr.", arg); + bb_error_msg("\"%s\" is invalid lladdr.", arg); return -1; } if (temp < 0 || temp > 255) { - error_msg("\"%s\" is invalid lladdr.", arg); + bb_error_msg("\"%s\" is invalid lladdr.", arg); return -1; } lladdr[i] = temp; diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c index 2c23cd2..fa15486 100644 --- a/networking/libiproute/utils.c +++ b/networking/libiproute/utils.c @@ -209,10 +209,10 @@ int get_prefix_1(inet_prefix * dst, char *arg, int family) int get_addr(inet_prefix * dst, char *arg, int family) { if (family == AF_PACKET) { - error_msg_and_die("\"%s\" may be inet address, but it is not allowed in this context.", arg); + bb_error_msg_and_die("\"%s\" may be inet address, but it is not allowed in this context.", arg); } if (get_addr_1(dst, arg, family)) { - error_msg_and_die("an inet address is expected rather than \"%s\".", arg); + bb_error_msg_and_die("an inet address is expected rather than \"%s\".", arg); } return 0; } @@ -220,10 +220,10 @@ int get_addr(inet_prefix * dst, char *arg, int family) int get_prefix(inet_prefix * dst, char *arg, int family) { if (family == AF_PACKET) { - error_msg_and_die("\"%s\" may be inet address, but it is not allowed in this context.", arg); + bb_error_msg_and_die("\"%s\" may be inet address, but it is not allowed in this context.", arg); } if (get_prefix_1(dst, arg, family)) { - error_msg_and_die("an inet address is expected rather than \"%s\".", arg); + bb_error_msg_and_die("an inet address is expected rather than \"%s\".", arg); } return 0; } @@ -233,32 +233,32 @@ __u32 get_addr32(char *name) inet_prefix addr; if (get_addr_1(&addr, name, AF_INET)) { - error_msg_and_die("an IP address is expected rather than \"%s\"", name); + bb_error_msg_and_die("an IP address is expected rather than \"%s\"", name); } return addr.data[0]; } void incomplete_command() { - error_msg("Command line is not complete. Try option \"help\""); + bb_error_msg("Command line is not complete. Try option \"help\""); exit(-1); } void invarg(char *msg, char *arg) { - error_msg("argument \"%s\" is wrong: %s", arg, msg); + bb_error_msg("argument \"%s\" is wrong: %s", arg, msg); exit(-1); } void duparg(char *key, char *arg) { - error_msg("duplicate \"%s\": \"%s\" is the second value.", key, arg); + bb_error_msg("duplicate \"%s\": \"%s\" is the second value.", key, arg); exit(-1); } void duparg2(char *key, char *arg) { - error_msg("either \"%s\" is duplicate, or \"%s\" is a garbage.", key, arg); + bb_error_msg("either \"%s\" is duplicate, or \"%s\" is a garbage.", key, arg); exit(-1); } diff --git a/networking/nameif.c b/networking/nameif.c index f3b9271..e74a042 100644 --- a/networking/nameif.c +++ b/networking/nameif.c @@ -63,11 +63,11 @@ static void serror(const char *s, ...) va_start(ap, s); if (use_syslog) { - openlog(applet_name, 0, LOG_LOCAL0); + openlog(bb_applet_name, 0, LOG_LOCAL0); vsyslog(LOG_ERR, s, ap); closelog(); } else { - verror_msg(s, ap); + bb_verror_msg(s, ap); putc('\n', stderr); } @@ -111,12 +111,12 @@ int nameif_main(int argc, char **argv) use_syslog = 1; break; default: - show_usage(); + bb_show_usage(); } } if ((argc - optind) & 1) - show_usage(); + bb_show_usage(); if (optind < argc) { char **a = argv + optind; @@ -126,7 +126,7 @@ int nameif_main(int argc, char **argv) if (strlen(*a) > IF_NAMESIZE) serror("interface name `%s' too long", *a); ch = xcalloc(1, sizeof(mactable_t)); - ch->ifname = xstrdup(*a++); + ch->ifname = bb_xstrdup(*a++); ch->mac = cc_macaddr(*a++); if (clist) clist->prev = ch; @@ -134,9 +134,9 @@ int nameif_main(int argc, char **argv) clist = ch; } } else { - ifh = xfopen(fname, "r"); + ifh = bb_xfopen(fname, "r"); - while ((line = get_line_from_file(ifh)) != NULL) { + while ((line = bb_get_line_from_file(ifh)) != NULL) { char *line_ptr; size_t name_length; @@ -145,7 +145,7 @@ int nameif_main(int argc, char **argv) continue; name_length = strcspn(line_ptr, " \t"); ch = xcalloc(1, sizeof(mactable_t)); - ch->ifname = xstrndup(line_ptr, name_length); + ch->ifname = bb_xstrndup(line_ptr, name_length); if (name_length > IF_NAMESIZE) serror("interface name `%s' too long", ch->ifname); line_ptr += name_length; diff --git a/networking/nc.c b/networking/nc.c index 63d8c5b..4888ccc 100644 --- a/networking/nc.c +++ b/networking/nc.c @@ -72,7 +72,7 @@ int nc_main(int argc, char **argv) break; #endif default: - show_usage(); + bb_show_usage(); } } @@ -85,13 +85,13 @@ int nc_main(int argc, char **argv) if ((do_listen && optind != argc) || (!do_listen && optind + 2 != argc)) - show_usage(); + bb_show_usage(); if ((sfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) - perror_msg_and_die("socket"); + bb_perror_msg_and_die("socket"); x = 1; if (setsockopt (sfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x)) == -1) - perror_msg_and_die ("reuseaddr failed"); + bb_perror_msg_and_die ("reuseaddr failed"); address.sin_family = AF_INET; if (lport != 0) { @@ -99,17 +99,17 @@ int nc_main(int argc, char **argv) address.sin_port = htons(lport); if (bind(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) - perror_msg_and_die("bind"); + bb_perror_msg_and_die("bind"); } if (do_listen) { socklen_t addrlen = sizeof(address); if (listen(sfd, 1) < 0) - perror_msg_and_die("listen"); + bb_perror_msg_and_die("listen"); if ((tmpfd = accept(sfd, (struct sockaddr *) &address, &addrlen)) < 0) - perror_msg_and_die("accept"); + bb_perror_msg_and_die("accept"); close(sfd); sfd = tmpfd; @@ -120,7 +120,7 @@ int nc_main(int argc, char **argv) address.sin_port = htons(atoi(argv[optind+1])); if (connect(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) - perror_msg_and_die("connect"); + bb_perror_msg_and_die("connect"); } #ifdef GAPING_SECURITY_HOLE @@ -149,12 +149,12 @@ int nc_main(int argc, char **argv) testfds = readfds; if (select(FD_SETSIZE, &testfds, NULL, NULL, NULL) < 0) - perror_msg_and_die("select"); + bb_perror_msg_and_die("select"); for (fd = 0; fd < FD_SETSIZE; fd++) { if (FD_ISSET(fd, &testfds)) { if ((nread = safe_read(fd, buf, sizeof(buf))) < 0) - perror_msg_and_die("read"); + bb_perror_msg_and_die("read"); if (fd == sfd) { if (nread == 0) @@ -166,8 +166,8 @@ int nc_main(int argc, char **argv) ofd = sfd; } - if (full_write(ofd, buf, nread) < 0) - perror_msg_and_die("write"); + if (bb_full_write(ofd, buf, nread) < 0) + bb_perror_msg_and_die("write"); if (delay > 0) { sleep(delay); } diff --git a/networking/netstat.c b/networking/netstat.c index d2b2d5e..17a5887 100644 --- a/networking/netstat.c +++ b/networking/netstat.c @@ -200,7 +200,7 @@ static void tcp_do_one(int lnr, const char *line) } if (num < 10) { - error_msg("warning, got bogus tcp line."); + bb_error_msg("warning, got bogus tcp line."); return; } state_str = tcp_state[state]; @@ -271,7 +271,7 @@ static void udp_do_one(int lnr, const char *line) } if (num < 10) { - error_msg("warning, got bogus udp line."); + bb_error_msg("warning, got bogus udp line."); return; } switch (state) { @@ -365,7 +365,7 @@ static void raw_do_one(int lnr, const char *line) } if (num < 10) { - error_msg("warning, got bogus raw line."); + bb_error_msg("warning, got bogus raw line."); return; } state_str=itoa(state); @@ -418,7 +418,7 @@ static void unix_do_one(int nr, const char *line) num = sscanf(line, "%p: %lX %lX %lX %X %X %d %s", &d, &refcnt, &proto, &unix_flags, &type, &state, &inode, path); if (num < 6) { - error_msg("warning, got bogus unix line."); + bb_error_msg("warning, got bogus unix line."); return; } if (!(has & HAS_INODE)) @@ -539,7 +539,7 @@ static void do_info(const char *file, const char *name, void (*proc)(int, const if (errno != ENOENT) { perror(file); } else { - error_msg("no support for `%s' on this system.", name); + bb_error_msg("no support for `%s' on this system.", name); } } else { do { @@ -597,14 +597,14 @@ int netstat_main(int argc, char **argv) new_flags |= NETSTAT_UNIX; break; default: - show_usage(); + bb_show_usage(); } if ( showroute ) { #ifdef CONFIG_ROUTE displayroutes ( flags & NETSTAT_NUMERIC, !extended ); return 0; #else - error_msg_and_die( "-r (display routing table) is not compiled in." ); + bb_error_msg_and_die( "-r (display routing table) is not compiled in." ); #endif } diff --git a/networking/nslookup.c b/networking/nslookup.c index edbc656..0f3102e 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c @@ -185,7 +185,7 @@ int nslookup_main(int argc, char **argv) */ if (argc < 2 || *argv[1]=='-' || argc > 3) - show_usage(); + bb_show_usage(); else if(argc == 3) set_default_dns(argv[2]); @@ -199,4 +199,4 @@ int nslookup_main(int argc, char **argv) return EXIT_SUCCESS; } -/* $Id: nslookup.c,v 1.29 2002/07/24 00:56:56 sandman Exp $ */ +/* $Id: nslookup.c,v 1.30 2003/03/19 09:12:38 mjn3 Exp $ */ diff --git a/networking/ping.c b/networking/ping.c index 044b547..28b38db 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -1,6 +1,6 @@ /* vi: set sw=4 ts=4: */ /* - * $Id: ping.c,v 1.53 2003/01/12 06:08:33 andersen Exp $ + * $Id: ping.c,v 1.54 2003/03/19 09:12:38 mjn3 Exp $ * Mini ping implementation for busybox * * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> @@ -208,7 +208,7 @@ static void ping(const char *host) (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); if (c < 0 || c != sizeof(packet)) - perror_msg_and_die("sendto"); + bb_perror_msg_and_die("sendto"); signal(SIGALRM, noresp); alarm(5); /* give the host 5000ms to respond */ @@ -221,7 +221,7 @@ static void ping(const char *host) (struct sockaddr *) &from, &fromlen)) < 0) { if (errno == EINTR) continue; - perror_msg("recvfrom"); + bb_perror_msg("recvfrom"); continue; } if (c >= 76) { /* ip + icmp */ @@ -241,7 +241,7 @@ extern int ping_main(int argc, char **argv) argc--; argv++; if (argc < 1) - show_usage(); + bb_show_usage(); ping(*argv); return EXIT_SUCCESS; } @@ -313,9 +313,9 @@ static void sendping(int junk) (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); if (i < 0) - perror_msg_and_die("sendto"); + bb_perror_msg_and_die("sendto"); else if ((size_t)i != sizeof(packet)) - error_msg_and_die("ping wrote %d chars; %d expected", i, + bb_error_msg_and_die("ping wrote %d chars; %d expected", i, (int)sizeof(packet)); signal(SIGALRM, sendping); @@ -410,7 +410,7 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from) printf("\n"); } else if (icmppkt->icmp_type != ICMP_ECHO) - error_msg("Warning: Got ICMP %d (%s)", + bb_error_msg("Warning: Got ICMP %d (%s)", icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type)); } @@ -426,7 +426,7 @@ static void ping(const char *host) pingaddr.sin_family = AF_INET; hostent = xgethostbyname(host); if (hostent->h_addrtype != AF_INET) - error_msg_and_die("unknown address type; only AF_INET is currently supported."); + bb_error_msg_and_die("unknown address type; only AF_INET is currently supported."); memcpy(&pingaddr.sin_addr, hostent->h_addr, sizeof(pingaddr.sin_addr)); @@ -460,7 +460,7 @@ static void ping(const char *host) (struct sockaddr *) &from, &fromlen)) < 0) { if (errno == EINTR) continue; - perror_msg("recvfrom"); + bb_perror_msg("recvfrom"); continue; } unpack(packet, c, &from); @@ -489,24 +489,24 @@ extern int ping_main(int argc, char **argv) break; case 'c': if (--argc <= 0) - show_usage(); + bb_show_usage(); argv++; pingcount = atoi(*argv); break; case 's': if (--argc <= 0) - show_usage(); + bb_show_usage(); argv++; datalen = atoi(*argv); break; default: - show_usage(); + bb_show_usage(); } argc--; argv++; } if (argc < 1) - show_usage(); + bb_show_usage(); myid = getpid() & 0xFFFF; ping(*argv); diff --git a/networking/ping6.c b/networking/ping6.c index f1ccff4..c406242 100644 --- a/networking/ping6.c +++ b/networking/ping6.c @@ -1,6 +1,6 @@ /* vi: set sw=4 ts=4: */ /* - * $Id: ping6.c,v 1.3 2003/01/12 06:08:33 andersen Exp $ + * $Id: ping6.c,v 1.4 2003/03/19 09:12:38 mjn3 Exp $ * Mini ping implementation for busybox * * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> @@ -112,7 +112,7 @@ static void ping(const char *host) (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in6)); if (c < 0 || c != sizeof(packet)) - perror_msg_and_die("sendto"); + bb_perror_msg_and_die("sendto"); signal(SIGALRM, noresp); alarm(5); /* give the host 5000ms to respond */ @@ -125,7 +125,7 @@ static void ping(const char *host) (struct sockaddr *) &from, &fromlen)) < 0) { if (errno == EINTR) continue; - perror_msg("recvfrom"); + bb_perror_msg("recvfrom"); continue; } if (c >= 8) { /* icmp6_hdr */ @@ -143,7 +143,7 @@ extern int ping6_main(int argc, char **argv) argc--; argv++; if (argc < 1) - show_usage(); + bb_show_usage(); ping(*argv); return EXIT_SUCCESS; } @@ -218,9 +218,9 @@ static void sendping(int junk) (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in6)); if (i < 0) - perror_msg_and_die("sendto"); + bb_perror_msg_and_die("sendto"); else if ((size_t)i != sizeof(packet)) - error_msg_and_die("ping wrote %d chars; %d expected", i, + bb_error_msg_and_die("ping wrote %d chars; %d expected", i, (int)sizeof(packet)); signal(SIGALRM, sendping); @@ -308,7 +308,7 @@ static void unpack(char *packet, int sz, struct sockaddr_in6 *from, int hoplimit printf("\n"); } else if (icmppkt->icmp6_type != ICMP6_ECHO_REQUEST) - error_msg("Warning: Got ICMP %d (%s)", + bb_error_msg("Warning: Got ICMP %d (%s)", icmppkt->icmp6_type, icmp6_type_name (icmppkt->icmp6_type)); } @@ -329,7 +329,7 @@ static void ping(const char *host) pingaddr.sin6_family = AF_INET6; hostent = xgethostbyname2(host, AF_INET6); if (hostent->h_addrtype != AF_INET6) - error_msg_and_die("unknown address type; only AF_INET6 is currently supported."); + bb_error_msg_and_die("unknown address type; only AF_INET6 is currently supported."); memcpy(&pingaddr.sin6_addr, hostent->h_addr, sizeof(pingaddr.sin6_addr)); @@ -350,7 +350,7 @@ static void ping(const char *host) } if (setsockopt(pingsock, IPPROTO_ICMPV6, ICMP6_FILTER, &filt, sizeof(filt)) < 0) - error_msg_and_die("setsockopt(ICMP6_FILTER)"); + bb_error_msg_and_die("setsockopt(ICMP6_FILTER)"); } #endif /*ICMP6_FILTER*/ @@ -374,7 +374,7 @@ static void ping(const char *host) if (ifname) { if ((pingaddr.sin6_scope_id = if_nametoindex(ifname)) == 0) - error_msg_and_die("%s: invalid interface name", ifname); + bb_error_msg_and_die("%s: invalid interface name", ifname); } printf("PING %s (%s): %d data bytes\n", @@ -405,7 +405,7 @@ static void ping(const char *host) if ((c = recvmsg(pingsock, &msg, 0)) < 0) { if (errno == EINTR) continue; - perror_msg("recvfrom"); + bb_perror_msg("recvfrom"); continue; } for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL; @@ -446,30 +446,30 @@ extern int ping6_main(int argc, char **argv) break; case 'c': if (--argc <= 0) - show_usage(); + bb_show_usage(); argv++; pingcount = atoi(*argv); break; case 's': if (--argc <= 0) - show_usage(); + bb_show_usage(); argv++; datalen = atoi(*argv); break; case 'I': if (--argc <= 0) - show_usage(); + bb_show_usage(); argv++; ifname = *argv; break; default: - show_usage(); + bb_show_usage(); } argc--; argv++; } if (argc < 1) - show_usage(); + bb_show_usage(); myid = getpid() & 0xFFFF; ping(*argv); diff --git a/networking/route.c b/networking/route.c index b564c6d..083149a 100644 --- a/networking/route.c +++ b/networking/route.c @@ -15,7 +15,7 @@ * Foundation; either version 2 of the License, or (at * your option) any later version. * - * $Id: route.c,v 1.21 2002/12/16 22:04:18 sandman Exp $ + * $Id: route.c,v 1.22 2003/03/19 09:12:39 mjn3 Exp $ * * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru> * adjustments by Larry Doolittle <LRDoolittle@lbl.gov> @@ -88,7 +88,7 @@ static int INET_setroute(int action, int options, char **args) xflag = 0; if (*args == NULL) - show_usage(); + bb_show_usage(); if (strcmp(*args, "-net") == 0) { xflag = 1; args++; @@ -97,7 +97,7 @@ static int INET_setroute(int action, int options, char **args) args++; } if (*args == NULL) - show_usage(); + bb_show_usage(); safe_strncpy(target, *args++, (sizeof target)); /* Clean out the RTREQ structure. */ @@ -107,7 +107,7 @@ static int INET_setroute(int action, int options, char **args) if ((isnet = INET_resolve(target, (struct sockaddr_in *) &rt.rt_dst, xflag != 1)) < 0) { - error_msg(_("can't resolve %s"), target); + bb_error_msg(_("can't resolve %s"), target); return EXIT_FAILURE; /* XXX change to E_something */ } @@ -135,7 +135,7 @@ static int INET_setroute(int action, int options, char **args) args++; if (!*args || !isdigit(**args)) - show_usage(); + bb_show_usage(); metric = atoi(*args); #if HAVE_NEW_ADDRT rt.rt_metric = metric + 1; @@ -151,12 +151,12 @@ static int INET_setroute(int action, int options, char **args) args++; if (!*args || mask_in_addr(rt)) - show_usage(); + bb_show_usage(); netmask = *args; if ((isnet = INET_resolve(netmask, (struct sockaddr_in *) &mask, 0)) < 0) { - error_msg(_("can't resolve netmask %s"), netmask); + bb_error_msg(_("can't resolve netmask %s"), netmask); return E_LOOKUP; } rt.rt_genmask = full_mask(mask); @@ -167,18 +167,18 @@ static int INET_setroute(int action, int options, char **args) if (strcmp(*args, "gw") == 0 || strcmp(*args, "gateway") == 0) { args++; if (!*args) - show_usage(); + bb_show_usage(); if (rt.rt_flags & RTF_GATEWAY) - show_usage(); + bb_show_usage(); safe_strncpy(gateway, *args, (sizeof gateway)); if ((isnet = INET_resolve(gateway, (struct sockaddr_in *) &rt.rt_gateway, 1)) < 0) { - error_msg(_("can't resolve gw %s"), gateway); + bb_error_msg(_("can't resolve gw %s"), gateway); return E_LOOKUP; } if (isnet) { - error_msg(_("%s: cannot use a NETWORK as gateway!"), gateway); + bb_error_msg(_("%s: cannot use a NETWORK as gateway!"), gateway); return E_OPTERR; } rt.rt_flags |= RTF_GATEWAY; @@ -190,11 +190,11 @@ static int INET_setroute(int action, int options, char **args) args++; rt.rt_flags |= RTF_MSS; if (!*args) - show_usage(); + bb_show_usage(); rt.rt_mss = atoi(*args); args++; if (rt.rt_mss < 64 || rt.rt_mss > 32768) { - error_msg(_("Invalid MSS.")); + bb_error_msg(_("Invalid MSS.")); return E_OPTERR; } continue; @@ -203,12 +203,12 @@ static int INET_setroute(int action, int options, char **args) if (strcmp(*args, "window") == 0) { args++; if (!*args) - show_usage(); + bb_show_usage(); rt.rt_flags |= RTF_WINDOW; rt.rt_window = atoi(*args); args++; if (rt.rt_window < 128) { - error_msg(_("Invalid window.")); + bb_error_msg(_("Invalid window.")); return E_OPTERR; } continue; @@ -217,7 +217,7 @@ static int INET_setroute(int action, int options, char **args) if (strcmp(*args, "irtt") == 0) { args++; if (!*args) - show_usage(); + bb_show_usage(); args++; #if HAVE_RTF_IRTT rt.rt_flags |= RTF_IRTT; @@ -225,7 +225,7 @@ static int INET_setroute(int action, int options, char **args) rt.rt_irtt *= (sysconf(_SC_CLK_TCK) / 100); /* FIXME */ #if 0 /* FIXME: do we need to check anything of this? */ if (rt.rt_irtt < 1 || rt.rt_irtt > (120 * HZ)) { - error_msg(_("Invalid initial rtt.")); + bb_error_msg(_("Invalid initial rtt.")); return E_OPTERR; } #endif @@ -262,7 +262,7 @@ static int INET_setroute(int action, int options, char **args) if (strcmp(*args, "device") == 0 || strcmp(*args, "dev") == 0) { args++; if (rt.rt_dev || *args == NULL) - show_usage(); + bb_show_usage(); rt.rt_dev = *args++; continue; } @@ -270,9 +270,9 @@ static int INET_setroute(int action, int options, char **args) if (!rt.rt_dev) { rt.rt_dev = *args++; if (*args) - show_usage(); /* must be last to catch typos */ + bb_show_usage(); /* must be last to catch typos */ } else { - show_usage(); + bb_show_usage(); } } @@ -287,17 +287,17 @@ static int INET_setroute(int action, int options, char **args) mask = ~ntohl(mask); if ((rt.rt_flags & RTF_HOST) && mask != 0xffffffff) { - error_msg(_("netmask %.8x doesn't make sense with host route"), + bb_error_msg(_("netmask %.8x doesn't make sense with host route"), (unsigned int) mask); return E_OPTERR; } if (mask & (mask + 1)) { - error_msg(_("bogus netmask %s"), netmask); + bb_error_msg(_("bogus netmask %s"), netmask); return E_OPTERR; } mask = ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr; if (mask & ~mask_in_addr(rt)) { - error_msg(_("netmask doesn't match route address")); + bb_error_msg(_("netmask doesn't match route address")); return E_OPTERR; } } @@ -343,7 +343,7 @@ static int INET6_setroute(int action, int options, char **args) int skfd; if (*args == NULL) - show_usage(); + bb_show_usage(); strcpy(target, *args++); if (!strcmp(target, "default")) { @@ -353,13 +353,13 @@ static int INET6_setroute(int action, int options, char **args) if ((cp = strchr(target, '/'))) { prefix_len = atol(cp + 1); if ((prefix_len < 0) || (prefix_len > 128)) - show_usage(); + bb_show_usage(); *cp = 0; } else { prefix_len = 128; } if (INET6_resolve(target, (struct sockaddr_in6 *) &sa6) < 0) { - error_msg(_("can't resolve %s"), target); + bb_error_msg(_("can't resolve %s"), target); return EXIT_FAILURE; /* XXX change to E_something */ } } @@ -381,7 +381,7 @@ static int INET6_setroute(int action, int options, char **args) args++; if (!*args || !isdigit(**args)) - show_usage(); + bb_show_usage(); metric = atoi(*args); rt.rtmsg_metric = metric; args++; @@ -390,12 +390,12 @@ static int INET6_setroute(int action, int options, char **args) if (!strcmp(*args, "gw") || !strcmp(*args, "gateway")) { args++; if (!*args) - show_usage(); + bb_show_usage(); if (rt.rtmsg_flags & RTF_GATEWAY) - show_usage(); + bb_show_usage(); strcpy(gateway, *args); if (INET6_resolve(gateway, (struct sockaddr_in6 *) &sa6) < 0) { - error_msg(_("can't resolve gw %s"), gateway); + bb_error_msg(_("can't resolve gw %s"), gateway); return (E_LOOKUP); } memcpy(&rt.rtmsg_gateway, sa6.sin6_addr.s6_addr, @@ -417,9 +417,9 @@ static int INET6_setroute(int action, int options, char **args) if (!strcmp(*args, "device") || !strcmp(*args, "dev")) { args++; if (!*args) - show_usage(); + bb_show_usage(); } else if (args[1]) - show_usage(); + bb_show_usage(); devname = *args; args++; @@ -493,7 +493,7 @@ void displayroutes(int noresolve, int netstatfmt) char sdest[16], sgw[16]; - FILE *fp = xfopen("/proc/net/route", "r"); + FILE *fp = bb_xfopen("/proc/net/route", "r"); if (noresolve) noresolve = 0x0fff; @@ -515,7 +515,7 @@ void displayroutes(int noresolve, int netstatfmt) if (sscanf(buff + ifl + 1, "%lx%lx%X%d%d%d%lx%d%d%d", &d, &g, &flgs, &ref, &use, &metric, &m, &mtu, &win, &ir) != 10) { - error_msg_and_die("Unsuported kernel route format\n"); + bb_error_msg_and_die("Unsuported kernel route format\n"); } ifl = 0; /* parse flags */ if (flgs & RTF_UP) { @@ -570,7 +570,7 @@ static void INET6_displayroutes(int noresolve) char addr6p[8][5], saddr6p[8][5], naddr6p[8][5]; - FILE *fp = xfopen("/proc/net/ipv6_route", "r"); + FILE *fp = bb_xfopen("/proc/net/ipv6_route", "r"); flags[0] = 'U'; @@ -598,7 +598,7 @@ static void INET6_displayroutes(int noresolve) naddr6p[0], naddr6p[1], naddr6p[2], naddr6p[3], naddr6p[4], naddr6p[5], naddr6p[6], naddr6p[7], &metric, &use, &refcnt, &iflags, iface) != 31) { - error_msg_and_die("Unsuported kernel route format\n"); + bb_error_msg_and_die("Unsuported kernel route format\n"); } ifl = 1; /* parse flags */ @@ -673,7 +673,7 @@ int route_main(int argc, char **argv) break; #endif default: - show_usage(); + bb_show_usage(); } } @@ -694,7 +694,7 @@ int route_main(int argc, char **argv) else if (strcmp(argv[1], "flush") == 0) what = RTACTION_FLUSH; else - show_usage(); + bb_show_usage(); } #ifdef CONFIG_FEATURE_IPV6 diff --git a/networking/telnet.c b/networking/telnet.c index 0c794b6..8f2573c 100644 --- a/networking/telnet.c +++ b/networking/telnet.c @@ -604,7 +604,7 @@ extern int telnet_main(int argc, char** argv) G.termios_raw = G.termios_def; cfmakeraw(&G.termios_raw); - if (argc < 2) show_usage(); + if (argc < 2) bb_show_usage(); port = (argc > 2)? argv[2] : "23"; host = argv[1]; diff --git a/networking/telnetd.c b/networking/telnetd.c index 8634a42..077194c 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c @@ -1,4 +1,4 @@ -/* $Id: telnetd.c,v 1.4 2003/01/22 21:09:48 bug1 Exp $ +/* $Id: telnetd.c,v 1.5 2003/03/19 09:12:39 mjn3 Exp $ * * Simple telnet server * Bjorn Wesen, Axis Communications AB (bjornw@axis.com) @@ -380,12 +380,12 @@ telnetd_main(int argc, char **argv) break; #endif /* CONFIG_FEATURE_TELNETD_INETD */ default: - show_usage(); + bb_show_usage(); } } if (access(loginpath, X_OK) < 0) { - error_msg_and_die ("'%s' unavailable.", loginpath); + bb_error_msg_and_die ("'%s' unavailable.", loginpath); } argv_init[0] = loginpath; @@ -400,7 +400,7 @@ telnetd_main(int argc, char **argv) master_fd = socket(AF_INET, SOCK_STREAM, 0); if (master_fd < 0) { - perror_msg_and_die("socket"); + bb_perror_msg_and_die("socket"); } (void)setsockopt(master_fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); @@ -411,15 +411,15 @@ telnetd_main(int argc, char **argv) sa.sin_port = htons(portnbr); if (bind(master_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) { - perror_msg_and_die("bind"); + bb_perror_msg_and_die("bind"); } if (listen(master_fd, 1) < 0) { - perror_msg_and_die("listen"); + bb_perror_msg_and_die("listen"); } if (daemon(0, 0) < 0) - perror_msg_and_die("daemon"); + bb_perror_msg_and_die("daemon"); maxfd = master_fd; diff --git a/networking/tftp.c b/networking/tftp.c index 378ba2f..a33b5c2 100644 --- a/networking/tftp.c +++ b/networking/tftp.c @@ -60,7 +60,7 @@ #define TFTP_ERROR 5 #define TFTP_OACK 6 -static const char *tftp_error_msg[] = { +static const char *tftp_bb_error_msg[] = { "Undefined error", "File not found", "Access violation", @@ -86,7 +86,7 @@ static int tftp_blocksize_check(int blocksize, int bufsize) if ((bufsize && (blocksize > bufsize)) || (blocksize < 8) || (blocksize > 65464)) { - error_msg("bad blocksize"); + bb_error_msg("bad blocksize"); return 0; } @@ -169,7 +169,7 @@ static inline int tftp(const int cmd, const struct hostent *host, tftp_bufsize += 4; if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { - perror_msg("socket"); + bb_perror_msg("socket"); return EXIT_FAILURE; } @@ -223,7 +223,7 @@ static inline int tftp(const int cmd, const struct hostent *host, } if (too_long || ((&buf[tftp_bufsize - 1] - cp) < 6)) { - error_msg("too long remote-filename"); + bb_error_msg("too long remote-filename"); break; } @@ -239,7 +239,7 @@ static inline int tftp(const int cmd, const struct hostent *host, if (len != TFTP_BLOCKSIZE_DEFAULT) { if ((&buf[tftp_bufsize - 1] - cp) < 15) { - error_msg("too long remote-filename"); + bb_error_msg("too long remote-filename"); break; } @@ -270,7 +270,7 @@ static inline int tftp(const int cmd, const struct hostent *host, len = read(localfd, cp, tftp_bufsize - 4); if (len < 0) { - perror_msg("read"); + bb_perror_msg("read"); break; } @@ -298,7 +298,7 @@ static inline int tftp(const int cmd, const struct hostent *host, #endif if (sendto(socketfd, buf, len, 0, (struct sockaddr *) &sa, sizeof(sa)) < 0) { - perror_msg("send"); + bb_perror_msg("send"); len = -1; break; } @@ -325,7 +325,7 @@ static inline int tftp(const int cmd, const struct hostent *host, (struct sockaddr *) &from, &fromlen); if (len < 0) { - perror_msg("recvfrom"); + bb_perror_msg("recvfrom"); break; } @@ -343,18 +343,18 @@ static inline int tftp(const int cmd, const struct hostent *host, timeout = bb_tftp_num_retries; case 0: - error_msg("timeout"); + bb_error_msg("timeout"); if (timeout == 0) { len = -1; - error_msg("last timeout"); + bb_error_msg("last timeout"); } else { timeout--; } break; default: - perror_msg("select"); + bb_perror_msg("select"); len = -1; } @@ -380,14 +380,14 @@ static inline int tftp(const int cmd, const struct hostent *host, if (buf[4] != '\0') { msg = &buf[4]; buf[tftp_bufsize - 1] = '\0'; - } else if (tmp < (sizeof(tftp_error_msg) + } else if (tmp < (sizeof(tftp_bb_error_msg) / sizeof(char *))) { - msg = (char *) tftp_error_msg[tmp]; + msg = (char *) tftp_bb_error_msg[tmp]; } if (msg) { - error_msg("server says: %s", msg); + bb_error_msg("server says: %s", msg); } break; @@ -429,11 +429,11 @@ static inline int tftp(const int cmd, const struct hostent *host, } /* FIXME: * we should send ERROR 8 */ - error_msg("bad server option"); + bb_error_msg("bad server option"); break; } - error_msg("warning: blksize not supported by server" + bb_error_msg("warning: blksize not supported by server" " - reverting to 512"); tftp_bufsize = TFTP_BLOCKSIZE_DEFAULT + 4; @@ -447,7 +447,7 @@ static inline int tftp(const int cmd, const struct hostent *host, len = write(localfd, &buf[4], len - 4); if (len < 0) { - perror_msg("write"); + bb_perror_msg("write"); break; } @@ -538,16 +538,16 @@ int tftp_main(int argc, char **argv) break; #endif case 'l': - localfile = xstrdup(optarg); + localfile = bb_xstrdup(optarg); break; case 'r': - remotefile = xstrdup(optarg); + remotefile = bb_xstrdup(optarg); break; } } if ((cmd == 0) || (optind == argc)) { - show_usage(); + bb_show_usage(); } if(localfile && strcmp(localfile, "-") == 0) { fd = fileno((cmd==tftp_cmd_get)? stdout : stdin); @@ -560,7 +560,7 @@ int tftp_main(int argc, char **argv) fd = open(localfile, flags, 0644); } if (fd < 0) { - perror_msg_and_die("local file"); + bb_perror_msg_and_die("local file"); } host = xgethostbyname(argv[optind]); diff --git a/networking/traceroute.c b/networking/traceroute.c index a9cad4b..be9ea1d 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -448,7 +448,7 @@ traceroute_main(int argc, char *argv[]) case 'm': max_ttl = atoi(optarg); if (max_ttl <= 1) - error_msg_and_die("max ttl must be >1."); + bb_error_msg_and_die("max ttl must be >1."); break; case 'n': nflag++; @@ -456,12 +456,12 @@ traceroute_main(int argc, char *argv[]) case 'p': port = atoi(optarg); if (port < 1) - error_msg_and_die("port must be >0."); + bb_error_msg_and_die("port must be >0."); break; case 'q': nprobes = atoi(optarg); if (nprobes < 1) - error_msg_and_die("nprobes must be >0."); + bb_error_msg_and_die("nprobes must be >0."); break; case 'r': options |= SO_DONTROUTE; @@ -476,7 +476,7 @@ traceroute_main(int argc, char *argv[]) case 't': tos = atoi(optarg); if (tos < 0 || tos > 255) - error_msg_and_die("tos must be 0 to 255."); + bb_error_msg_and_die("tos must be 0 to 255."); break; case 'v': #ifdef CONFIG_FEATURE_TRACEROUTE_VERBOSE @@ -486,16 +486,16 @@ traceroute_main(int argc, char *argv[]) case 'w': waittime = atoi(optarg); if (waittime <= 1) - error_msg_and_die("wait must be >1 sec."); + bb_error_msg_and_die("wait must be >1 sec."); break; default: - show_usage(); + bb_show_usage(); } argc -= optind; argv += optind; if (argc < 1) - show_usage(); + bb_show_usage(); setlinebuf (stdout); @@ -507,7 +507,7 @@ traceroute_main(int argc, char *argv[]) if (*++argv) datalen = atoi(*argv); if (datalen < 0 || datalen >= MAXPACKET - sizeof(struct opacket)) - error_msg_and_die("packet size must be 0 <= s < %d.", + bb_error_msg_and_die("packet size must be 0 <= s < %d.", MAXPACKET - sizeof(struct opacket)); datalen += sizeof(struct opacket); outpacket = (struct opacket *)xmalloc((unsigned)datalen); @@ -520,7 +520,7 @@ traceroute_main(int argc, char *argv[]) ident = (getpid() & 0xffff) | 0x8000; if ((sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) - perror_msg_and_die(can_not_create_raw_socket); + bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket); s = create_icmp_socket(); @@ -535,12 +535,12 @@ traceroute_main(int argc, char *argv[]) #ifdef SO_SNDBUF if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&datalen, sizeof(datalen)) < 0) - perror_msg_and_die("SO_SNDBUF"); + bb_perror_msg_and_die("SO_SNDBUF"); #endif #ifdef IP_HDRINCL if (setsockopt(sndsock, IPPROTO_IP, IP_HDRINCL, (char *)&on, sizeof(on)) < 0) - perror_msg_and_die("IP_HDRINCL"); + bb_perror_msg_and_die("IP_HDRINCL"); #endif #ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG if (options & SO_DEBUG) @@ -556,11 +556,11 @@ traceroute_main(int argc, char *argv[]) from.sin_family = AF_INET; from.sin_addr.s_addr = inet_addr(source); if (from.sin_addr.s_addr == -1) - error_msg_and_die("unknown host %s", source); + bb_error_msg_and_die("unknown host %s", source); outpacket->ip.ip_src = from.sin_addr; #ifndef IP_HDRINCL if (bind(sndsock, (struct sockaddr *)&from, sizeof(from)) < 0) - perror_msg_and_die("bind"); + bb_perror_msg_and_die("bind"); #endif } diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index fdcd17f..c97e422 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -81,7 +81,7 @@ struct client_config_t client_config = { }; #ifndef IN_BUSYBOX -static void __attribute__ ((noreturn)) show_usage(void) +static void __attribute__ ((noreturn)) bb_show_usage(void) { printf( "Usage: udhcpc [OPTIONS]\n\n" @@ -104,7 +104,7 @@ static void __attribute__ ((noreturn)) show_usage(void) exit(0); } #else -extern void show_usage(void) __attribute__ ((noreturn)); +extern void bb_show_usage(void) __attribute__ ((noreturn)); #endif @@ -298,7 +298,7 @@ int main(int argc, char *argv[]) exit_client(0); break; default: - show_usage(); + bb_show_usage(); } } diff --git a/networking/vconfig.c b/networking/vconfig.c index 3bd9c30..d58c375 100644 --- a/networking/vconfig.c +++ b/networking/vconfig.c @@ -1,3 +1,27 @@ +/* vi: set sw=4 ts=4: */ +/* + * vconfig implementation for busybox + * + * Copyright (C) 2001 Manuel Novoa III <mjn3@codepoet.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* BB_AUDIT SUSv3 N/A */ + #include <stdlib.h> #include <unistd.h> #include <fcntl.h> @@ -11,29 +35,14 @@ #define VLAN_GROUP_ARRAY_LEN 4096 #define SIOCSIFVLAN 0x8983 /* Set 802.1Q VLAN options */ -/* This is rather specialized in that we're passing a 'char **' in - * order to avoid the pointer dereference multiple times in the - * actual calls below. */ -static unsigned long xstrtoul10(char **str, unsigned long max_val) -{ - char *endptr; - unsigned long r; - - r = strtoul(str[2], &endptr, 10); - if ((r > max_val) || (*endptr != 0)) { - show_usage(); - } - return r; -} - /* On entry, table points to the length of the current string plus - * nul terminator plus data lenght for the subsequent entry. The + * nul terminator plus data length for the subsequent entry. The * return value is the last data entry for the matching string. */ static const char *xfind_str(const char *table, const char *str) { while (strcasecmp(str, table+1) != 0) { if (!*(table += table[0])) { - show_usage(); + bb_show_usage(); } } return table - 1; @@ -89,12 +98,12 @@ int vconfig_main(int argc, char **argv) int fd; if (argc < 3) { - show_usage(); + bb_show_usage(); } /* Don't bother closing the filedes. It will be closed on cleanup. */ if (open(conf_file_name, O_RDONLY) < 0) { /* Is 802.1q is present? */ - perror_msg_and_die("open %s", conf_file_name); + bb_perror_msg_and_die("open %s", conf_file_name); } memset(&ifr, 0, sizeof(struct vlan_ioctl_args)); @@ -103,16 +112,17 @@ int vconfig_main(int argc, char **argv) p = xfind_str(cmds+2, *argv); ifr.cmd = *p; if (argc != p[-1]) { - show_usage(); + bb_show_usage(); } if (ifr.cmd == SET_VLAN_NAME_TYPE_CMD) { /* set_name_type */ ifr.u.name_type = *xfind_str(name_types+1, argv[1]); } else { if (strlen(argv[1]) >= IF_NAMESIZE) { - error_msg_and_die("if_name >= %d chars\n", IF_NAMESIZE); + bb_error_msg_and_die("if_name >= %d chars\n", IF_NAMESIZE); } strcpy(ifr.device1, argv[1]); + p = argv[2]; /* I suppose one could try to combine some of the function calls below, * since ifr.u.flag, ifr.u.VID, and ifr.u.skb_priority are all same-sized @@ -120,19 +130,19 @@ int vconfig_main(int argc, char **argv) * doing so wouldn't save that much space and would also make maintainence * more of a pain. */ if (ifr.cmd == SET_VLAN_FLAG_CMD) { /* set_flag */ - ifr.u.flag = xstrtoul10(argv, 1); + ifr.u.flag = bb_xgetularg10_bnd(p, 0, 1); } else if (ifr.cmd == ADD_VLAN_CMD) { /* add */ - ifr.u.VID = xstrtoul10(argv, VLAN_GROUP_ARRAY_LEN-1); + ifr.u.VID = bb_xgetularg10_bnd(p, 0, VLAN_GROUP_ARRAY_LEN-1); } else if (ifr.cmd != DEL_VLAN_CMD) { /* set_{egress|ingress}_map */ - ifr.u.skb_priority = xstrtoul10(argv, ULONG_MAX); - ifr.vlan_qos = xstrtoul10(argv+1, 7); + ifr.u.skb_priority = bb_xgetularg10_bnd(p, 0, ULONG_MAX); + ifr.vlan_qos = bb_xgetularg10_bnd(argv[3], 0, 7); } } if (((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) || (ioctl(fd, SIOCSIFVLAN, &ifr) < 0) ) { - perror_msg_and_die("socket or ioctl error for %s", *argv); + bb_perror_msg_and_die("socket or ioctl error for %s", *argv); } return 0; diff --git a/networking/wget.c b/networking/wget.c index 7154faa..d68b165 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -123,7 +123,7 @@ static char *safe_fgets(char *s, int size, FILE *stream) #define close_delete_and_die(s...) { \ close_and_delete_outfile(output, fname_out, do_continue); \ - error_msg_and_die(s); } + bb_error_msg_and_die(s); } #ifdef CONFIG_FEATURE_WGET_AUTHENTICATION @@ -140,7 +140,7 @@ char *base64enc(char *p, char *buf, int len) { while(*p) { if (s >= buf+len-4) - error_msg_and_die("buffer overflow"); + bb_error_msg_and_die("buffer overflow"); *(s++) = al[(*p >> 2) & 0x3F]; *(s++) = al[((*p << 4) & 0x30) | ((*(p+1) >> 4) & 0x0F)]; *s = *(s+1) = '='; @@ -221,7 +221,7 @@ int wget_main(int argc, char **argv) case LONG_HEADER: { int arglen = strlen(optarg); if(extra_headers_left - arglen - 2 <= 0) - error_msg_and_die("extra_headers buffer too small(need %i)", extra_headers_left - arglen); + bb_error_msg_and_die("extra_headers buffer too small(need %i)", extra_headers_left - arglen); strcpy(extra_headers_ptr, optarg); extra_headers_ptr += arglen; extra_headers_left -= ( arglen + 2 ); @@ -236,12 +236,12 @@ int wget_main(int argc, char **argv) } break; default: - show_usage(); + bb_show_usage(); } } if (argc - optind != 1) - show_usage(); + bb_show_usage(); parse_url(argv[optind], &target); server.host = target.host; @@ -253,7 +253,7 @@ int wget_main(int argc, char **argv) if (!noproxy) { proxy = getenv(target.is_ftp ? "ftp_proxy" : "http_proxy"); if (proxy) - parse_url(xstrdup(proxy), &server); + parse_url(bb_xstrdup(proxy), &server); } /* Guess an output filename */ @@ -262,7 +262,7 @@ int wget_main(int argc, char **argv) #ifdef CONFIG_FEATURE_WGET_STATUSBAR curfile = #endif - get_last_path_component(target.path); + bb_get_last_path_component(target.path); if (fname_out==NULL || strlen(fname_out)<1) { fname_out = #ifdef CONFIG_FEATURE_WGET_STATUSBAR @@ -274,11 +274,11 @@ int wget_main(int argc, char **argv) fname_out = concat_path_file(dir_prefix, fname_out); #ifdef CONFIG_FEATURE_WGET_STATUSBAR } else { - curfile = get_last_path_component(fname_out); + curfile = bb_get_last_path_component(fname_out); #endif } if (do_continue && !fname_out) - error_msg_and_die("cannot specify continue (-c) without a filename (-O)"); + bb_error_msg_and_die("cannot specify continue (-c) without a filename (-O)"); /* @@ -288,7 +288,7 @@ int wget_main(int argc, char **argv) output = stdout; quiet_flag = TRUE; } else { - output = xfopen(fname_out, (do_continue ? "a" : "w")); + output = bb_xfopen(fname_out, (do_continue ? "a" : "w")); } /* @@ -296,7 +296,7 @@ int wget_main(int argc, char **argv) */ if (do_continue) { if (fstat(fileno(output), &sbuf) < 0) - perror_msg_and_die("fstat()"); + bb_perror_msg_and_die("fstat()"); if (sbuf.st_size > 0) beg_range = sbuf.st_size; else @@ -399,9 +399,9 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) } if (strcasecmp(buf, "location") == 0) { if (s[0] == '/') - target.path = xstrdup(s+1); + target.path = bb_xstrdup(s+1); else { - parse_url(xstrdup(s), &target); + parse_url(bb_xstrdup(s), &target); if (!proxy) { server.host = target.host; server.port = target.port; @@ -419,7 +419,7 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) * FTP session */ if (! target.user) - target.user = xstrdup("anonymous:busybox@"); + target.user = bb_xstrdup("anonymous:busybox@"); sfp = open_socket(server.host, server.port); if (ftpcmd(NULL, NULL, sfp, buf) != 220) @@ -496,7 +496,7 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) do { while ((filesize > 0 || !got_clen) && (n = safe_fread(buf, 1, chunked ? (filesize > sizeof(buf) ? sizeof(buf) : filesize) : sizeof(buf), dfp)) > 0) { if (safe_fwrite(buf, 1, n, output) != n) - perror_msg_and_die("write error"); + bb_perror_msg_and_die("write error"); #ifdef CONFIG_FEATURE_WGET_STATUSBAR statbytes+=n; #endif @@ -512,7 +512,7 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) } if (n == 0 && ferror(dfp)) - perror_msg_and_die("network read error"); + bb_perror_msg_and_die("network read error"); } while (chunked); #ifdef CONFIG_FEATURE_WGET_STATUSBAR if (quiet_flag==FALSE) @@ -521,7 +521,7 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) if (!proxy && target.is_ftp) { fclose(dfp); if (ftpcmd(NULL, NULL, sfp, buf) != 226) - error_msg_and_die("ftp error: %s", buf+4); + bb_error_msg_and_die("ftp error: %s", buf+4); ftpcmd("QUIT", NULL, sfp, buf); } exit(EXIT_SUCCESS); @@ -541,14 +541,14 @@ void parse_url(char *url, struct host_info *h) h->host = url + 6; h->is_ftp = 1; } else - error_msg_and_die("not an http or ftp url: %s", url); + bb_error_msg_and_die("not an http or ftp url: %s", url); sp = strchr(h->host, '/'); if (sp != NULL) { *sp++ = '\0'; h->path = sp; } else - h->path = xstrdup(""); + h->path = bb_xstrdup(""); up = strrchr(h->host, '@'); if (up != NULL) { @@ -580,7 +580,7 @@ FILE *open_socket(char *host, int port) * Get the server onto a stdio stream. */ if ((fp = fdopen(fd, "r+")) == NULL) - perror_msg_and_die("fdopen()"); + bb_perror_msg_and_die("fdopen()"); return fp; } @@ -609,7 +609,7 @@ char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc) /* verify we are at the end of the header name */ if (*s != ':') - error_msg_and_die("bad header line: %s", buf); + bb_error_msg_and_die("bad header line: %s", buf); /* locate the start of the header value */ for (*s++ = '\0' ; *s == ' ' || *s == '\t' ; ++s) @@ -646,7 +646,7 @@ static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf) do { p = fgets(buf, 510, fp); if (!p) - perror_msg_and_die("fgets()"); + bb_perror_msg_and_die("fgets()"); } while (! isdigit(buf[0]) || buf[3] != ' '); return atoi(buf); @@ -824,7 +824,7 @@ progressmeter(int flag) * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: wget.c,v 1.52 2003/03/11 18:03:39 andersen Exp $ + * $Id: wget.c,v 1.53 2003/03/19 09:12:39 mjn3 Exp $ */ |