Changeset View
Changeset View
Standalone View
Standalone View
head/sbin/ifconfig/ifconfig.c
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | |||||
int verbose; | int verbose; | ||||
int noload; | int noload; | ||||
int printifname = 0; | int printifname = 0; | ||||
int supmedia = 0; | int supmedia = 0; | ||||
int printkeys = 0; /* Print keying material for interfaces. */ | int printkeys = 0; /* Print keying material for interfaces. */ | ||||
/* Formatter Strings */ | /* Formatter Strings */ | ||||
char *f_inet, *f_inet6, *f_ether, *f_addr, *f_scope; | char *f_inet, *f_inet6, *f_ether, *f_addr; | ||||
static int ifconfig(int argc, char *const *argv, int iscreate, | static int ifconfig(int argc, char *const *argv, int iscreate, | ||||
const struct afswtch *afp); | const struct afswtch *afp); | ||||
static void status(const struct afswtch *afp, const struct sockaddr_dl *sdl, | static void status(const struct afswtch *afp, const struct sockaddr_dl *sdl, | ||||
struct ifaddrs *ifa); | struct ifaddrs *ifa); | ||||
static void tunnel_status(int s); | static void tunnel_status(int s); | ||||
static void usage(void); | static void usage(void); | ||||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | static void freeformat(void) | ||||
if (f_inet != NULL) | if (f_inet != NULL) | ||||
free(f_inet); | free(f_inet); | ||||
if (f_inet6 != NULL) | if (f_inet6 != NULL) | ||||
free(f_inet6); | free(f_inet6); | ||||
if (f_ether != NULL) | if (f_ether != NULL) | ||||
free(f_ether); | free(f_ether); | ||||
if (f_addr != NULL) | if (f_addr != NULL) | ||||
free(f_addr); | free(f_addr); | ||||
if (f_scope != NULL) | |||||
free(f_scope); | |||||
} | } | ||||
static void setformat(char *input) | static void setformat(char *input) | ||||
{ | { | ||||
char *formatstr, *category, *modifier; | char *formatstr, *category, *modifier; | ||||
formatstr = strdup(input); | formatstr = strdup(input); | ||||
while ((category = strsep(&formatstr, ",")) != NULL) { | while ((category = strsep(&formatstr, ",")) != NULL) { | ||||
Show All 11 Lines | while ((category = strsep(&formatstr, ",")) != NULL) { | ||||
if (strcmp(category, "addr") == 0) | if (strcmp(category, "addr") == 0) | ||||
f_addr = strdup(modifier); | f_addr = strdup(modifier); | ||||
else if (strcmp(category, "ether") == 0) | else if (strcmp(category, "ether") == 0) | ||||
f_ether = strdup(modifier); | f_ether = strdup(modifier); | ||||
else if (strcmp(category, "inet") == 0) | else if (strcmp(category, "inet") == 0) | ||||
f_inet = strdup(modifier); | f_inet = strdup(modifier); | ||||
else if (strcmp(category, "inet6") == 0) | else if (strcmp(category, "inet6") == 0) | ||||
f_inet6 = strdup(modifier); | f_inet6 = strdup(modifier); | ||||
else if (strcmp(category, "scope") == 0) | |||||
f_scope = strdup(modifier); | |||||
} | } | ||||
free(formatstr); | free(formatstr); | ||||
} | } | ||||
#undef ORDERS_SIZE | #undef ORDERS_SIZE | ||||
static struct ifaddrs * | static struct ifaddrs * | ||||
sortifaddrs(struct ifaddrs *list, | sortifaddrs(struct ifaddrs *list, | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | main(int argc, char *argv[]) | ||||
char options[1024], *cp, *envformat, *namecp = NULL; | char options[1024], *cp, *envformat, *namecp = NULL; | ||||
struct ifa_queue q = TAILQ_HEAD_INITIALIZER(q); | struct ifa_queue q = TAILQ_HEAD_INITIALIZER(q); | ||||
struct ifa_order_elt *cur, *tmp; | struct ifa_order_elt *cur, *tmp; | ||||
const char *ifname; | const char *ifname; | ||||
struct option *p; | struct option *p; | ||||
size_t iflen; | size_t iflen; | ||||
all = downonly = uponly = namesonly = noload = verbose = 0; | all = downonly = uponly = namesonly = noload = verbose = 0; | ||||
f_inet = f_inet6 = f_ether = f_addr = f_scope = NULL; | f_inet = f_inet6 = f_ether = f_addr = NULL; | ||||
envformat = getenv("IFCONFIG_FORMAT"); | envformat = getenv("IFCONFIG_FORMAT"); | ||||
if (envformat != NULL) | if (envformat != NULL) | ||||
setformat(envformat); | setformat(envformat); | ||||
/* | /* | ||||
* Ensure we print interface name when expected to, | * Ensure we print interface name when expected to, | ||||
* even if we terminate early due to error. | * even if we terminate early due to error. | ||||
▲ Show 20 Lines • Show All 1,091 Lines • Show Last 20 Lines |