Commit a6118deb authored by Mike Frysinger's avatar Mike Frysinger

lib: af: constify aftype

Most callers never modify this structure, so constify it everywhere.
parent 2e15dacb
...@@ -88,7 +88,7 @@ int opt_v = 0; /* debugging output flag */ ...@@ -88,7 +88,7 @@ int opt_v = 0; /* debugging output flag */
int opt_D = 0; /* HW-address is devicename */ 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 */
struct aftype *ap; /* current address family */ const struct aftype *ap;/* current address family */
struct hwtype *hw; /* current hardware type */ 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) */
......
...@@ -257,7 +257,7 @@ int main(int argc, char **argv) ...@@ -257,7 +257,7 @@ int main(int argc, char **argv)
struct sockaddr *samask = (struct sockaddr *)&_samask; struct sockaddr *samask = (struct sockaddr *)&_samask;
struct sockaddr_in *sin = (struct sockaddr_in *)sa; struct sockaddr_in *sin = (struct sockaddr_in *)sa;
char host[128]; char host[128];
struct aftype *ap; const struct aftype *ap;
struct hwtype *hw; struct hwtype *hw;
struct ifreq ifr; struct ifreq ifr;
int goterr = 0, didnetmask = 0, neednetmask=0; int goterr = 0, didnetmask = 0, neednetmask=0;
......
...@@ -41,7 +41,7 @@ int flag_ash; ...@@ -41,7 +41,7 @@ int flag_ash;
int flag_bluetooth; int flag_bluetooth;
struct aftrans_t { static const struct aftrans_t {
char *alias; char *alias;
char *name; char *name;
int *flag; int *flag;
...@@ -117,7 +117,7 @@ extern struct aftype ash_aftype; ...@@ -117,7 +117,7 @@ extern struct aftype ash_aftype;
static short sVafinit = 0; static short sVafinit = 0;
struct aftype *aftypes[] = struct aftype * const aftypes[] =
{ {
#if HAVE_AFUNIX #if HAVE_AFUNIX
&unix_aftype, &unix_aftype,
...@@ -233,9 +233,9 @@ void aftrans_def(char *tool, char *argv0, char *dflt) ...@@ -233,9 +233,9 @@ void aftrans_def(char *tool, char *argv0, char *dflt)
/* Check our protocol family table for this family. */ /* Check our protocol family table for this family. */
struct aftype *get_aftype(const char *name) const struct aftype *get_aftype(const char *name)
{ {
struct aftype **afp; struct aftype * const *afp;
if (!sVafinit) if (!sVafinit)
afinit(); afinit();
...@@ -253,9 +253,9 @@ struct aftype *get_aftype(const char *name) ...@@ -253,9 +253,9 @@ struct aftype *get_aftype(const char *name)
/* Check our protocol family table for this family. */ /* Check our protocol family table for this family. */
struct aftype *get_afntype(int af) const struct aftype *get_afntype(int af)
{ {
struct aftype **afp; struct aftype * const *afp;
if (!sVafinit) if (!sVafinit)
afinit(); afinit();
...@@ -278,7 +278,7 @@ int get_socket_for_af(int af) ...@@ -278,7 +278,7 @@ int get_socket_for_af(int af)
int aftrans_opt(const char *arg) int aftrans_opt(const char *arg)
{ {
struct aftrans_t *paft; const struct aftrans_t *paft;
char *tmp1, *tmp2; char *tmp1, *tmp2;
char buf[256]; char buf[256];
...@@ -321,7 +321,7 @@ int aftrans_opt(const char *arg) ...@@ -321,7 +321,7 @@ int aftrans_opt(const char *arg)
void print_aflist(int type) { void print_aflist(int type) {
int count = 0; int count = 0;
const char * txt; const char * txt;
struct aftype **afp; struct aftype * const *afp;
if (!sVafinit) if (!sVafinit)
afinit(); afinit();
......
...@@ -75,7 +75,7 @@ void getroute_init(void) ...@@ -75,7 +75,7 @@ void getroute_init(void)
int route_info(const char *afname, int options) int route_info(const char *afname, int options)
{ {
struct aftype *ap; const struct aftype *ap;
char *tmp1, *tmp2; char *tmp1, *tmp2;
int found = E_NOTFOUND, rc; int found = E_NOTFOUND, rc;
char buf[256]; char buf[256];
......
...@@ -646,7 +646,7 @@ void ife_print_short(struct interface *ptr) ...@@ -646,7 +646,7 @@ void ife_print_short(struct interface *ptr)
void ife_print_long(struct interface *ptr) void ife_print_long(struct interface *ptr)
{ {
struct aftype *ap; const struct aftype *ap;
struct hwtype *hw; struct hwtype *hw;
int hf; int hf;
int can_compress = 0; int can_compress = 0;
...@@ -656,13 +656,13 @@ void ife_print_long(struct interface *ptr) ...@@ -656,13 +656,13 @@ void ife_print_long(struct interface *ptr)
static char flags[200]; static char flags[200];
#if HAVE_AFIPX #if HAVE_AFIPX
static struct aftype *ipxtype = NULL; static const struct aftype *ipxtype = NULL;
#endif #endif
#if HAVE_AFECONET #if HAVE_AFECONET
static struct aftype *ectype = NULL; static const struct aftype *ectype = NULL;
#endif #endif
#if HAVE_AFATALK #if HAVE_AFATALK
static struct aftype *ddptype = NULL; static const struct aftype *ddptype = NULL;
#endif #endif
#if HAVE_AFINET6 #if HAVE_AFINET6
FILE *f; FILE *f;
......
...@@ -40,7 +40,7 @@ int IPX_rprint(int options) ...@@ -40,7 +40,7 @@ int IPX_rprint(int options)
char router_node[128]; char router_node[128];
int num; int num;
FILE *fp; FILE *fp;
struct aftype *ap; const struct aftype *ap;
struct sockaddr sa; struct sockaddr sa;
fp = fopen(_PATH_PROCNET_IPX_ROUTE1, "r"); fp = fopen(_PATH_PROCNET_IPX_ROUTE1, "r");
......
...@@ -54,7 +54,7 @@ struct masq { ...@@ -54,7 +54,7 @@ struct masq {
short pdelta; /* Delta in sequence numbers before last */ short pdelta; /* Delta in sequence numbers before last */
}; };
static struct aftype *ap; /* current address family */ static const struct aftype *ap; /* current address family */
static int has_pdelta; static int has_pdelta;
static void print_masq(struct masq *ms, int numeric_host, int numeric_port, static void print_masq(struct masq *ms, int numeric_host, int numeric_port,
......
...@@ -52,7 +52,7 @@ struct aftype { ...@@ -52,7 +52,7 @@ struct aftype {
const char *flag_file; const char *flag_file;
}; };
extern struct aftype *aftypes[]; extern struct aftype * const aftypes[];
/* This structure defines hardware protocols and their handlers. */ /* This structure defines hardware protocols and their handlers. */
struct hwtype { struct hwtype {
...@@ -70,8 +70,8 @@ struct hwtype { ...@@ -70,8 +70,8 @@ struct hwtype {
extern struct hwtype *get_hwtype(const char *name); extern struct hwtype *get_hwtype(const char *name);
extern struct hwtype *get_hwntype(int type); extern struct hwtype *get_hwntype(int type);
extern void print_hwlist(int type); extern void print_hwlist(int type);
extern struct aftype *get_aftype(const char *name); extern const struct aftype *get_aftype(const char *name);
extern 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(struct hwtype *hw, void *addr);
......
...@@ -72,7 +72,7 @@ void setroute_init(void) ...@@ -72,7 +72,7 @@ void setroute_init(void)
int route_edit(int action, const char *afname, int options, char **argv) int route_edit(int action, const char *afname, int options, char **argv)
{ {
struct aftype *ap; const struct aftype *ap;
ap = get_aftype(afname); ap = get_aftype(afname);
......
...@@ -20,7 +20,7 @@ int skfd = -1; /* generic raw socket desc. */ ...@@ -20,7 +20,7 @@ int skfd = -1; /* generic raw socket desc. */
int sockets_open(int family) int sockets_open(int family)
{ {
struct aftype **aft; struct aftype * const *aft;
int sfd = -1; int sfd = -1;
static int force = -1; static int force = -1;
......
...@@ -622,7 +622,7 @@ static void igmp_do_one(int lnr, const char *line,const char *prot) ...@@ -622,7 +622,7 @@ static void igmp_do_one(int lnr, const char *line,const char *prot)
#else #else
struct sockaddr_in mcastaddr; struct sockaddr_in mcastaddr;
#endif #endif
struct aftype *ap; const struct aftype *ap;
static int idx_flag = 0; static int idx_flag = 0;
static int igmp6_flag = 0; static int igmp6_flag = 0;
static char device[16]; static char device[16];
...@@ -782,7 +782,7 @@ static int ip_parse_dots(uint32_t *addr, char const *src) { ...@@ -782,7 +782,7 @@ static int ip_parse_dots(uint32_t *addr, char const *src) {
static void print_ip_service(struct sockaddr_in *addr, char const *protname, static void print_ip_service(struct sockaddr_in *addr, char const *protname,
char *buf, unsigned size) { char *buf, unsigned size) {
struct aftype *ap; const struct aftype *ap;
if(size == 0) return; if(size == 0) return;
...@@ -930,7 +930,7 @@ static int sctp_info(void) { ...@@ -930,7 +930,7 @@ static int sctp_info(void) {
return sctp_info_assocs(); return sctp_info_assocs();
} }
static void addr_do_one(char *buf, size_t buf_len, size_t short_len, struct aftype *ap, static void addr_do_one(char *buf, size_t buf_len, size_t short_len, const struct aftype *ap,
#if HAVE_AFINET6 #if HAVE_AFINET6
struct sockaddr_in6 *addr, struct sockaddr_in6 *addr,
#else #else
...@@ -963,7 +963,7 @@ static void tcp_do_one(int lnr, const char *line, const char *prot) ...@@ -963,7 +963,7 @@ static void tcp_do_one(int lnr, const char *line, const char *prot)
unsigned long rxq, txq, time_len, retr, inode; unsigned long rxq, txq, time_len, retr, inode;
int num, local_port, rem_port, d, state, uid, timer_run, timeout; int num, local_port, rem_port, d, state, uid, timer_run, timeout;
char rem_addr[128], local_addr[128], timers[64]; char rem_addr[128], local_addr[128], timers[64];
struct aftype *ap; const struct aftype *ap;
#if HAVE_AFINET6 #if HAVE_AFINET6
struct sockaddr_in6 localaddr, remaddr; struct sockaddr_in6 localaddr, remaddr;
char addr6[INET6_ADDRSTRLEN]; char addr6[INET6_ADDRSTRLEN];
...@@ -1082,7 +1082,7 @@ static void udp_do_one(int lnr, const char *line,const char *prot) ...@@ -1082,7 +1082,7 @@ static void udp_do_one(int lnr, const char *line,const char *prot)
#else #else
struct sockaddr_in localaddr, remaddr; struct sockaddr_in localaddr, remaddr;
#endif #endif
struct aftype *ap; const struct aftype *ap;
unsigned long rxq, txq, time_len, retr, inode; unsigned long rxq, txq, time_len, retr, inode;
if (lnr == 0) if (lnr == 0)
...@@ -1210,7 +1210,7 @@ static void raw_do_one(int lnr, const char *line,const char *prot) ...@@ -1210,7 +1210,7 @@ static void raw_do_one(int lnr, const char *line,const char *prot)
#else #else
struct sockaddr_in localaddr, remaddr; struct sockaddr_in localaddr, remaddr;
#endif #endif
struct aftype *ap; const struct aftype *ap;
unsigned long rxq, txq, time_len, retr, inode; unsigned long rxq, txq, time_len, retr, inode;
if (lnr == 0) if (lnr == 0)
...@@ -1560,7 +1560,7 @@ static int ipx_info(void) ...@@ -1560,7 +1560,7 @@ static int ipx_info(void)
unsigned int uid; unsigned int uid;
char *st; char *st;
int nc; int nc;
struct aftype *ap; const struct aftype *ap;
struct passwd *pw; struct passwd *pw;
char sad[50], dad[50]; char sad[50], dad[50];
struct sockaddr sa; struct sockaddr sa;
......
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