networking/interface.c: fix indentation

This commit is contained in:
Denis Vlasenko 2008-06-04 07:59:51 +00:00
parent 630a7f75e8
commit 3b162ecdf6
3 changed files with 49 additions and 57 deletions

View File

@ -934,6 +934,8 @@ extern smallint interface_opt_a;
int display_interfaces(char *ifname); int display_interfaces(char *ifname);
#if ENABLE_FEATURE_HWIB #if ENABLE_FEATURE_HWIB
int in_ib(const char *bufp, struct sockaddr *sap); int in_ib(const char *bufp, struct sockaddr *sap);
#else
#define in_ib(a, b) 1 /* fail */
#endif #endif
const struct aftype *get_aftype(const char *name); const struct aftype *get_aftype(const char *name);
const struct hwtype *get_hwtype(const char *name); const struct hwtype *get_hwtype(const char *name);

View File

@ -252,20 +252,13 @@ static const struct options OptArray[] = {
/* /*
* A couple of prototypes. * A couple of prototypes.
*/ */
#if ENABLE_FEATURE_IFCONFIG_HW #if ENABLE_FEATURE_IFCONFIG_HW
static int in_ether(const char *bufp, struct sockaddr *sap); static int in_ether(const char *bufp, struct sockaddr *sap);
# if ENABLE_FEATURE_HWIB
extern int in_ib(const char *bufp, struct sockaddr *sap);
# else
# define in_ib(a, b) 1 /* fail */
# endif
#endif #endif
/* /*
* Our main function. * Our main function.
*/ */
int ifconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int ifconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ifconfig_main(int argc, char **argv) int ifconfig_main(int argc, char **argv)
{ {
@ -436,8 +429,7 @@ int ifconfig_main(int argc, char **argv)
bb_show_usage(); bb_show_usage();
/*safe_strncpy(host, *argv, sizeof(host));*/ /*safe_strncpy(host, *argv, sizeof(host));*/
host = *argv; host = *argv;
if (hw_class == 1 ? in_ether(host, &sa) if (hw_class == 1 ? in_ether(host, &sa) : in_ib(host, &sa))
: in_ib(host, &sa))
bb_error_msg_and_die("invalid hw-addr %s", host); bb_error_msg_and_die("invalid hw-addr %s", host);
p = (char *) &sa; p = (char *) &sa;
} }

View File

@ -680,7 +680,6 @@ static int if_fetch(struct interface *ife)
return 0; return 0;
} }
static int do_if_fetch(struct interface *ife) static int do_if_fetch(struct interface *ife)
{ {
if (if_fetch(ife) < 0) { if (if_fetch(ife) < 0) {
@ -1217,63 +1216,62 @@ static int if_print(char *ifname)
/* Input an Infiniband address and convert to binary. */ /* Input an Infiniband address and convert to binary. */
int in_ib(const char *bufp, struct sockaddr *sap) int in_ib(const char *bufp, struct sockaddr *sap)
{ {
unsigned char *ptr; unsigned char *ptr;
char c; char c;
const char *orig; const char *orig;
int i; int i;
unsigned val; unsigned val;
sap->sa_family = ib_hwtype.type; sap->sa_family = ib_hwtype.type;
ptr = (unsigned char *) sap->sa_data; ptr = (unsigned char *) sap->sa_data;
i = 0; i = 0;
orig = bufp; orig = bufp;
while ((*bufp != '\0') && (i < INFINIBAND_ALEN)) { while ((*bufp != '\0') && (i < INFINIBAND_ALEN)) {
val = 0; val = 0;
c = *bufp++; c = *bufp++;
if (isdigit(c)) if (isdigit(c))
val = c - '0'; val = c - '0';
else if (c >= 'a' && c <= 'f') else if (c >= 'a' && c <= 'f')
val = c - 'a' + 10; val = c - 'a' + 10;
else if (c >= 'A' && c <= 'F') else if (c >= 'A' && c <= 'F')
val = c - 'A' + 10; val = c - 'A' + 10;
else { else {
errno = EINVAL; errno = EINVAL;
return (-1); return -1;
} }
val <<= 4; val <<= 4;
c = *bufp; c = *bufp;
if (isdigit(c)) if (isdigit(c))
val |= c - '0'; val |= c - '0';
else if (c >= 'a' && c <= 'f') else if (c >= 'a' && c <= 'f')
val |= c - 'a' + 10; val |= c - 'a' + 10;
else if (c >= 'A' && c <= 'F') else if (c >= 'A' && c <= 'F')
val |= c - 'A' + 10; val |= c - 'A' + 10;
else if (c == ':' || c == 0) else if (c == ':' || c == 0)
val >>= 4; val >>= 4;
else { else {
errno = EINVAL; errno = EINVAL;
return (-1); return -1;
} }
if (c != 0) if (c != 0)
bufp++; bufp++;
*ptr++ = (unsigned char) (val & 0377); *ptr++ = (unsigned char) (val & 0377);
i++; i++;
/* We might get a semicolon here - not required. */ /* We might get a semicolon here - not required. */
if (*bufp == ':') { if (*bufp == ':') {
bufp++; bufp++;
}
} }
}
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "in_ib(%s): %s\n", orig, UNSPEC_print(sap->sa_data)); fprintf(stderr, "in_ib(%s): %s\n", orig, UNSPEC_print(sap->sa_data));
#endif #endif
return (0); return 0;
} }
#endif #endif
int display_interfaces(char *ifname) int display_interfaces(char *ifname)
{ {
int status; int status;