Commit 742e6280 authored by Mike Frysinger's avatar Mike Frysinger

lib: hw: constify hwtype

Most callers never modify this structure, so constify it everywhere.
parent a6118deb
...@@ -89,7 +89,7 @@ int opt_D = 0; /* HW-address is devicename */ ...@@ -89,7 +89,7 @@ int opt_D = 0; /* HW-address is devicename */
int opt_e = 0; /* 0=BSD output, 1=new linux */ int opt_e = 0; /* 0=BSD output, 1=new linux */
int opt_a = 0; /* all entries, substring match */ int opt_a = 0; /* all entries, substring match */
const struct aftype *ap;/* current address family */ const struct aftype *ap;/* current address family */
struct hwtype *hw; /* current hardware type */ const struct hwtype *hw;/* current hardware type */
int sockfd = 0; /* active socket descriptor */ int sockfd = 0; /* active socket descriptor */
int hw_set = 0; /* flag if hw-type was set (-H) */ int hw_set = 0; /* flag if hw-type was set (-H) */
char device[16] = ""; /* current device */ char device[16] = ""; /* current device */
...@@ -238,10 +238,10 @@ static int arp_del(char **args) ...@@ -238,10 +238,10 @@ static int arp_del(char **args)
} }
/* Get the hardware address to a specified interface name */ /* Get the hardware address to a specified interface name */
static int arp_getdevhw(char *ifname, struct sockaddr *sa, struct hwtype *hw) static int arp_getdevhw(char *ifname, struct sockaddr *sa, const struct hwtype *hw)
{ {
struct ifreq ifr; struct ifreq ifr;
struct hwtype *xhw; const struct hwtype *xhw;
safe_strncpy(ifr.ifr_name, ifname, IFNAMSIZ); safe_strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) < 0) { if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) < 0) {
...@@ -437,7 +437,7 @@ static int arp_file(char *name) ...@@ -437,7 +437,7 @@ static int arp_file(char *name)
static void arp_disp_2(const char *name, int type, int arp_flags, const char *hwa, const char *mask, const char *dev) static void arp_disp_2(const char *name, int type, int arp_flags, const char *hwa, const char *mask, const char *dev)
{ {
static int title = 0; static int title = 0;
struct hwtype *xhw; const struct hwtype *xhw;
char flags[10]; char flags[10];
xhw = get_hwntype(type); xhw = get_hwntype(type);
...@@ -486,7 +486,7 @@ static void arp_disp_2(const char *name, int type, int arp_flags, const char *hw ...@@ -486,7 +486,7 @@ static void arp_disp_2(const char *name, int type, int arp_flags, const char *hw
/* Print the contents of an ARP request block. */ /* Print the contents of an ARP request block. */
static void arp_disp(const char *name, const char *ip, int type, int arp_flags, const char *hwa, const char *mask, const char *dev) static void arp_disp(const char *name, const char *ip, int type, int arp_flags, const char *hwa, const char *mask, const char *dev)
{ {
struct hwtype *xhw; const struct hwtype *xhw;
xhw = get_hwntype(type); xhw = get_hwntype(type);
if (xhw == NULL) if (xhw == NULL)
......
...@@ -258,7 +258,7 @@ int main(int argc, char **argv) ...@@ -258,7 +258,7 @@ int main(int argc, char **argv)
struct sockaddr_in *sin = (struct sockaddr_in *)sa; struct sockaddr_in *sin = (struct sockaddr_in *)sa;
char host[128]; char host[128];
const struct aftype *ap; const struct aftype *ap;
struct hwtype *hw; const struct hwtype *hw;
struct ifreq ifr; struct ifreq ifr;
int goterr = 0, didnetmask = 0, neednetmask=0; int goterr = 0, didnetmask = 0, neednetmask=0;
char **spp; char **spp;
......
...@@ -61,7 +61,7 @@ void activate_init(void) ...@@ -61,7 +61,7 @@ void activate_init(void)
int activate_ld(const char *hwname, int fd) int activate_ld(const char *hwname, int fd)
{ {
struct hwtype *hw; const struct hwtype *hw;
hw = get_hwtype(hwname); hw = get_hwtype(hwname);
......
...@@ -77,7 +77,7 @@ extern struct hwtype ib_hwtype; ...@@ -77,7 +77,7 @@ extern struct hwtype ib_hwtype;
extern struct hwtype eui64_hwtype; extern struct hwtype eui64_hwtype;
static struct hwtype *hwtypes[] = static const struct hwtype * const hwtypes[] =
{ {
&loop_hwtype, &loop_hwtype,
...@@ -237,9 +237,9 @@ static void hwinit(void) ...@@ -237,9 +237,9 @@ static void hwinit(void)
} }
/* Check our hardware type table for this type. */ /* Check our hardware type table for this type. */
struct hwtype *get_hwtype(const char *name) const struct hwtype *get_hwtype(const char *name)
{ {
struct hwtype **hwp; const struct hwtype * const *hwp;
if (!sVhwinit) if (!sVhwinit)
hwinit(); hwinit();
...@@ -255,9 +255,9 @@ struct hwtype *get_hwtype(const char *name) ...@@ -255,9 +255,9 @@ struct hwtype *get_hwtype(const char *name)
/* Check our hardware type table for this type. */ /* Check our hardware type table for this type. */
struct hwtype *get_hwntype(int type) const struct hwtype *get_hwntype(int type)
{ {
struct hwtype **hwp; const struct hwtype * const *hwp;
if (!sVhwinit) if (!sVhwinit)
hwinit(); hwinit();
...@@ -275,7 +275,7 @@ struct hwtype *get_hwntype(int type) ...@@ -275,7 +275,7 @@ struct hwtype *get_hwntype(int type)
void print_hwlist(int type) { void print_hwlist(int type) {
int count = 0; int count = 0;
const char * txt; const char * txt;
struct hwtype **hwp; const struct hwtype * const *hwp;
if (!sVhwinit) if (!sVhwinit)
hwinit(); hwinit();
...@@ -295,7 +295,7 @@ void print_hwlist(int type) { ...@@ -295,7 +295,7 @@ void print_hwlist(int type) {
} }
/* return 1 if address is all zeros */ /* return 1 if address is all zeros */
int hw_null_address(struct hwtype *hw, void *ap) int hw_null_address(const struct hwtype *hw, void *ap)
{ {
unsigned int i; unsigned int i;
unsigned char *address = (unsigned char *)ap; unsigned char *address = (unsigned char *)ap;
......
...@@ -647,7 +647,7 @@ void ife_print_short(struct interface *ptr) ...@@ -647,7 +647,7 @@ void ife_print_short(struct interface *ptr)
void ife_print_long(struct interface *ptr) void ife_print_long(struct interface *ptr)
{ {
const struct aftype *ap; const struct aftype *ap;
struct hwtype *hw; const struct hwtype *hw;
int hf; int hf;
int can_compress = 0; int can_compress = 0;
unsigned long long rx, tx, short_rx, short_tx; unsigned long long rx, tx, short_rx, short_tx;
......
...@@ -67,13 +67,13 @@ struct hwtype { ...@@ -67,13 +67,13 @@ struct hwtype {
}; };
extern struct hwtype *get_hwtype(const char *name); extern const struct hwtype *get_hwtype(const char *name);
extern struct hwtype *get_hwntype(int type); extern const struct hwtype *get_hwntype(int type);
extern void print_hwlist(int type); extern void print_hwlist(int type);
extern const struct aftype *get_aftype(const char *name); extern const struct aftype *get_aftype(const char *name);
extern const struct aftype *get_afntype(int type); extern const struct aftype *get_afntype(int type);
extern void print_aflist(int type); extern void print_aflist(int type);
extern int hw_null_address(struct hwtype *hw, void *addr); extern int hw_null_address(const struct hwtype *hw, void *addr);
extern int getargs(char *string, char *arguments[]); extern int getargs(char *string, char *arguments[]);
......
...@@ -46,7 +46,7 @@ static char no_rarp_message[] = N_("This kernel does not support RARP.\n"); ...@@ -46,7 +46,7 @@ static char no_rarp_message[] = N_("This kernel does not support RARP.\n");
static char *Release = RELEASE; static char *Release = RELEASE;
static struct hwtype *hardware = NULL; static const struct hwtype *hardware = NULL;
/* Delete an entry from the RARP cache. */ /* Delete an entry from the RARP cache. */
static int rarp_delete(int fd, struct hostent *hp) static int rarp_delete(int fd, struct hostent *hp)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment