Changeset View
Changeset View
Standalone View
Standalone View
sbin/ifconfig/ifconfig.c
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
#include <jail.h> | #include <jail.h> | ||||
#endif | #endif | ||||
#include <stdbool.h> | #include <stdbool.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <libifconfig.h> | |||||
#include "ifconfig.h" | #include "ifconfig.h" | ||||
ifconfig_handle_t *lifh; | |||||
/* | /* | ||||
* Since "struct ifreq" is composed of various union members, callers | * Since "struct ifreq" is composed of various union members, callers | ||||
* should pay special attention to interpret the value. | * should pay special attention to interpret the value. | ||||
* (.e.g. little/big endian difference in the structure.) | * (.e.g. little/big endian difference in the structure.) | ||||
*/ | */ | ||||
struct ifreq ifr; | struct ifreq ifr; | ||||
char name[IFNAMSIZ]; | char name[IFNAMSIZ]; | ||||
▲ Show 20 Lines • Show All 325 Lines • ▼ Show 20 Lines | main(int argc, char *argv[]) | ||||
const char *ifname, *matchgroup, *nogroup; | const char *ifname, *matchgroup, *nogroup; | ||||
struct option *p; | struct option *p; | ||||
size_t iflen; | size_t iflen; | ||||
int flags; | int flags; | ||||
all = downonly = uponly = namesonly = noload = verbose = 0; | all = downonly = uponly = namesonly = noload = verbose = 0; | ||||
f_inet = f_inet6 = f_ether = f_addr = NULL; | f_inet = f_inet6 = f_ether = f_addr = NULL; | ||||
matchgroup = nogroup = NULL; | matchgroup = nogroup = NULL; | ||||
lifh = ifconfig_open(); | |||||
kp: It doesn't make any functional difference, but we should probably do `ifconfig_close(lifh);` at… | |||||
if (lifh == NULL) | |||||
err(EXIT_FAILURE, "ifconfig_open"); | |||||
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,283 Lines • Show Last 20 Lines |
It doesn't make any functional difference, but we should probably do ifconfig_close(lifh); at the end of main().