Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 1 | /* ifconfig |
| 2 | * |
| 3 | * Similar to the standard Unix ifconfig, but with only the necessary |
| 4 | * parts for AF_INET, and without any printing of if info (for now). |
| 5 | * |
| 6 | * Bjorn Wesen, Axis Communications AB |
| 7 | * |
| 8 | * |
| 9 | * Authors of the original ifconfig was: |
| 10 | * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> |
| 11 | * |
| 12 | * This program is free software; you can redistribute it |
| 13 | * and/or modify it under the terms of the GNU General |
| 14 | * Public License as published by the Free Software |
| 15 | * Foundation; either version 2 of the License, or (at |
| 16 | * your option) any later version. |
| 17 | * |
Glenn L McGrath | 8ae4cab | 2002-11-26 09:02:06 +0000 | [diff] [blame] | 18 | * $Id: ifconfig.c,v 1.20 2002/11/26 09:02:05 bug1 Exp $ |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 19 | * |
| 20 | */ |
| 21 | |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 22 | /* |
| 23 | * Heavily modified by Manuel Novoa III Mar 6, 2001 |
| 24 | * |
| 25 | * From initial port to busybox, removed most of the redundancy by |
| 26 | * converting to a table-driven approach. Added several (optional) |
| 27 | * args missing from initial port. |
| 28 | * |
Manuel Novoa III | 68ea1d0 | 2001-03-12 09:57:59 +0000 | [diff] [blame] | 29 | * Still missing: media, tunnel. |
Eric Andersen | 51b8bd6 | 2002-07-03 11:46:38 +0000 | [diff] [blame] | 30 | * |
| 31 | * 2002-04-20 |
| 32 | * IPV6 support added by Bart Visscher <magick@linux-fan.com> |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 33 | */ |
| 34 | |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 35 | #include <stdio.h> |
| 36 | #include <stdlib.h> |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 37 | #include <string.h> /* strcmp and friends */ |
| 38 | #include <ctype.h> /* isdigit and friends */ |
| 39 | #include <stddef.h> /* offsetof */ |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 40 | #include <sys/ioctl.h> |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 41 | #include <net/if_arp.h> |
Eric Andersen | cd8c436 | 2001-11-10 11:22:46 +0000 | [diff] [blame] | 42 | #include <netinet/in.h> |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 43 | #include <linux/if_ether.h> |
Eric Andersen | cd8c436 | 2001-11-10 11:22:46 +0000 | [diff] [blame] | 44 | #include <net/if.h> |
| 45 | #include "inet_common.h" |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 46 | #include "busybox.h" |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 47 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 48 | #ifdef CONFIG_FEATURE_IFCONFIG_SLIP |
Glenn L McGrath | 8ae4cab | 2002-11-26 09:02:06 +0000 | [diff] [blame] | 49 | # include <linux/if_slip.h> |
Eric Andersen | f15d4da | 2001-03-06 00:48:59 +0000 | [diff] [blame] | 50 | #endif |
| 51 | |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 52 | /* I don't know if this is needed for busybox or not. Anyone? */ |
| 53 | #define QUESTIONABLE_ALIAS_CASE |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 54 | |
| 55 | |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 56 | /* Defines for glibc2.0 users. */ |
| 57 | #ifndef SIOCSIFTXQLEN |
Glenn L McGrath | 8ae4cab | 2002-11-26 09:02:06 +0000 | [diff] [blame] | 58 | # define SIOCSIFTXQLEN 0x8943 |
| 59 | # define SIOCGIFTXQLEN 0x8942 |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 60 | #endif |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 61 | |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 62 | /* ifr_qlen is ifru_ivalue, but it isn't present in 2.0 kernel headers */ |
| 63 | #ifndef ifr_qlen |
Glenn L McGrath | 8ae4cab | 2002-11-26 09:02:06 +0000 | [diff] [blame] | 64 | # define ifr_qlen ifr_ifru.ifru_mtu |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 65 | #endif |
Eric Andersen | f15d4da | 2001-03-06 00:48:59 +0000 | [diff] [blame] | 66 | |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 67 | #ifndef IFF_DYNAMIC |
Glenn L McGrath | 8ae4cab | 2002-11-26 09:02:06 +0000 | [diff] [blame] | 68 | # define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses */ |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 69 | #endif |
Eric Andersen | f15d4da | 2001-03-06 00:48:59 +0000 | [diff] [blame] | 70 | |
Glenn L McGrath | 8ae4cab | 2002-11-26 09:02:06 +0000 | [diff] [blame] | 71 | #ifdef CONFIG_FEATURE_IPV6 |
Eric Andersen | 51b8bd6 | 2002-07-03 11:46:38 +0000 | [diff] [blame] | 72 | struct in6_ifreq { |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 73 | struct in6_addr ifr6_addr; |
| 74 | uint32_t ifr6_prefixlen; |
| 75 | int ifr6_ifindex; |
Eric Andersen | 51b8bd6 | 2002-07-03 11:46:38 +0000 | [diff] [blame] | 76 | }; |
| 77 | #endif |
| 78 | |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 79 | /* |
| 80 | * Here are the bit masks for the "flags" member of struct options below. |
| 81 | * N_ signifies no arg prefix; M_ signifies arg prefixed by '-'. |
| 82 | * CLR clears the flag; SET sets the flag; ARG signifies (optional) arg. |
Eric Andersen | f15d4da | 2001-03-06 00:48:59 +0000 | [diff] [blame] | 83 | */ |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 84 | #define N_CLR 0x01 |
| 85 | #define M_CLR 0x02 |
| 86 | #define N_SET 0x04 |
| 87 | #define M_SET 0x08 |
| 88 | #define N_ARG 0x10 |
| 89 | #define M_ARG 0x20 |
| 90 | |
| 91 | #define M_MASK (M_CLR | M_SET | M_ARG) |
| 92 | #define N_MASK (N_CLR | N_SET | N_ARG) |
| 93 | #define SET_MASK (N_SET | M_SET) |
| 94 | #define CLR_MASK (N_CLR | M_CLR) |
| 95 | #define SET_CLR_MASK (SET_MASK | CLR_MASK) |
| 96 | #define ARG_MASK (M_ARG | N_ARG) |
| 97 | |
| 98 | /* |
| 99 | * Here are the bit masks for the "arg_flags" member of struct options below. |
| 100 | */ |
| 101 | |
| 102 | /* |
| 103 | * cast type: |
| 104 | * 00 int |
| 105 | * 01 char * |
| 106 | * 02 HOST_COPY in_ether |
| 107 | * 03 HOST_COPY INET_resolve |
| 108 | */ |
| 109 | #define A_CAST_TYPE 0x03 |
| 110 | /* |
| 111 | * map type: |
| 112 | * 00 not a map type (mem_start, io_addr, irq) |
| 113 | * 04 memstart (unsigned long) |
| 114 | * 08 io_addr (unsigned short) |
| 115 | * 0C irq (unsigned char) |
| 116 | */ |
| 117 | #define A_MAP_TYPE 0x0C |
| 118 | #define A_ARG_REQ 0x10 /* Set if an arg is required. */ |
| 119 | #define A_NETMASK 0x20 /* Set if netmask (check for multiple sets). */ |
| 120 | #define A_SET_AFTER 0x40 /* Set a flag at the end. */ |
| 121 | #define A_COLON_CHK 0x80 /* Is this needed? See below. */ |
| 122 | |
| 123 | /* |
| 124 | * These defines are for dealing with the A_CAST_TYPE field. |
| 125 | */ |
| 126 | #define A_CAST_CHAR_PTR 0x01 |
| 127 | #define A_CAST_RESOLVE 0x01 |
| 128 | #define A_CAST_HOST_COPY 0x02 |
| 129 | #define A_CAST_HOST_COPY_IN_ETHER A_CAST_HOST_COPY |
| 130 | #define A_CAST_HOST_COPY_RESOLVE (A_CAST_HOST_COPY | A_CAST_RESOLVE) |
| 131 | |
| 132 | /* |
| 133 | * These defines are for dealing with the A_MAP_TYPE field. |
| 134 | */ |
| 135 | #define A_MAP_ULONG 0x04 /* memstart */ |
| 136 | #define A_MAP_USHORT 0x08 /* io_addr */ |
| 137 | #define A_MAP_UCHAR 0x0C /* irq */ |
| 138 | |
| 139 | /* |
| 140 | * Define the bit masks signifying which operations to perform for each arg. |
| 141 | */ |
| 142 | |
| 143 | #define ARG_METRIC (A_ARG_REQ /*| A_CAST_INT*/) |
| 144 | #define ARG_MTU (A_ARG_REQ /*| A_CAST_INT*/) |
| 145 | #define ARG_TXQUEUELEN (A_ARG_REQ /*| A_CAST_INT*/) |
| 146 | #define ARG_MEM_START (A_ARG_REQ | A_MAP_ULONG) |
Eric Andersen | 72f9a42 | 2001-10-28 05:12:20 +0000 | [diff] [blame] | 147 | #define ARG_IO_ADDR (A_ARG_REQ | A_MAP_ULONG) |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 148 | #define ARG_IRQ (A_ARG_REQ | A_MAP_UCHAR) |
| 149 | #define ARG_DSTADDR (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE) |
| 150 | #define ARG_NETMASK (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_NETMASK) |
Manuel Novoa III | 4fb0b51 | 2001-08-10 06:02:23 +0000 | [diff] [blame] | 151 | #define ARG_BROADCAST (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER) |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 152 | #define ARG_HW (A_ARG_REQ | A_CAST_HOST_COPY_IN_ETHER) |
| 153 | #define ARG_POINTOPOINT (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER) |
| 154 | #define ARG_KEEPALIVE (A_ARG_REQ | A_CAST_CHAR_PTR) |
| 155 | #define ARG_OUTFILL (A_ARG_REQ | A_CAST_CHAR_PTR) |
Manuel Novoa III | 4fb0b51 | 2001-08-10 06:02:23 +0000 | [diff] [blame] | 156 | #define ARG_HOSTNAME (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_COLON_CHK) |
Eric Andersen | 51b8bd6 | 2002-07-03 11:46:38 +0000 | [diff] [blame] | 157 | #define ARG_ADD_DEL (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER) |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 158 | |
| 159 | |
| 160 | /* |
| 161 | * Set up the tables. Warning! They must have corresponding order! |
| 162 | */ |
| 163 | |
| 164 | struct arg1opt { |
| 165 | const char *name; |
| 166 | unsigned short selector; |
| 167 | unsigned short ifr_offset; |
| 168 | }; |
| 169 | |
| 170 | struct options { |
| 171 | const char *name; |
| 172 | const unsigned char flags; |
Manuel Novoa III | 4fb0b51 | 2001-08-10 06:02:23 +0000 | [diff] [blame] | 173 | const unsigned char arg_flags; |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 174 | const unsigned short selector; |
| 175 | }; |
| 176 | |
| 177 | #define ifreq_offsetof(x) offsetof(struct ifreq, x) |
| 178 | |
| 179 | static const struct arg1opt Arg1Opt[] = { |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 180 | {"SIOCSIFMETRIC", SIOCSIFMETRIC, ifreq_offsetof(ifr_metric)}, |
| 181 | {"SIOCSIFMTU", SIOCSIFMTU, ifreq_offsetof(ifr_mtu)}, |
| 182 | {"SIOCSIFTXQLEN", SIOCSIFTXQLEN, ifreq_offsetof(ifr_qlen)}, |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 183 | {"SIOCSIFDSTADDR", SIOCSIFDSTADDR, ifreq_offsetof(ifr_dstaddr)}, |
| 184 | {"SIOCSIFNETMASK", SIOCSIFNETMASK, ifreq_offsetof(ifr_netmask)}, |
| 185 | {"SIOCSIFBRDADDR", SIOCSIFBRDADDR, ifreq_offsetof(ifr_broadaddr)}, |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 186 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 187 | {"SIOCSIFHWADDR", SIOCSIFHWADDR, ifreq_offsetof(ifr_hwaddr)}, |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 188 | #endif |
| 189 | {"SIOCSIFDSTADDR", SIOCSIFDSTADDR, ifreq_offsetof(ifr_dstaddr)}, |
Eric Andersen | f15d4da | 2001-03-06 00:48:59 +0000 | [diff] [blame] | 190 | #ifdef SIOCSKEEPALIVE |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 191 | {"SIOCSKEEPALIVE", SIOCSKEEPALIVE, ifreq_offsetof(ifr_data)}, |
Eric Andersen | f15d4da | 2001-03-06 00:48:59 +0000 | [diff] [blame] | 192 | #endif |
| 193 | #ifdef SIOCSOUTFILL |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 194 | {"SIOCSOUTFILL", SIOCSOUTFILL, ifreq_offsetof(ifr_data)}, |
Eric Andersen | f15d4da | 2001-03-06 00:48:59 +0000 | [diff] [blame] | 195 | #endif |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 196 | #ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 197 | {"SIOCSIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.mem_start)}, |
| 198 | {"SIOCSIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.base_addr)}, |
| 199 | {"SIOCSIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.irq)}, |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 200 | #endif |
| 201 | /* Last entry if for unmatched (possibly hostname) arg. */ |
Glenn L McGrath | 8ae4cab | 2002-11-26 09:02:06 +0000 | [diff] [blame] | 202 | #ifdef CONFIG_FEATURE_IPV6 |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 203 | {"SIOCSIFADDR", SIOCSIFADDR, ifreq_offsetof(ifr_addr)}, /* IPv6 version ignores the offset */ |
| 204 | {"SIOCDIFADDR", SIOCDIFADDR, ifreq_offsetof(ifr_addr)}, /* IPv6 version ignores the offset */ |
Eric Andersen | 51b8bd6 | 2002-07-03 11:46:38 +0000 | [diff] [blame] | 205 | #endif |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 206 | {"SIOCSIFADDR", SIOCSIFADDR, ifreq_offsetof(ifr_addr)}, |
Eric Andersen | f15d4da | 2001-03-06 00:48:59 +0000 | [diff] [blame] | 207 | }; |
| 208 | |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 209 | static const struct options OptArray[] = { |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 210 | {"metric", N_ARG, ARG_METRIC, 0}, |
| 211 | {"mtu", N_ARG, ARG_MTU, 0}, |
| 212 | {"txqueuelen", N_ARG, ARG_TXQUEUELEN, 0}, |
| 213 | {"dstaddr", N_ARG, ARG_DSTADDR, 0}, |
| 214 | {"netmask", N_ARG, ARG_NETMASK, 0}, |
| 215 | {"broadcast", N_ARG | M_CLR, ARG_BROADCAST, IFF_BROADCAST}, |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 216 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 217 | {"hw", N_ARG, ARG_HW, 0}, |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 218 | #endif |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 219 | {"pointopoint", N_ARG | M_CLR, ARG_POINTOPOINT, IFF_POINTOPOINT}, |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 220 | #ifdef SIOCSKEEPALIVE |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 221 | {"keepalive", N_ARG, ARG_KEEPALIVE, 0}, |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 222 | #endif |
| 223 | #ifdef SIOCSOUTFILL |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 224 | {"outfill", N_ARG, ARG_OUTFILL, 0}, |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 225 | #endif |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 226 | #ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 227 | {"mem_start", N_ARG, ARG_MEM_START, 0}, |
| 228 | {"io_addr", N_ARG, ARG_IO_ADDR, 0}, |
| 229 | {"irq", N_ARG, ARG_IRQ, 0}, |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 230 | #endif |
Glenn L McGrath | 8ae4cab | 2002-11-26 09:02:06 +0000 | [diff] [blame] | 231 | #ifdef CONFIG_FEATURE_IPV6 |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 232 | {"add", N_ARG, ARG_ADD_DEL, 0}, |
| 233 | {"del", N_ARG, ARG_ADD_DEL, 0}, |
Eric Andersen | 51b8bd6 | 2002-07-03 11:46:38 +0000 | [diff] [blame] | 234 | #endif |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 235 | {"arp", N_CLR | M_SET, 0, IFF_NOARP}, |
| 236 | {"trailers", N_CLR | M_SET, 0, IFF_NOTRAILERS}, |
| 237 | {"promisc", N_SET | M_CLR, 0, IFF_PROMISC}, |
| 238 | {"multicast", N_SET | M_CLR, 0, IFF_MULTICAST}, |
| 239 | {"allmulti", N_SET | M_CLR, 0, IFF_ALLMULTI}, |
| 240 | {"dynamic", N_SET | M_CLR, 0, IFF_DYNAMIC}, |
| 241 | {"up", N_SET, 0, (IFF_UP | IFF_RUNNING)}, |
| 242 | {"down", N_CLR, 0, IFF_UP}, |
| 243 | {NULL, 0, ARG_HOSTNAME, (IFF_UP | IFF_RUNNING)} |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 244 | }; |
Eric Andersen | f15d4da | 2001-03-06 00:48:59 +0000 | [diff] [blame] | 245 | |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 246 | /* |
| 247 | * A couple of prototypes. |
| 248 | */ |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 249 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 250 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 251 | static int in_ether(char *bufp, struct sockaddr *sap); |
| 252 | #endif |
| 253 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 254 | #ifdef CONFIG_FEATURE_IFCONFIG_STATUS |
Manuel Novoa III | 68ea1d0 | 2001-03-12 09:57:59 +0000 | [diff] [blame] | 255 | extern int interface_opt_a; |
| 256 | extern int display_interfaces(char *ifname); |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 257 | #endif |
| 258 | |
| 259 | /* |
| 260 | * Our main function. |
| 261 | */ |
| 262 | |
| 263 | int ifconfig_main(int argc, char **argv) |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 264 | { |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 265 | struct ifreq ifr; |
| 266 | struct sockaddr_in sai; |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 267 | |
Glenn L McGrath | 8ae4cab | 2002-11-26 09:02:06 +0000 | [diff] [blame] | 268 | #ifdef CONFIG_FEATURE_IPV6 |
Eric Andersen | 51b8bd6 | 2002-07-03 11:46:38 +0000 | [diff] [blame] | 269 | struct sockaddr_in6 sai6; |
| 270 | #endif |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 271 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 272 | struct sockaddr sa; |
| 273 | #endif |
| 274 | const struct arg1opt *a1op; |
| 275 | const struct options *op; |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 276 | int sockfd; /* socket fd we use to manipulate stuff with */ |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 277 | int goterr; |
| 278 | int selector; |
| 279 | char *p; |
| 280 | char host[128]; |
Manuel Novoa III | 4fb0b51 | 2001-08-10 06:02:23 +0000 | [diff] [blame] | 281 | unsigned char mask; |
| 282 | unsigned char did_flags; |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 283 | |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 284 | goterr = 0; |
| 285 | did_flags = 0; |
| 286 | |
Manuel Novoa III | 68ea1d0 | 2001-03-12 09:57:59 +0000 | [diff] [blame] | 287 | /* skip argv[0] */ |
| 288 | ++argv; |
| 289 | --argc; |
| 290 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 291 | #ifdef CONFIG_FEATURE_IFCONFIG_STATUS |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 292 | if ((argc > 0) && (strcmp(*argv, "-a") == 0)) { |
Manuel Novoa III | 68ea1d0 | 2001-03-12 09:57:59 +0000 | [diff] [blame] | 293 | interface_opt_a = 1; |
| 294 | --argc; |
| 295 | ++argv; |
| 296 | } |
| 297 | #endif |
| 298 | |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 299 | if (argc <= 1) { |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 300 | #ifdef CONFIG_FEATURE_IFCONFIG_STATUS |
Manuel Novoa III | 68ea1d0 | 2001-03-12 09:57:59 +0000 | [diff] [blame] | 301 | return display_interfaces(argc ? *argv : NULL); |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 302 | #else |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 303 | error_msg_and_die |
| 304 | ("ifconfig was not compiled with interface status display support."); |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 305 | #endif |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 306 | } |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 307 | |
| 308 | /* Create a channel to the NET kernel. */ |
| 309 | if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { |
Manuel Novoa III | fa45f22 | 2001-03-09 23:06:15 +0000 | [diff] [blame] | 310 | perror_msg_and_die("socket"); |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 311 | } |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 312 | |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 313 | /* get interface name */ |
| 314 | safe_strncpy(ifr.ifr_name, *argv, IFNAMSIZ); |
| 315 | |
| 316 | /* Process the remaining arguments. */ |
| 317 | while (*++argv != (char *) NULL) { |
| 318 | p = *argv; |
| 319 | mask = N_MASK; |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 320 | if (*p == '-') { /* If the arg starts with '-'... */ |
| 321 | ++p; /* advance past it and */ |
| 322 | mask = M_MASK; /* set the appropriate mask. */ |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 323 | } |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 324 | for (op = OptArray; op->name; op++) { /* Find table entry. */ |
| 325 | if (strcmp(p, op->name) == 0) { /* If name matches... */ |
| 326 | if ((mask &= op->flags)) { /* set the mask and go. */ |
| 327 | goto FOUND_ARG;; |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 328 | } |
| 329 | /* If we get here, there was a valid arg with an */ |
| 330 | /* invalid '-' prefix. */ |
| 331 | ++goterr; |
| 332 | goto LOOP; |
| 333 | } |
| 334 | } |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 335 | |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 336 | /* We fell through, so treat as possible hostname. */ |
| 337 | a1op = Arg1Opt + (sizeof(Arg1Opt) / sizeof(Arg1Opt[0])) - 1; |
| 338 | mask = op->arg_flags; |
| 339 | goto HOSTNAME; |
| 340 | |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 341 | FOUND_ARG: |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 342 | if (mask & ARG_MASK) { |
| 343 | mask = op->arg_flags; |
| 344 | a1op = Arg1Opt + (op - OptArray); |
| 345 | if (mask & A_NETMASK & did_flags) { |
| 346 | show_usage(); |
| 347 | } |
| 348 | if (*++argv == NULL) { |
| 349 | if (mask & A_ARG_REQ) { |
| 350 | show_usage(); |
| 351 | } else { |
| 352 | --argv; |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 353 | mask &= A_SET_AFTER; /* just for broadcast */ |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 354 | } |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 355 | } else { /* got an arg so process it */ |
| 356 | HOSTNAME: |
Manuel Novoa III | 4fb0b51 | 2001-08-10 06:02:23 +0000 | [diff] [blame] | 357 | did_flags |= (mask & A_NETMASK); |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 358 | if (mask & A_CAST_HOST_COPY) { |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 359 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 360 | if (mask & A_CAST_RESOLVE) { |
| 361 | #endif |
Glenn L McGrath | 8ae4cab | 2002-11-26 09:02:06 +0000 | [diff] [blame] | 362 | #ifdef CONFIG_FEATURE_IPV6 |
Eric Andersen | 51b8bd6 | 2002-07-03 11:46:38 +0000 | [diff] [blame] | 363 | char *prefix; |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 364 | int prefix_len = 0; |
Eric Andersen | 51b8bd6 | 2002-07-03 11:46:38 +0000 | [diff] [blame] | 365 | #endif |
| 366 | |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 367 | safe_strncpy(host, *argv, (sizeof host)); |
Glenn L McGrath | 8ae4cab | 2002-11-26 09:02:06 +0000 | [diff] [blame] | 368 | #ifdef CONFIG_FEATURE_IPV6 |
Eric Andersen | 51b8bd6 | 2002-07-03 11:46:38 +0000 | [diff] [blame] | 369 | if ((prefix = strchr(host, '/'))) { |
| 370 | prefix_len = atol(prefix + 1); |
| 371 | if ((prefix_len < 0) || (prefix_len > 128)) { |
| 372 | ++goterr; |
| 373 | goto LOOP; |
| 374 | } |
| 375 | *prefix = 0; |
| 376 | } |
| 377 | #endif |
| 378 | |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 379 | sai.sin_family = AF_INET; |
| 380 | sai.sin_port = 0; |
Eric Andersen | cd8c436 | 2001-11-10 11:22:46 +0000 | [diff] [blame] | 381 | if (!strcmp(host, bb_INET_default)) { |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 382 | /* Default is special, meaning 0.0.0.0. */ |
| 383 | sai.sin_addr.s_addr = INADDR_ANY; |
Glenn L McGrath | 8ae4cab | 2002-11-26 09:02:06 +0000 | [diff] [blame] | 384 | #ifdef CONFIG_FEATURE_IPV6 |
Eric Andersen | 51b8bd6 | 2002-07-03 11:46:38 +0000 | [diff] [blame] | 385 | } else |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 386 | if (inet_pton(AF_INET6, host, &sai6.sin6_addr) > |
| 387 | 0) { |
Eric Andersen | 51b8bd6 | 2002-07-03 11:46:38 +0000 | [diff] [blame] | 388 | int sockfd6; |
| 389 | struct in6_ifreq ifr6; |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 390 | |
| 391 | memcpy((char *) &ifr6.ifr6_addr, |
| 392 | (char *) &sai6.sin6_addr, |
| 393 | sizeof(struct in6_addr)); |
Eric Andersen | 51b8bd6 | 2002-07-03 11:46:38 +0000 | [diff] [blame] | 394 | |
| 395 | /* Create a channel to the NET kernel. */ |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 396 | if ((sockfd6 = |
| 397 | socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { |
Eric Andersen | 51b8bd6 | 2002-07-03 11:46:38 +0000 | [diff] [blame] | 398 | perror_msg_and_die("socket6"); |
| 399 | } |
| 400 | if (ioctl(sockfd6, SIOGIFINDEX, &ifr) < 0) { |
| 401 | perror("SIOGIFINDEX"); |
| 402 | ++goterr; |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 403 | continue; |
Eric Andersen | 51b8bd6 | 2002-07-03 11:46:38 +0000 | [diff] [blame] | 404 | } |
| 405 | ifr6.ifr6_ifindex = ifr.ifr_ifindex; |
| 406 | ifr6.ifr6_prefixlen = prefix_len; |
| 407 | if (ioctl(sockfd6, a1op->selector, &ifr6) < 0) { |
| 408 | perror(a1op->name); |
| 409 | ++goterr; |
| 410 | } |
| 411 | continue; |
| 412 | #endif |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 413 | } else if (inet_aton(host, &sai.sin_addr) == 0) { |
| 414 | /* It's not a dotted quad. */ |
| 415 | ++goterr; |
| 416 | continue; |
| 417 | } |
| 418 | p = (char *) &sai; |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 419 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 420 | } else { /* A_CAST_HOST_COPY_IN_ETHER */ |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 421 | /* This is the "hw" arg case. */ |
| 422 | if (strcmp("ether", *argv) || (*++argv == NULL)) { |
| 423 | show_usage(); |
| 424 | } |
| 425 | safe_strncpy(host, *argv, (sizeof host)); |
| 426 | if (in_ether(host, &sa)) { |
Eric Andersen | 4acf8f8 | 2001-10-28 09:36:48 +0000 | [diff] [blame] | 427 | error_msg("invalid hw-addr %s", host); |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 428 | ++goterr; |
| 429 | continue; |
| 430 | } |
| 431 | p = (char *) &sa; |
| 432 | } |
| 433 | #endif |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 434 | memcpy((((char *) (&ifr)) + a1op->ifr_offset), |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 435 | p, sizeof(struct sockaddr)); |
| 436 | } else { |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 437 | unsigned int i = strtoul(*argv, NULL, 0); |
| 438 | |
| 439 | p = ((char *) (&ifr)) + a1op->ifr_offset; |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 440 | #ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 441 | if (mask & A_MAP_TYPE) { |
| 442 | if (ioctl(sockfd, SIOCGIFMAP, &ifr) < 0) { |
| 443 | ++goterr; |
| 444 | continue; |
| 445 | } |
| 446 | if ((mask & A_MAP_UCHAR) == A_MAP_UCHAR) { |
| 447 | *((unsigned char *) p) = i; |
| 448 | } else if (mask & A_MAP_USHORT) { |
| 449 | *((unsigned short *) p) = i; |
| 450 | } else { |
| 451 | *((unsigned long *) p) = i; |
| 452 | } |
| 453 | } else |
| 454 | #endif |
| 455 | if (mask & A_CAST_CHAR_PTR) { |
| 456 | *((caddr_t *) p) = (caddr_t) i; |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 457 | } else { /* A_CAST_INT */ |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 458 | *((int *) p) = i; |
| 459 | } |
| 460 | } |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 461 | |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 462 | if (ioctl(sockfd, a1op->selector, &ifr) < 0) { |
| 463 | perror(a1op->name); |
| 464 | ++goterr; |
| 465 | continue; |
| 466 | } |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 467 | #ifdef QUESTIONABLE_ALIAS_CASE |
| 468 | if (mask & A_COLON_CHK) { |
| 469 | /* |
| 470 | * Don't do the set_flag() if the address is an alias with |
| 471 | * a - at the end, since it's deleted already! - Roman |
| 472 | * |
| 473 | * Should really use regex.h here, not sure though how well |
| 474 | * it'll go with the cross-platform support etc. |
| 475 | */ |
| 476 | char *ptr; |
| 477 | short int found_colon = 0; |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 478 | |
| 479 | for (ptr = ifr.ifr_name; *ptr; ptr++) { |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 480 | if (*ptr == ':') { |
| 481 | found_colon++; |
| 482 | } |
| 483 | } |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 484 | |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 485 | if (found_colon && *(ptr - 1) == '-') { |
| 486 | continue; |
| 487 | } |
| 488 | } |
| 489 | #endif |
| 490 | } |
| 491 | if (!(mask & A_SET_AFTER)) { |
| 492 | continue; |
| 493 | } |
| 494 | mask = N_SET; |
| 495 | } |
| 496 | |
| 497 | if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) { |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 498 | perror("SIOCGIFFLAGS"); |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 499 | ++goterr; |
| 500 | } else { |
| 501 | selector = op->selector; |
| 502 | if (mask & SET_MASK) { |
| 503 | ifr.ifr_flags |= selector; |
| 504 | } else { |
| 505 | ifr.ifr_flags &= ~selector; |
| 506 | } |
| 507 | if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0) { |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 508 | perror("SIOCSIFFLAGS"); |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 509 | ++goterr; |
| 510 | } |
| 511 | } |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 512 | LOOP: |
Eric Andersen | 2276d83 | 2002-07-11 11:11:56 +0000 | [diff] [blame] | 513 | continue; |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 514 | } /* end of while-loop */ |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 515 | |
| 516 | return goterr; |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 517 | } |
| 518 | |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 519 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 520 | /* Input an Ethernet address and convert to binary. */ |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 521 | static int in_ether(char *bufp, struct sockaddr *sap) |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 522 | { |
| 523 | unsigned char *ptr; |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 524 | int i, j; |
| 525 | unsigned char val; |
| 526 | unsigned char c; |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 527 | |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 528 | sap->sa_family = ARPHRD_ETHER; |
| 529 | ptr = sap->sa_data; |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 530 | |
| 531 | for (i = 0; i < ETH_ALEN; i++) { |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 532 | val = 0; |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 533 | |
| 534 | /* We might get a semicolon here - not required. */ |
| 535 | if (i && (*bufp == ':')) { |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 536 | bufp++; |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 537 | } |
| 538 | |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 539 | for (j = 0; j < 2; j++) { |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 540 | c = *bufp; |
| 541 | if (c >= '0' && c <= '9') { |
| 542 | c -= '0'; |
| 543 | } else if (c >= 'a' && c <= 'f') { |
Manuel Novoa III | 049dc25 | 2001-03-26 16:26:16 +0000 | [diff] [blame] | 544 | c -= ('a' - 10); |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 545 | } else if (c >= 'A' && c <= 'F') { |
Manuel Novoa III | 049dc25 | 2001-03-26 16:26:16 +0000 | [diff] [blame] | 546 | c -= ('A' - 10); |
Manuel Novoa III | df351d6 | 2001-03-08 22:57:00 +0000 | [diff] [blame] | 547 | } else if (j && (c == ':' || c == 0)) { |
| 548 | break; |
| 549 | } else { |
| 550 | return -1; |
| 551 | } |
| 552 | ++bufp; |
| 553 | val <<= 4; |
| 554 | val += c; |
| 555 | } |
| 556 | *ptr++ = val; |
Eric Andersen | ec45595 | 2001-02-14 08:11:27 +0000 | [diff] [blame] | 557 | } |
| 558 | |
Glenn L McGrath | baf55a8 | 2002-08-22 18:22:10 +0000 | [diff] [blame] | 559 | return (int) (*bufp); /* Error if we don't end at end of string. */ |
Eric Andersen | f15d4da | 2001-03-06 00:48:59 +0000 | [diff] [blame] | 560 | } |
| 561 | #endif |