From fa85b86f388fb037b67fa7fcc3b5502c8d0fa84a Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sun, 7 Jan 2007 01:24:12 +0000 Subject: add arp applet - thanks to "Eric Spakman" --- include/applets.h | 1 + include/libbb.h | 37 +++++++++++++++++++++++++++++++++++++ include/usage.h | 20 ++++++++++++++++++++ 3 files changed, 58 insertions(+) (limited to 'include') diff --git a/include/applets.h b/include/applets.h index 8586ffc86..465ecdbdd 100644 --- a/include/applets.h +++ b/include/applets.h @@ -56,6 +56,7 @@ USE_ADDGROUP(APPLET(addgroup, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_ADDUSER(APPLET(adduser, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_ADJTIMEX(APPLET(adjtimex, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_AR(APPLET(ar, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) +USE_ARP(APPLET(arp, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_ARPING(APPLET(arping, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_ASH(APPLET_NOUSAGE(ash, ash, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_AWK(APPLET(awk, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) diff --git a/include/libbb.h b/include/libbb.h index e92e4db1c..6f66c8545 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -121,6 +121,38 @@ /* scary. better ideas? (but do *test* them first!) */ #define OFF_T_MAX ((off_t)~((off_t)1 << (sizeof(off_t)*8-1))) +/* This structure defines protocol families and their handlers. */ +struct aftype { + char *name; + char *title; + int af; + int alen; + char *(*print) (unsigned char *); + char *(*sprint) (struct sockaddr *, int numeric); + int (*input) (int type, char *bufp, struct sockaddr *); + void (*herror) (char *text); + int (*rprint) (int options); + int (*rinput) (int typ, int ext, char **argv); + + /* may modify src */ + int (*getmask) (char *src, struct sockaddr * mask, char *name); + + int fd; + char *flag_file; +}; + +/* This structure defines hardware protocols and their handlers. */ +struct hwtype { + char *name; + char *title; + int type; + int alen; + char *(*print) (unsigned char *); + int (*input) (char *, struct sockaddr *); + int (*activate) (int fd); + int suppress_null_addr; +}; + /* Some useful definitions */ #undef FALSE #define FALSE ((int) 0) @@ -426,8 +458,13 @@ extern int bb_test(int argc, char** argv); int create_icmp_socket(void); int create_icmp6_socket(void); /* interface.c */ +struct aftype; +struct hwtype; extern int interface_opt_a; int display_interfaces(char *ifname); +struct aftype *get_aftype(const char *name); +const struct hwtype *get_hwtype(const char *name); +const struct hwtype *get_hwntype(int type); #ifndef BUILD_INDIVIDUAL diff --git a/include/usage.h b/include/usage.h index ae03d5431..cfae4e1e1 100644 --- a/include/usage.h +++ b/include/usage.h @@ -55,6 +55,26 @@ " -x Extract\n" \ " -v Verbosely list files processed" +#define arp_trivial_usage \ + "\n" \ + "[-vn] [-H type] [-i if] -a [hostname]\n" \ + "[-v] [-i if] -d hostname [pub]\n" \ + "[-v] [-H type] [-i if] -s hostname hw_addr [temp]\n" \ + "[-v] [-H type] [-i if] -s hostname hw_addr [netmask nm] pub\n" \ + "[-v] [-H type] [-i if] -Ds hostname ifa [netmask nm] pub\n" +#define arp_full_usage \ + "Manipulate the system ARP cache" \ + "\n\nOptions:" \ + "\n -a Display (all) hosts" \ + "\n -s Set a new ARP entry" \ + "\n -d Delete a specified entry" \ + "\n -v Verbose" \ + "\n -n Don't resolve names" \ + "\n -i if Specify network interface (e.g. eth0)" \ + "\n -D Read from given device" \ + "\n -A, -p Specify protocol family" \ + "\n -H hwtype Specify hardware address type" + #define arping_trivial_usage \ "[-fqbDUA] [-c count] [-w timeout] [-i device] [-s sender] target" #define arping_full_usage \ -- cgit v1.2.3