[BusyBox-cvs] busybox/networking/libiproute ip_parse_common_args.c,NONE,1.1 Makefile.in,1.2,1.3 ip_common.h,1.1,1.2 ipaddress.c,1.2,1.3

Glenn McGrath bug1 at busybox.net
Sun Dec 1 23:04:11 UTC 2002


Update of /var/cvs/busybox/networking/libiproute
In directory winder:/tmp/cvs-serv5851/networking/libiproute

Modified Files:
	Makefile.in ip_common.h ipaddress.c 
Added Files:
	ip_parse_common_args.c 
Log Message:
Enable ip commands to be compiled seperate from ip, modifed patch from Bastian Blank 


--- NEW FILE: ip_parse_common_args.c ---
/*
 * ip.c		"ip" utility frontend.
 *
 *		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.
 *
 * Authors:	Alexey Kuznetsov, <kuznet at ms2.inr.ac.ru>
 *
 *
 * Changes:
 *
 * Rani Assaf <rani at magic.metawire.com> 980929:	resolve addresses
 */

#include "utils.h"
#include "ip_common.h"

#include "busybox.h"

int preferred_family = AF_UNSPEC;
int oneline = 0;
char * _SL_ = NULL;

void ip_parse_common_args(int *argcp, char ***argvp)
{
	int argc = *argcp;
	char **argv = *argvp;

	while (argc > 1) {
		char *opt = argv[1];

		if (strcmp(opt,"--") == 0) {
			argc--; argv++;
			break;
		}

		if (opt[0] != '-')
			break;

		if (opt[1] == '-')
			opt++;

		if (matches(opt, "-family") == 0) {
			argc--;
			argv++;
			if (strcmp(argv[1], "inet") == 0)
				preferred_family = AF_INET;
			else if (strcmp(argv[1], "inet6") == 0)
				preferred_family = AF_INET6;
			else if (strcmp(argv[1], "link") == 0)
				preferred_family = AF_PACKET;
			else
				invarg(argv[1], "invalid protocol family");
		} else if (strcmp(opt, "-4") == 0) {
			preferred_family = AF_INET;
		} else if (strcmp(opt, "-6") == 0) {
			preferred_family = AF_INET6;
		} else if (strcmp(opt, "-0") == 0) {
			preferred_family = AF_PACKET;
		} else if (matches(opt, "-oneline") == 0) {
			++oneline;
		} else {
			show_usage();
		}
		argc--;	argv++;
	}
	_SL_ = oneline ? "\\" : "\n" ;
}

Index: Makefile.in
===================================================================
RCS file: /var/cvs/busybox/networking/libiproute/Makefile.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile.in	10 Nov 2002 10:20:45 -0000	1.2
+++ Makefile.in	1 Dec 2002 23:04:06 -0000	1.3
@@ -23,6 +23,7 @@
 endif
 
 LIBIPROUTE-$(CONFIG_IP) += \
+	ip_parse_common_args.o \
 	ipaddress.o \
 	iplink.o \
 	iproute.o \

Index: ip_common.h
===================================================================
RCS file: /var/cvs/busybox/networking/libiproute/ip_common.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ip_common.h	10 Nov 2002 01:33:51 -0000	1.1
+++ ip_common.h	1 Dec 2002 23:04:06 -0000	1.2
@@ -1,3 +1,7 @@
+extern int preferred_family;
+extern char * _SL_;
+
+extern void ip_parse_common_args(int *argcp, char ***argvp);
 extern int print_linkinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
 extern int print_addrinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
 extern int print_neigh(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);

Index: ipaddress.c
===================================================================
RCS file: /var/cvs/busybox/networking/libiproute/ipaddress.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ipaddress.c	28 Nov 2002 10:49:14 -0000	1.2
+++ ipaddress.c	1 Dec 2002 23:04:06 -0000	1.3
@@ -230,7 +230,6 @@
 	if ((filter.flags^ifa->ifa_flags)&filter.flagmask)
 		return 0;
 	if (filter.label) {
-		SPRINT_BUF(b1);
 		const char *label;
 		if (rta_tb[IFA_LABEL])
 			label = RTA_DATA(rta_tb[IFA_LABEL]);
@@ -541,10 +540,10 @@
 	return ipaddr_list(argc, argv);
 }
 
-void ipaddr_reset_filter(int oneline)
+void ipaddr_reset_filter(int _oneline)
 {
 	memset(&filter, 0, sizeof(filter));
-	filter.oneline = oneline;
+	filter.oneline = _oneline;
 }
 
 int default_scope(inet_prefix *lcl)




More information about the busybox-cvs mailing list