Commit d1f28cf1 authored by Stephen Hemminger's avatar Stephen Hemminger

ip: make local functions static

parent 14645ec2
...@@ -46,7 +46,7 @@ static int show_mark(FILE *fp, const struct nlmsghdr *n) ...@@ -46,7 +46,7 @@ static int show_mark(FILE *fp, const struct nlmsghdr *n)
return 0; return 0;
} }
int accept_msg(const struct sockaddr_nl *who, static int accept_msg(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg) struct nlmsghdr *n, void *arg)
{ {
FILE *fp = arg; FILE *fp = arg;
......
...@@ -112,7 +112,7 @@ errout: ...@@ -112,7 +112,7 @@ errout:
return ret; return ret;
} }
void print_ctrl_cmd_flags(FILE *fp, __u32 fl) static void print_ctrl_cmd_flags(FILE *fp, __u32 fl)
{ {
fprintf(fp, "\n\t\tCapabilities (0x%x):\n ", fl); fprintf(fp, "\n\t\tCapabilities (0x%x):\n ", fl);
if (!fl) { if (!fl) {
......
...@@ -89,7 +89,7 @@ static void usage(void) ...@@ -89,7 +89,7 @@ static void usage(void)
exit(-1); exit(-1);
} }
void print_link_flags(FILE *fp, unsigned flags, unsigned mdown) static void print_link_flags(FILE *fp, unsigned flags, unsigned mdown)
{ {
fprintf(fp, "<"); fprintf(fp, "<");
if (flags & IFF_UP && !(flags & IFF_RUNNING)) if (flags & IFF_UP && !(flags & IFF_RUNNING))
...@@ -699,8 +699,8 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n, ...@@ -699,8 +699,8 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n,
return 0; return 0;
} }
int print_addrinfo_primary(const struct sockaddr_nl *who, struct nlmsghdr *n, static int print_addrinfo_primary(const struct sockaddr_nl *who,
void *arg) struct nlmsghdr *n, void *arg)
{ {
struct ifaddrmsg *ifa = NLMSG_DATA(n); struct ifaddrmsg *ifa = NLMSG_DATA(n);
...@@ -710,8 +710,8 @@ int print_addrinfo_primary(const struct sockaddr_nl *who, struct nlmsghdr *n, ...@@ -710,8 +710,8 @@ int print_addrinfo_primary(const struct sockaddr_nl *who, struct nlmsghdr *n,
return print_addrinfo(who, n, arg); return print_addrinfo(who, n, arg);
} }
int print_addrinfo_secondary(const struct sockaddr_nl *who, struct nlmsghdr *n, static int print_addrinfo_secondary(const struct sockaddr_nl *who,
void *arg) struct nlmsghdr *n, void *arg)
{ {
struct ifaddrmsg *ifa = NLMSG_DATA(n); struct ifaddrmsg *ifa = NLMSG_DATA(n);
......
...@@ -135,7 +135,7 @@ struct link_util *get_link_kind(const char *id) ...@@ -135,7 +135,7 @@ struct link_util *get_link_kind(const char *id)
return l; return l;
} }
int get_link_mode(const char *mode) static int get_link_mode(const char *mode)
{ {
if (strcasecmp(mode, "default") == 0) if (strcasecmp(mode, "default") == 0)
return IF_LINK_MODE_DEFAULT; return IF_LINK_MODE_DEFAULT;
...@@ -194,7 +194,7 @@ struct iplink_req { ...@@ -194,7 +194,7 @@ struct iplink_req {
char buf[1024]; char buf[1024];
}; };
int iplink_parse_vf(int vf, int *argcp, char ***argvp, static int iplink_parse_vf(int vf, int *argcp, char ***argvp,
struct iplink_req *req) struct iplink_req *req)
{ {
int len, argc = *argcp; int len, argc = *argcp;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "rt_names.h" #include "rt_names.h"
#include "utils.h" #include "utils.h"
#include "ip_common.h"
static struct { static struct {
char *dev; char *dev;
...@@ -70,7 +71,7 @@ struct ma_info ...@@ -70,7 +71,7 @@ struct ma_info
inet_prefix addr; inet_prefix addr;
}; };
void maddr_ins(struct ma_info **lst, struct ma_info *m) static void maddr_ins(struct ma_info **lst, struct ma_info *m)
{ {
struct ma_info *mp; struct ma_info *mp;
...@@ -82,7 +83,7 @@ void maddr_ins(struct ma_info **lst, struct ma_info *m) ...@@ -82,7 +83,7 @@ void maddr_ins(struct ma_info **lst, struct ma_info *m)
*lst = m; *lst = m;
} }
void read_dev_mcast(struct ma_info **result_p) static void read_dev_mcast(struct ma_info **result_p)
{ {
char buf[256]; char buf[256];
FILE *fp = fopen("/proc/net/dev_mcast", "r"); FILE *fp = fopen("/proc/net/dev_mcast", "r");
...@@ -119,7 +120,7 @@ void read_dev_mcast(struct ma_info **result_p) ...@@ -119,7 +120,7 @@ void read_dev_mcast(struct ma_info **result_p)
fclose(fp); fclose(fp);
} }
void read_igmp(struct ma_info **result_p) static void read_igmp(struct ma_info **result_p)
{ {
struct ma_info m; struct ma_info m;
char buf[256]; char buf[256];
...@@ -158,7 +159,7 @@ void read_igmp(struct ma_info **result_p) ...@@ -158,7 +159,7 @@ void read_igmp(struct ma_info **result_p)
} }
void read_igmp6(struct ma_info **result_p) static void read_igmp6(struct ma_info **result_p)
{ {
char buf[256]; char buf[256];
FILE *fp = fopen("/proc/net/igmp6", "r"); FILE *fp = fopen("/proc/net/igmp6", "r");
...@@ -275,7 +276,7 @@ static int multiaddr_list(int argc, char **argv) ...@@ -275,7 +276,7 @@ static int multiaddr_list(int argc, char **argv)
return 0; return 0;
} }
int multiaddr_modify(int cmd, int argc, char **argv) static int multiaddr_modify(int cmd, int argc, char **argv)
{ {
struct ifreq ifr; struct ifreq ifr;
int fd; int fd;
......
...@@ -37,7 +37,7 @@ static void usage(void) ...@@ -37,7 +37,7 @@ static void usage(void)
} }
int accept_msg(const struct sockaddr_nl *who, static int accept_msg(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg) struct nlmsghdr *n, void *arg)
{ {
FILE *fp = (FILE*)arg; FILE *fp = (FILE*)arg;
......
...@@ -52,7 +52,7 @@ static void usage(void) ...@@ -52,7 +52,7 @@ static void usage(void)
exit(-1); exit(-1);
} }
int nud_state_a2n(unsigned *state, char *arg) static int nud_state_a2n(unsigned *state, const char *arg)
{ {
if (matches(arg, "permanent") == 0) if (matches(arg, "permanent") == 0)
*state = NUD_PERMANENT; *state = NUD_PERMANENT;
...@@ -313,13 +313,13 @@ int print_neigh(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) ...@@ -313,13 +313,13 @@ int print_neigh(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
return 0; return 0;
} }
void ipneigh_reset_filter() void ipneigh_reset_filter(void)
{ {
memset(&filter, 0, sizeof(filter)); memset(&filter, 0, sizeof(filter));
filter.state = ~0; filter.state = ~0;
} }
int do_show_or_flush(int argc, char **argv, int flush) static int do_show_or_flush(int argc, char **argv, int flush)
{ {
char *filter_dev = NULL; char *filter_dev = NULL;
int state_given = 0; int state_given = 0;
......
...@@ -119,12 +119,12 @@ int print_netconf(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) ...@@ -119,12 +119,12 @@ int print_netconf(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
return 0; return 0;
} }
void ipnetconf_reset_filter(void) static void ipnetconf_reset_filter(void)
{ {
memset(&filter, 0, sizeof(filter)); memset(&filter, 0, sizeof(filter));
} }
int do_show(int argc, char **argv) static int do_show(int argc, char **argv)
{ {
struct { struct {
struct nlmsghdr n; struct nlmsghdr n;
......
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
#include <string.h> #include <string.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/icmp6.h> #include <netinet/icmp6.h>
#include "utils.h" #include "utils.h"
#include "ip_common.h"
/* prefix flags; see kernel's net/ipv6/addrconf.c and include/net/if_inet6.h */ /* prefix flags; see kernel's net/ipv6/addrconf.c and include/net/if_inet6.h */
#define IF_PREFIX_ONLINK 0x01 #define IF_PREFIX_ONLINK 0x01
......
...@@ -124,7 +124,7 @@ static int flush_update(void) ...@@ -124,7 +124,7 @@ static int flush_update(void)
return 0; return 0;
} }
int filter_nlmsg(struct nlmsghdr *n, struct rtattr **tb, int host_len) static int filter_nlmsg(struct nlmsghdr *n, struct rtattr **tb, int host_len)
{ {
struct rtmsg *r = NLMSG_DATA(n); struct rtmsg *r = NLMSG_DATA(n);
inet_prefix dst; inet_prefix dst;
...@@ -263,7 +263,7 @@ int filter_nlmsg(struct nlmsghdr *n, struct rtattr **tb, int host_len) ...@@ -263,7 +263,7 @@ int filter_nlmsg(struct nlmsghdr *n, struct rtattr **tb, int host_len)
return 1; return 1;
} }
int calc_host_len(struct rtmsg *r) static int calc_host_len(const struct rtmsg *r)
{ {
if (r->rtm_family == AF_INET6) if (r->rtm_family == AF_INET6)
return 128; return 128;
...@@ -625,7 +625,9 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) ...@@ -625,7 +625,9 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
} }
int parse_one_nh(struct rtmsg *r, struct rtattr *rta, struct rtnexthop *rtnh, int *argcp, char ***argvp) static int parse_one_nh(struct rtmsg *r, struct rtattr *rta,
struct rtnexthop *rtnh,
int *argcp, char ***argvp)
{ {
int argc = *argcp; int argc = *argcp;
char **argv = *argvp; char **argv = *argvp;
...@@ -668,7 +670,8 @@ int parse_one_nh(struct rtmsg *r, struct rtattr *rta, struct rtnexthop *rtnh, in ...@@ -668,7 +670,8 @@ int parse_one_nh(struct rtmsg *r, struct rtattr *rta, struct rtnexthop *rtnh, in
return 0; return 0;
} }
int parse_nexthops(struct nlmsghdr *n, struct rtmsg *r, int argc, char **argv) static int parse_nexthops(struct nlmsghdr *n, struct rtmsg *r,
int argc, char **argv)
{ {
char buf[1024]; char buf[1024];
struct rtattr *rta = (void*)buf; struct rtattr *rta = (void*)buf;
...@@ -699,8 +702,7 @@ int parse_nexthops(struct nlmsghdr *n, struct rtmsg *r, int argc, char **argv) ...@@ -699,8 +702,7 @@ int parse_nexthops(struct nlmsghdr *n, struct rtmsg *r, int argc, char **argv)
return 0; return 0;
} }
static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
{ {
struct { struct {
struct nlmsghdr n; struct nlmsghdr n;
...@@ -1070,7 +1072,8 @@ static int iproute_flush_cache(void) ...@@ -1070,7 +1072,8 @@ static int iproute_flush_cache(void)
static __u32 route_dump_magic = 0x45311224; static __u32 route_dump_magic = 0x45311224;
int save_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) static int save_route(const struct sockaddr_nl *who, struct nlmsghdr *n,
void *arg)
{ {
int ret; int ret;
int len = n->nlmsg_len; int len = n->nlmsg_len;
...@@ -1363,7 +1366,7 @@ static int iproute_list_flush_or_save(int argc, char **argv, int action) ...@@ -1363,7 +1366,7 @@ static int iproute_list_flush_or_save(int argc, char **argv, int action)
} }
int iproute_get(int argc, char **argv) static int iproute_get(int argc, char **argv)
{ {
struct { struct {
struct nlmsghdr n; struct nlmsghdr n;
...@@ -1528,7 +1531,8 @@ int iproute_get(int argc, char **argv) ...@@ -1528,7 +1531,8 @@ int iproute_get(int argc, char **argv)
exit(0); exit(0);
} }
int restore_handler(const struct sockaddr_nl *nl, struct nlmsghdr *n, void *arg) static int restore_handler(const struct sockaddr_nl *nl, struct nlmsghdr *n,
void *arg)
{ {
int ret; int ret;
...@@ -1562,7 +1566,7 @@ static int route_dump_check_magic(void) ...@@ -1562,7 +1566,7 @@ static int route_dump_check_magic(void)
return 0; return 0;
} }
int iproute_restore(void) static int iproute_restore(void)
{ {
if (route_dump_check_magic()) if (route_dump_check_magic())
exit(-1); exit(-1);
...@@ -1584,7 +1588,7 @@ static int iproute_showdump(void) ...@@ -1584,7 +1588,7 @@ static int iproute_showdump(void)
exit(rtnl_from_file(stdin, &show_handler, NULL)); exit(rtnl_from_file(stdin, &show_handler, NULL));
} }
void iproute_reset_filter() void iproute_reset_filter(void)
{ {
memset(&filter, 0, sizeof(filter)); memset(&filter, 0, sizeof(filter));
filter.mdst.bitlen = -1; filter.mdst.bitlen = -1;
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "utils.h" #include "utils.h"
#include "xfrm.h" #include "xfrm.h"
#include "ip_common.h"
#define STRBUF_SIZE (128) #define STRBUF_SIZE (128)
#define STRBUF_CAT(buf, str) \ #define STRBUF_CAT(buf, str) \
......
...@@ -56,7 +56,7 @@ static int dump_msg(const struct sockaddr_nl *who, struct nlmsghdr *n, ...@@ -56,7 +56,7 @@ static int dump_msg(const struct sockaddr_nl *who, struct nlmsghdr *n,
return 0; return 0;
} }
void usage(void) static void usage(void)
{ {
fprintf(stderr, "Usage: rtmon file FILE [ all | LISTofOBJECTS]\n"); fprintf(stderr, "Usage: rtmon file FILE [ all | LISTofOBJECTS]\n");
fprintf(stderr, "LISTofOBJECTS := [ link ] [ address ] [ route ]\n"); fprintf(stderr, "LISTofOBJECTS := [ link ] [ address ] [ route ]\n");
......
...@@ -206,7 +206,7 @@ static int xfrm_report_print(const struct sockaddr_nl *who, ...@@ -206,7 +206,7 @@ static int xfrm_report_print(const struct sockaddr_nl *who,
return 0; return 0;
} }
void xfrm_ae_flags_print(__u32 flags, void *arg) static void xfrm_ae_flags_print(__u32 flags, void *arg)
{ {
FILE *fp = (FILE*)arg; FILE *fp = (FILE*)arg;
fprintf(fp, " (0x%x) ", flags); fprintf(fp, " (0x%x) ", flags);
......
...@@ -896,7 +896,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall) ...@@ -896,7 +896,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
exit(0); exit(0);
} }
int print_spdinfo( struct nlmsghdr *n, void *arg) static int print_spdinfo( struct nlmsghdr *n, void *arg)
{ {
FILE *fp = (FILE*)arg; FILE *fp = (FILE*)arg;
__u32 *f = NLMSG_DATA(n); __u32 *f = NLMSG_DATA(n);
......
...@@ -1053,7 +1053,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall) ...@@ -1053,7 +1053,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall)
exit(0); exit(0);
} }
int print_sadinfo(struct nlmsghdr *n, void *arg) static int print_sadinfo(struct nlmsghdr *n, void *arg)
{ {
FILE *fp = (FILE*)arg; FILE *fp = (FILE*)arg;
__u32 *f = NLMSG_DATA(n); __u32 *f = NLMSG_DATA(n);
......
...@@ -92,7 +92,7 @@ int broadcast_rate = 1000; ...@@ -92,7 +92,7 @@ int broadcast_rate = 1000;
int broadcast_burst = 3000; int broadcast_burst = 3000;
int poll_timeout = 30000; int poll_timeout = 30000;
void usage(void) static void usage(void)
{ {
fprintf(stderr, fprintf(stderr,
"Usage: arpd [ -lkh? ] [ -a N ] [ -b dbase ] [ -B number ]" "Usage: arpd [ -lkh? ] [ -a N ] [ -b dbase ] [ -B number ]"
...@@ -100,7 +100,7 @@ void usage(void) ...@@ -100,7 +100,7 @@ void usage(void)
exit(1); exit(1);
} }
int handle_if(int ifindex) static int handle_if(int ifindex)
{ {
int i; int i;
...@@ -115,7 +115,7 @@ int handle_if(int ifindex) ...@@ -115,7 +115,7 @@ int handle_if(int ifindex)
int sysctl_adjusted; int sysctl_adjusted;
void do_sysctl_adjustments(void) static void do_sysctl_adjustments(void)
{ {
int i; int i;
...@@ -148,7 +148,7 @@ void do_sysctl_adjustments(void) ...@@ -148,7 +148,7 @@ void do_sysctl_adjustments(void)
sysctl_adjusted = 1; sysctl_adjusted = 1;
} }
void undo_sysctl_adjustments(void) static void undo_sysctl_adjustments(void)
{ {
int i; int i;
...@@ -178,7 +178,7 @@ void undo_sysctl_adjustments(void) ...@@ -178,7 +178,7 @@ void undo_sysctl_adjustments(void)
} }
int send_probe(int ifindex, __u32 addr) static int send_probe(int ifindex, __u32 addr)
{ {
struct ifreq ifr; struct ifreq ifr;
struct sockaddr_in dst; struct sockaddr_in dst;
...@@ -238,7 +238,7 @@ int send_probe(int ifindex, __u32 addr) ...@@ -238,7 +238,7 @@ int send_probe(int ifindex, __u32 addr)
/* Be very tough on sending probes: 1 per second with burst of 3. */ /* Be very tough on sending probes: 1 per second with burst of 3. */
int queue_active_probe(int ifindex, __u32 addr) static int queue_active_probe(int ifindex, __u32 addr)
{ {
static struct timeval prev; static struct timeval prev;
static int buckets; static int buckets;
...@@ -262,7 +262,7 @@ int queue_active_probe(int ifindex, __u32 addr) ...@@ -262,7 +262,7 @@ int queue_active_probe(int ifindex, __u32 addr)
return -1; return -1;
} }
int respond_to_kernel(int ifindex, __u32 addr, char *lla, int llalen) static int respond_to_kernel(int ifindex, __u32 addr, char *lla, int llalen)
{ {
struct { struct {
struct nlmsghdr n; struct nlmsghdr n;
...@@ -286,7 +286,7 @@ int respond_to_kernel(int ifindex, __u32 addr, char *lla, int llalen) ...@@ -286,7 +286,7 @@ int respond_to_kernel(int ifindex, __u32 addr, char *lla, int llalen)
return rtnl_send(&rth, &req, req.n.nlmsg_len) <= 0; return rtnl_send(&rth, &req, req.n.nlmsg_len) <= 0;
} }
void prepare_neg_entry(__u8 *ndata, __u32 stamp) static void prepare_neg_entry(__u8 *ndata, __u32 stamp)
{ {
ndata[0] = 0xFF; ndata[0] = 0xFF;
ndata[1] = 0; ndata[1] = 0;
...@@ -297,7 +297,7 @@ void prepare_neg_entry(__u8 *ndata, __u32 stamp) ...@@ -297,7 +297,7 @@ void prepare_neg_entry(__u8 *ndata, __u32 stamp)
} }
int do_one_request(struct nlmsghdr *n) static int do_one_request(struct nlmsghdr *n)
{ {
struct ndmsg *ndm = NLMSG_DATA(n); struct ndmsg *ndm = NLMSG_DATA(n);
int len = n->nlmsg_len; int len = n->nlmsg_len;
...@@ -426,12 +426,12 @@ int do_one_request(struct nlmsghdr *n) ...@@ -426,12 +426,12 @@ int do_one_request(struct nlmsghdr *n)
return 0; return 0;
} }
void load_initial_table(void) static void load_initial_table(void)
{ {
rtnl_wilddump_request(&rth, AF_INET, RTM_GETNEIGH); rtnl_wilddump_request(&rth, AF_INET, RTM_GETNEIGH);
} }
void get_kern_msg(void) static void get_kern_msg(void)
{ {
int status; int status;
struct nlmsghdr *h; struct nlmsghdr *h;
...@@ -477,7 +477,7 @@ void get_kern_msg(void) ...@@ -477,7 +477,7 @@ void get_kern_msg(void)
} }
/* Receive gratuitous ARP messages and store them, that's all. */ /* Receive gratuitous ARP messages and store them, that's all. */
void get_arp_pkt(void) static void get_arp_pkt(void)
{ {
unsigned char buf[1024]; unsigned char buf[1024];
struct sockaddr_ll sll; struct sockaddr_ll sll;
...@@ -532,7 +532,7 @@ void get_arp_pkt(void) ...@@ -532,7 +532,7 @@ void get_arp_pkt(void)
dbase->put(dbase, &dbkey, &dbdat, 0); dbase->put(dbase, &dbkey, &dbdat, 0);
} }
void catch_signal(int sig, void (*handler)(int)) static void catch_signal(int sig, void (*handler)(int))
{ {
struct sigaction sa; struct sigaction sa;
...@@ -548,21 +548,21 @@ void catch_signal(int sig, void (*handler)(int)) ...@@ -548,21 +548,21 @@ void catch_signal(int sig, void (*handler)(int))
sigjmp_buf env; sigjmp_buf env;
volatile int in_poll; volatile int in_poll;
void sig_exit(int signo) static void sig_exit(int signo)
{ {
do_exit = 1; do_exit = 1;
if (in_poll) if (in_poll)
siglongjmp(env, 1); siglongjmp(env, 1);
} }
void sig_sync(int signo) static void sig_sync(int signo)
{ {
do_sync = 1; do_sync = 1;
if (in_poll) if (in_poll)
siglongjmp(env, 1); siglongjmp(env, 1);
} }
void sig_stats(int signo) static void sig_stats(int signo)
{ {
do_sync = 1; do_sync = 1;
do_stats = 1; do_stats = 1;
...@@ -570,7 +570,7 @@ void sig_stats(int signo) ...@@ -570,7 +570,7 @@ void sig_stats(int signo)
siglongjmp(env, 1); siglongjmp(env, 1);
} }
void send_stats(void) static void send_stats(void)
{ {
syslog(LOG_INFO, "arp_rcv: n%lu c%lu app_rcv: tot %lu hits %lu bad %lu neg %lu sup %lu", syslog(LOG_INFO, "arp_rcv: n%lu c%lu app_rcv: tot %lu hits %lu bad %lu neg %lu sup %lu",
stats.arp_new, stats.arp_change, stats.arp_new, stats.arp_change,
......
...@@ -115,7 +115,7 @@ static int get_nlmsg(const struct sockaddr_nl *who, ...@@ -115,7 +115,7 @@ static int get_nlmsg(const struct sockaddr_nl *who,
return 0; return 0;
} }
void load_info(void) static void load_info(void)
{ {
struct ifstat_ent *db, *n; struct ifstat_ent *db, *n;
struct rtnl_handle rth; struct rtnl_handle rth;
...@@ -146,7 +146,7 @@ void load_info(void) ...@@ -146,7 +146,7 @@ void load_info(void)
} }
} }
void load_raw_table(FILE *fp) static void load_raw_table(FILE *fp)
{ {
char buf[4096]; char buf[4096];
struct ifstat_ent *db = NULL; struct ifstat_ent *db = NULL;
...@@ -209,7 +209,7 @@ void load_raw_table(FILE *fp) ...@@ -209,7 +209,7 @@ void load_raw_table(FILE *fp)
} }
} }
void dump_raw_db(FILE *fp, int to_hist) static void dump_raw_db(FILE *fp, int to_hist)
{ {
struct ifstat_ent *n, *h; struct ifstat_ent *n, *h;
h = hist_db; h = hist_db;
...@@ -244,7 +244,8 @@ static const unsigned long long giga = 1000000000ull; ...@@ -244,7 +244,8 @@ static const unsigned long long giga = 1000000000ull;
static const unsigned long long mega = 1000000; static const unsigned long long mega = 1000000;
static const unsigned long long kilo = 1000; static const unsigned long long kilo = 1000;
void format_rate(FILE *fp, unsigned long long *vals, double *rates, int i) static void format_rate(FILE *fp, unsigned long long *vals,
double *rates, int i)
{ {
char temp[64]; char temp[64];
if (vals[i] > giga) if (vals[i] > giga)
...@@ -264,7 +265,7 @@ void format_rate(FILE *fp, unsigned long long *vals, double *rates, int i) ...@@ -264,7 +265,7 @@ void format_rate(FILE *fp, unsigned long long *vals, double *rates, int i)
fprintf(fp, "%-6u ", (unsigned)rates[i]); fprintf(fp, "%-6u ", (unsigned)rates[i]);
} }
void format_pair(FILE *fp, unsigned long long *vals, int i, int k) static void format_pair(FILE *fp, unsigned long long *vals, int i, int k)
{ {
char temp[64]; char temp[64];
if (vals[i] > giga) if (vals[i] > giga)
...@@ -284,7 +285,7 @@ void format_pair(FILE *fp, unsigned long long *vals, int i, int k) ...@@ -284,7 +285,7 @@ void format_pair(FILE *fp, unsigned long long *vals, int i, int k)
fprintf(fp, "%-6u ", (unsigned)vals[k]); fprintf(fp, "%-6u ", (unsigned)vals[k]);
} }
void print_head(FILE *fp) static void print_head(FILE *fp)
{ {
fprintf(fp, "#%s\n", info_source); fprintf(fp, "#%s\n", info_source);
fprintf(fp, "%-15s ", "Interface"); fprintf(fp, "%-15s ", "Interface");
...@@ -327,7 +328,8 @@ void print_head(FILE *fp) ...@@ -327,7 +328,8 @@ void print_head(FILE *fp)
} }
} }
void print_one_if(FILE *fp, struct ifstat_ent *n, unsigned long long *vals) static void print_one_if(FILE *fp, struct ifstat_ent *n,
unsigned long long *vals)
{ {
int i; int i;
fprintf(fp, "%-15s ", n->name); fprintf(fp, "%-15s ", n->name);
...@@ -374,7 +376,7 @@ void print_one_if(FILE *fp, struct ifstat_ent *n, unsigned long long *vals) ...@@ -374,7 +376,7 @@ void print_one_if(FILE *fp, struct ifstat_ent *n, unsigned long long *vals)
} }
void dump_kern_db(FILE *fp) static void dump_kern_db(FILE *fp)
{ {
struct ifstat_ent *n; struct ifstat_ent *n;
...@@ -388,7 +390,7 @@ void dump_kern_db(FILE *fp) ...@@ -388,7 +390,7 @@ void dump_kern_db(FILE *fp)
} }
void dump_incr_db(FILE *fp) static void dump_incr_db(FILE *fp)
{ {
struct ifstat_ent *n, *h; struct ifstat_ent *n, *h;
h = hist_db; h = hist_db;
...@@ -419,11 +421,11 @@ void dump_incr_db(FILE *fp) ...@@ -419,11 +421,11 @@ void dump_incr_db(FILE *fp)
static int children; static int children;
void sigchild(int signo) static void sigchild(int signo)
{ {
} }
void update_db(int interval) static void update_db(int interval)
{ {
struct ifstat_ent *n, *h; struct ifstat_ent *n, *h;
...@@ -482,7 +484,7 @@ void update_db(int interval) ...@@ -482,7 +484,7 @@ void update_db(int interval)
#define T_DIFF(a,b) (((a).tv_sec-(b).tv_sec)*1000 + ((a).tv_usec-(b).tv_usec)/1000) #define T_DIFF(a,b) (((a).tv_sec-(b).tv_sec)*1000 + ((a).tv_usec-(b).tv_usec)/1000)
void server_loop(int fd) static void server_loop(int fd)
{ {
struct timeval snaptime = { 0 }; struct timeval snaptime = { 0 };
struct pollfd p; struct pollfd p;
...@@ -534,7 +536,7 @@ void server_loop(int fd) ...@@ -534,7 +536,7 @@ void server_loop(int fd)
} }
} }
int verify_forging(int fd) static int verify_forging(int fd)
{ {
struct ucred cred; struct ucred cred;
socklen_t olen = sizeof(cred); socklen_t olen = sizeof(cred);
......
...@@ -55,17 +55,17 @@ static int generic_proc_open(const char *env, char *name) ...@@ -55,17 +55,17 @@ static int generic_proc_open(const char *env, char *name)
return open(p, O_RDONLY); return open(p, O_RDONLY);
} }
int net_netstat_open(void) static int net_netstat_open(void)
{ {
return generic_proc_open("PROC_NET_NETSTAT", "net/netstat"); return generic_proc_open("PROC_NET_NETSTAT", "net/netstat");
} }
int net_snmp_open(void) static int net_snmp_open(void)
{ {
return generic_proc_open("PROC_NET_SNMP", "net/snmp"); return generic_proc_open("PROC_NET_SNMP", "net/snmp");
} }
int net_snmp6_open(void) static int net_snmp6_open(void)
{ {
return generic_proc_open("PROC_NET_SNMP6", "net/snmp6"); return generic_proc_open("PROC_NET_SNMP6", "net/snmp6");
} }
...@@ -82,13 +82,13 @@ struct nstat_ent ...@@ -82,13 +82,13 @@ struct nstat_ent
struct nstat_ent *kern_db; struct nstat_ent *kern_db;
struct nstat_ent *hist_db; struct nstat_ent *hist_db;
char *useless_numbers[] = { static const char *useless_numbers[] = {
"IpForwarding", "IpDefaultTTL", "IpForwarding", "IpDefaultTTL",
"TcpRtoAlgorithm", "TcpRtoMin", "TcpRtoMax", "TcpRtoAlgorithm", "TcpRtoMin", "TcpRtoMax",
"TcpMaxConn", "TcpCurrEstab" "TcpMaxConn", "TcpCurrEstab"
}; };
int useless_number(char *id) static int useless_number(const char *id)
{ {
int i; int i;
for (i=0; i<sizeof(useless_numbers)/sizeof(*useless_numbers); i++) for (i=0; i<sizeof(useless_numbers)/sizeof(*useless_numbers); i++)
...@@ -97,7 +97,7 @@ int useless_number(char *id) ...@@ -97,7 +97,7 @@ int useless_number(char *id)
return 0; return 0;
} }
int match(char *id) static int match(const char *id)
{ {
int i; int i;
...@@ -111,7 +111,7 @@ int match(char *id) ...@@ -111,7 +111,7 @@ int match(char *id)
return 0; return 0;
} }
void load_good_table(FILE *fp) static void load_good_table(FILE *fp)
{ {
char buf[4096]; char buf[4096];
struct nstat_ent *db = NULL; struct nstat_ent *db = NULL;
...@@ -157,7 +157,7 @@ void load_good_table(FILE *fp) ...@@ -157,7 +157,7 @@ void load_good_table(FILE *fp)
} }
void load_ugly_table(FILE *fp) static void load_ugly_table(FILE *fp)
{ {
char buf[4096]; char buf[4096];
struct nstat_ent *db = NULL; struct nstat_ent *db = NULL;
...@@ -228,7 +228,7 @@ void load_ugly_table(FILE *fp) ...@@ -228,7 +228,7 @@ void load_ugly_table(FILE *fp)
} }
} }
void load_snmp(void) static void load_snmp(void)
{ {
FILE *fp = fdopen(net_snmp_open(), "r"); FILE *fp = fdopen(net_snmp_open(), "r");
if (fp) { if (fp) {
...@@ -237,7 +237,7 @@ void load_snmp(void) ...@@ -237,7 +237,7 @@ void load_snmp(void)
} }
} }
void load_snmp6(void) static void load_snmp6(void)
{ {
FILE *fp = fdopen(net_snmp6_open(), "r"); FILE *fp = fdopen(net_snmp6_open(), "r");
if (fp) { if (fp) {
...@@ -246,7 +246,7 @@ void load_snmp6(void) ...@@ -246,7 +246,7 @@ void load_snmp6(void)
} }
} }
void load_netstat(void) static void load_netstat(void)
{ {
FILE *fp = fdopen(net_netstat_open(), "r"); FILE *fp = fdopen(net_netstat_open(), "r");
if (fp) { if (fp) {
...@@ -255,7 +255,7 @@ void load_netstat(void) ...@@ -255,7 +255,7 @@ void load_netstat(void)
} }
} }
void dump_kern_db(FILE *fp, int to_hist) static void dump_kern_db(FILE *fp, int to_hist)
{ {
struct nstat_ent *n, *h; struct nstat_ent *n, *h;
h = hist_db; h = hist_db;
...@@ -280,7 +280,7 @@ void dump_kern_db(FILE *fp, int to_hist) ...@@ -280,7 +280,7 @@ void dump_kern_db(FILE *fp, int to_hist)
} }
} }
void dump_incr_db(FILE *fp) static void dump_incr_db(FILE *fp)
{ {
struct nstat_ent *n, *h; struct nstat_ent *n, *h;
h = hist_db; h = hist_db;
...@@ -311,11 +311,11 @@ void dump_incr_db(FILE *fp) ...@@ -311,11 +311,11 @@ void dump_incr_db(FILE *fp)
static int children; static int children;
void sigchild(int signo) static void sigchild(int signo)
{ {
} }
void update_db(int interval) static void update_db(int interval)
{ {
struct nstat_ent *n, *h; struct nstat_ent *n, *h;
...@@ -367,7 +367,7 @@ void update_db(int interval) ...@@ -367,7 +367,7 @@ void update_db(int interval)
#define T_DIFF(a,b) (((a).tv_sec-(b).tv_sec)*1000 + ((a).tv_usec-(b).tv_usec)/1000) #define T_DIFF(a,b) (((a).tv_sec-(b).tv_sec)*1000 + ((a).tv_usec-(b).tv_usec)/1000)
void server_loop(int fd) static void server_loop(int fd)
{ {
struct timeval snaptime = { 0 }; struct timeval snaptime = { 0 };
struct pollfd p; struct pollfd p;
...@@ -419,7 +419,7 @@ void server_loop(int fd) ...@@ -419,7 +419,7 @@ void server_loop(int fd)
} }
} }
int verify_forging(int fd) static int verify_forging(int fd)
{ {
struct ucred cred; struct ucred cred;
socklen_t olen = sizeof(cred); socklen_t olen = sizeof(cred);
......
...@@ -55,12 +55,12 @@ static int generic_proc_open(const char *env, const char *name) ...@@ -55,12 +55,12 @@ static int generic_proc_open(const char *env, const char *name)
return open(p, O_RDONLY); return open(p, O_RDONLY);
} }
int net_rtacct_open(void) static int net_rtacct_open(void)
{ {
return generic_proc_open("PROC_NET_RTACCT", "net/rt_acct"); return generic_proc_open("PROC_NET_RTACCT", "net/rt_acct");
} }
__u32 rmap[256/4]; static __u32 rmap[256/4];
struct rtacct_data struct rtacct_data
{ {
...@@ -71,12 +71,12 @@ struct rtacct_data ...@@ -71,12 +71,12 @@ struct rtacct_data
char signature[128]; char signature[128];
}; };
struct rtacct_data kern_db_static; static struct rtacct_data kern_db_static;
struct rtacct_data *kern_db = &kern_db_static; static struct rtacct_data *kern_db = &kern_db_static;
struct rtacct_data *hist_db; static struct rtacct_data *hist_db;
void nread(int fd, char *buf, int tot) static void nread(int fd, char *buf, int tot)
{ {
int count = 0; int count = 0;
...@@ -93,8 +93,7 @@ void nread(int fd, char *buf, int tot) ...@@ -93,8 +93,7 @@ void nread(int fd, char *buf, int tot)
} }
} }
static __u32 *read_kern_table(__u32 *tbl)
__u32 *read_kern_table(__u32 *tbl)
{ {
static __u32 *tbl_ptr; static __u32 *tbl_ptr;
int fd; int fd;
...@@ -130,7 +129,7 @@ __u32 *read_kern_table(__u32 *tbl) ...@@ -130,7 +129,7 @@ __u32 *read_kern_table(__u32 *tbl)
return tbl; return tbl;
} }
void format_rate(FILE *fp, double rate) static void format_rate(FILE *fp, double rate)
{ {
char temp[64]; char temp[64];
...@@ -144,7 +143,7 @@ void format_rate(FILE *fp, double rate) ...@@ -144,7 +143,7 @@ void format_rate(FILE *fp, double rate)
fprintf(fp, " %-10u", (unsigned)rate); fprintf(fp, " %-10u", (unsigned)rate);
} }
void format_count(FILE *fp, unsigned long long val) static void format_count(FILE *fp, unsigned long long val)
{ {
if (val > 1024*1024*1024) if (val > 1024*1024*1024)
fprintf(fp, " %10lluM", val/(1024*1024)); fprintf(fp, " %10lluM", val/(1024*1024));
...@@ -154,7 +153,7 @@ void format_count(FILE *fp, unsigned long long val) ...@@ -154,7 +153,7 @@ void format_count(FILE *fp, unsigned long long val)
fprintf(fp, " %10llu", val); fprintf(fp, " %10llu", val);
} }
void dump_abs_db(FILE *fp) static void dump_abs_db(FILE *fp)
{ {
int realm; int realm;
char b1[16]; char b1[16];
...@@ -216,7 +215,7 @@ void dump_abs_db(FILE *fp) ...@@ -216,7 +215,7 @@ void dump_abs_db(FILE *fp)
} }
void dump_incr_db(FILE *fp) static void dump_incr_db(FILE *fp)
{ {
int k, realm; int k, realm;
char b1[16]; char b1[16];
...@@ -293,13 +292,13 @@ void dump_incr_db(FILE *fp) ...@@ -293,13 +292,13 @@ void dump_incr_db(FILE *fp)
static int children; static int children;
void sigchild(int signo) static void sigchild(int signo)
{ {
} }
/* Server side only: read kernel data, update tables, calculate rates. */ /* Server side only: read kernel data, update tables, calculate rates. */
void update_db(int interval) static void update_db(int interval)
{ {
int i; int i;
__u32 *ival; __u32 *ival;
...@@ -331,7 +330,7 @@ void update_db(int interval) ...@@ -331,7 +330,7 @@ void update_db(int interval)
} }
} }
void send_db(int fd) static void send_db(int fd)
{ {
int tot = 0; int tot = 0;
...@@ -351,7 +350,7 @@ void send_db(int fd) ...@@ -351,7 +350,7 @@ void send_db(int fd)
#define T_DIFF(a,b) (((a).tv_sec-(b).tv_sec)*1000 + ((a).tv_usec-(b).tv_usec)/1000) #define T_DIFF(a,b) (((a).tv_sec-(b).tv_sec)*1000 + ((a).tv_usec-(b).tv_usec)/1000)
void pad_kern_table(struct rtacct_data *dat, __u32 *ival) static void pad_kern_table(struct rtacct_data *dat, __u32 *ival)
{ {
int i; int i;
memset(dat->rate, 0, sizeof(dat->rate)); memset(dat->rate, 0, sizeof(dat->rate));
...@@ -361,7 +360,7 @@ void pad_kern_table(struct rtacct_data *dat, __u32 *ival) ...@@ -361,7 +360,7 @@ void pad_kern_table(struct rtacct_data *dat, __u32 *ival)
dat->val[i] = ival[i]; dat->val[i] = ival[i];
} }
void server_loop(int fd) static void server_loop(int fd)
{ {
struct timeval snaptime = { 0 }; struct timeval snaptime = { 0 };
struct pollfd p; struct pollfd p;
...@@ -410,7 +409,7 @@ void server_loop(int fd) ...@@ -410,7 +409,7 @@ void server_loop(int fd)
} }
} }
int verify_forging(int fd) static int verify_forging(int fd)
{ {
struct ucred cred; struct ucred cred;
socklen_t olen = sizeof(cred); socklen_t olen = sizeof(cred);
......
...@@ -309,7 +309,7 @@ static void user_ent_hash_build(void) ...@@ -309,7 +309,7 @@ static void user_ent_hash_build(void)
closedir(dir); closedir(dir);
} }
int find_users(unsigned ino, char *buf, int buflen) static int find_users(unsigned ino, char *buf, int buflen)
{ {
struct user_ent *p; struct user_ent *p;
int cnt = 0; int cnt = 0;
...@@ -365,7 +365,7 @@ static const char *slabstat_ids[] = ...@@ -365,7 +365,7 @@ static const char *slabstat_ids[] =
"skbuff_head_cache", "skbuff_head_cache",
}; };
int get_slabstat(struct slabstat *s) static int get_slabstat(struct slabstat *s)
{ {
char buf[256]; char buf[256];
FILE *fp; FILE *fp;
...@@ -455,7 +455,7 @@ static const char *tmr_name[] = { ...@@ -455,7 +455,7 @@ static const char *tmr_name[] = {
"unknown" "unknown"
}; };
const char *print_ms_timer(int timeout) static const char *print_ms_timer(int timeout)
{ {
static char buf[64]; static char buf[64];
int secs, msecs, minutes; int secs, msecs, minutes;
...@@ -482,7 +482,7 @@ const char *print_ms_timer(int timeout) ...@@ -482,7 +482,7 @@ const char *print_ms_timer(int timeout)
return buf; return buf;
} }
const char *print_hz_timer(int timeout) static const char *print_hz_timer(int timeout)
{ {
int hz = get_user_hz(); int hz = get_user_hz();
return print_ms_timer(((timeout*1000) + hz-1)/hz); return print_ms_timer(((timeout*1000) + hz-1)/hz);
...@@ -498,7 +498,7 @@ struct scache ...@@ -498,7 +498,7 @@ struct scache
struct scache *rlist; struct scache *rlist;
void init_service_resolver(void) static void init_service_resolver(void)
{ {
char buf[128]; char buf[128];
FILE *fp = popen("/usr/sbin/rpcinfo -p 2>/dev/null", "r"); FILE *fp = popen("/usr/sbin/rpcinfo -p 2>/dev/null", "r");
...@@ -555,7 +555,7 @@ static int is_ephemeral(int port) ...@@ -555,7 +555,7 @@ static int is_ephemeral(int port)
} }
const char *__resolve_service(int port) static const char *__resolve_service(int port)
{ {
struct scache *c; struct scache *c;
...@@ -580,7 +580,7 @@ const char *__resolve_service(int port) ...@@ -580,7 +580,7 @@ const char *__resolve_service(int port)
} }
const char *resolve_service(int port) static const char *resolve_service(int port)
{ {
static char buf[128]; static char buf[128];
static struct scache cache[256]; static struct scache cache[256];
...@@ -634,7 +634,7 @@ const char *resolve_service(int port) ...@@ -634,7 +634,7 @@ const char *resolve_service(int port)
return buf; return buf;
} }
void formatted_print(const inet_prefix *a, int port) static void formatted_print(const inet_prefix *a, int port)
{ {
char buf[1024]; char buf[1024];
const char *ap = buf; const char *ap = buf;
...@@ -667,7 +667,8 @@ struct aafilter ...@@ -667,7 +667,8 @@ struct aafilter
struct aafilter *next; struct aafilter *next;
}; };
int inet2_addr_match(const inet_prefix *a, const inet_prefix *p, int plen) static int inet2_addr_match(const inet_prefix *a, const inet_prefix *p,
int plen)
{ {
if (!inet_addr_match(a, p, plen)) if (!inet_addr_match(a, p, plen))
return 0; return 0;
...@@ -686,7 +687,7 @@ int inet2_addr_match(const inet_prefix *a, const inet_prefix *p, int plen) ...@@ -686,7 +687,7 @@ int inet2_addr_match(const inet_prefix *a, const inet_prefix *p, int plen)
return 1; return 1;
} }
int unix_match(const inet_prefix *a, const inet_prefix *p) static int unix_match(const inet_prefix *a, const inet_prefix *p)
{ {
char *addr, *pattern; char *addr, *pattern;
memcpy(&addr, a->data, sizeof(addr)); memcpy(&addr, a->data, sizeof(addr));
...@@ -698,7 +699,7 @@ int unix_match(const inet_prefix *a, const inet_prefix *p) ...@@ -698,7 +699,7 @@ int unix_match(const inet_prefix *a, const inet_prefix *p)
return !fnmatch(pattern, addr, 0); return !fnmatch(pattern, addr, 0);
} }
int run_ssfilter(struct ssfilter *f, struct tcpstat *s) static int run_ssfilter(struct ssfilter *f, struct tcpstat *s)
{ {
switch (f->type) { switch (f->type) {
case SSF_S_AUTO: case SSF_S_AUTO:
...@@ -1882,7 +1883,7 @@ outerr: ...@@ -1882,7 +1883,7 @@ outerr:
} }
int dgram_show_line(char *line, const struct filter *f, int family) static int dgram_show_line(char *line, const struct filter *f, int family)
{ {
struct tcpstat s; struct tcpstat s;
char *loc, *rem, *data; char *loc, *rem, *data;
...@@ -1974,7 +1975,7 @@ int dgram_show_line(char *line, const struct filter *f, int family) ...@@ -1974,7 +1975,7 @@ int dgram_show_line(char *line, const struct filter *f, int family)
} }
int udp_show(struct filter *f) static int udp_show(struct filter *f)
{ {
FILE *fp = NULL; FILE *fp = NULL;
...@@ -2010,7 +2011,7 @@ outerr: ...@@ -2010,7 +2011,7 @@ outerr:
} while (0); } while (0);
} }
int raw_show(struct filter *f) static int raw_show(struct filter *f)
{ {
FILE *fp = NULL; FILE *fp = NULL;
...@@ -2063,7 +2064,7 @@ int unix_state_map[] = { SS_CLOSE, SS_SYN_SENT, ...@@ -2063,7 +2064,7 @@ int unix_state_map[] = { SS_CLOSE, SS_SYN_SENT,
#define MAX_UNIX_REMEMBER (1024*1024/sizeof(struct unixstat)) #define MAX_UNIX_REMEMBER (1024*1024/sizeof(struct unixstat))
void unix_list_free(struct unixstat *list) static void unix_list_free(struct unixstat *list)
{ {
while (list) { while (list) {
struct unixstat *s = list; struct unixstat *s = list;
...@@ -2074,7 +2075,7 @@ void unix_list_free(struct unixstat *list) ...@@ -2074,7 +2075,7 @@ void unix_list_free(struct unixstat *list)
} }
} }
void unix_list_print(struct unixstat *list, struct filter *f) static void unix_list_print(struct unixstat *list, struct filter *f)
{ {
struct unixstat *s; struct unixstat *s;
char *peer; char *peer;
...@@ -2283,7 +2284,7 @@ close_it: ...@@ -2283,7 +2284,7 @@ close_it:
return 0; return 0;
} }
int unix_show(struct filter *f) static int unix_show(struct filter *f)
{ {
FILE *fp; FILE *fp;
char buf[256]; char buf[256];
...@@ -2368,7 +2369,7 @@ int unix_show(struct filter *f) ...@@ -2368,7 +2369,7 @@ int unix_show(struct filter *f)
} }
int packet_show(struct filter *f) static int packet_show(struct filter *f)
{ {
FILE *fp; FILE *fp;
char buf[256]; char buf[256];
...@@ -2445,7 +2446,7 @@ int packet_show(struct filter *f) ...@@ -2445,7 +2446,7 @@ int packet_show(struct filter *f)
return 0; return 0;
} }
int netlink_show(struct filter *f) static int netlink_show(struct filter *f)
{ {
FILE *fp; FILE *fp;
char buf[256]; char buf[256];
...@@ -2534,7 +2535,7 @@ struct snmpstat ...@@ -2534,7 +2535,7 @@ struct snmpstat
int tcp_estab; int tcp_estab;
}; };
int get_snmp_int(char *proto, char *key, int *result) static int get_snmp_int(char *proto, char *key, int *result)
{ {
char buf[1024]; char buf[1024];
FILE *fp; FILE *fp;
...@@ -2629,7 +2630,7 @@ static void get_sockstat_line(char *line, struct sockstat *s) ...@@ -2629,7 +2630,7 @@ static void get_sockstat_line(char *line, struct sockstat *s)
&s->tcp_orphans, &s->tcp_tws, &s->tcp_total, &s->tcp_mem); &s->tcp_orphans, &s->tcp_tws, &s->tcp_total, &s->tcp_mem);
} }
int get_sockstat(struct sockstat *s) static int get_sockstat(struct sockstat *s)
{ {
char buf[256]; char buf[256];
FILE *fp; FILE *fp;
...@@ -2651,7 +2652,7 @@ int get_sockstat(struct sockstat *s) ...@@ -2651,7 +2652,7 @@ int get_sockstat(struct sockstat *s)
return 0; return 0;
} }
int print_summary(void) static int print_summary(void)
{ {
struct sockstat s; struct sockstat s;
struct snmpstat sn; struct snmpstat sn;
...@@ -2743,7 +2744,7 @@ static void usage(void) ...@@ -2743,7 +2744,7 @@ static void usage(void)
} }
int scan_state(const char *state) static int scan_state(const char *state)
{ {
int i; int i;
if (strcasecmp(state, "close") == 0 || if (strcasecmp(state, "close") == 0 ||
......
...@@ -37,7 +37,7 @@ static void explain(void) ...@@ -37,7 +37,7 @@ static void explain(void)
fprintf(stderr, "\nNOTE: CLASSID is parsed as hexadecimal input.\n"); fprintf(stderr, "\nNOTE: CLASSID is parsed as hexadecimal input.\n");
} }
int get_addr_and_pi(int *argc_p, char ***argv_p, inet_prefix * addr, static int get_addr_and_pi(int *argc_p, char ***argv_p, inet_prefix * addr,
struct tc_rsvp_pinfo *pinfo, int dir, int family) struct tc_rsvp_pinfo *pinfo, int dir, int family)
{ {
int argc = *argc_p; int argc = *argc_p;
......
...@@ -45,7 +45,7 @@ static void explain(void) ...@@ -45,7 +45,7 @@ static void explain(void)
fprintf(stderr, "\nNOTE: CLASSID is parsed at hexadecimal input.\n"); fprintf(stderr, "\nNOTE: CLASSID is parsed at hexadecimal input.\n");
} }
int get_u32_handle(__u32 *handle, const char *str) static int get_u32_handle(__u32 *handle, const char *str)
{ {
__u32 htid=0, hash=0, nodeid=0; __u32 htid=0, hash=0, nodeid=0;
char *tmp = strchr(str, ':'); char *tmp = strchr(str, ':');
...@@ -80,7 +80,7 @@ int get_u32_handle(__u32 *handle, const char *str) ...@@ -80,7 +80,7 @@ int get_u32_handle(__u32 *handle, const char *str)
return 0; return 0;
} }
char * sprint_u32_handle(__u32 handle, char *buf) static char * sprint_u32_handle(__u32 handle, char *buf)
{ {
int bsize = SPRINT_BSIZE-1; int bsize = SPRINT_BSIZE-1;
__u32 htid = TC_U32_HTID(handle); __u32 htid = TC_U32_HTID(handle);
...@@ -194,7 +194,7 @@ static int pack_key8(struct tc_u32_sel *sel, __u32 key, __u32 mask, int off, int ...@@ -194,7 +194,7 @@ static int pack_key8(struct tc_u32_sel *sel, __u32 key, __u32 mask, int off, int
} }
int parse_at(int *argc_p, char ***argv_p, int *off, int *offmask) static int parse_at(int *argc_p, char ***argv_p, int *off, int *offmask)
{ {
int argc = *argc_p; int argc = *argc_p;
char **argv = *argv_p; char **argv = *argv_p;
......
...@@ -35,7 +35,7 @@ int gact_ld = 0 ; //fuckin backward compatibility ...@@ -35,7 +35,7 @@ int gact_ld = 0 ; //fuckin backward compatibility
int batch_c = 0; int batch_c = 0;
int tab_flush = 0; int tab_flush = 0;
void act_usage(void) static void act_usage(void)
{ {
/*XXX: In the near future add a action->print_help to improve /*XXX: In the near future add a action->print_help to improve
* usability * usability
...@@ -83,7 +83,7 @@ static int parse_noaopt(struct action_util *au, int *argc_p, char ***argv_p, int ...@@ -83,7 +83,7 @@ static int parse_noaopt(struct action_util *au, int *argc_p, char ***argv_p, int
return -1; return -1;
} }
struct action_util *get_action_kind(char *str) static struct action_util *get_action_kind(char *str)
{ {
static void *aBODY; static void *aBODY;
void *dlh; void *dlh;
...@@ -138,7 +138,7 @@ noexist: ...@@ -138,7 +138,7 @@ noexist:
return a; return a;
} }
int static int
new_cmd(char **argv) new_cmd(char **argv)
{ {
if ((matches(*argv, "change") == 0) || if ((matches(*argv, "change") == 0) ||
...@@ -241,7 +241,7 @@ bad_val: ...@@ -241,7 +241,7 @@ bad_val:
return -1; return -1;
} }
int static int
tc_print_one_action(FILE * f, struct rtattr *arg) tc_print_one_action(FILE * f, struct rtattr *arg)
{ {
...@@ -355,7 +355,7 @@ int print_action(const struct sockaddr_nl *who, ...@@ -355,7 +355,7 @@ int print_action(const struct sockaddr_nl *who,
return 0; return 0;
} }
int tc_action_gd(int cmd, unsigned flags, int *argc_p, char ***argv_p) static int tc_action_gd(int cmd, unsigned flags, int *argc_p, char ***argv_p)
{ {
char k[16]; char k[16];
struct action_util *a = NULL; struct action_util *a = NULL;
...@@ -467,7 +467,7 @@ bad_val: ...@@ -467,7 +467,7 @@ bad_val:
return ret; return ret;
} }
int tc_action_modify(int cmd, unsigned flags, int *argc_p, char ***argv_p) static int tc_action_modify(int cmd, unsigned flags, int *argc_p, char ***argv_p)
{ {
int argc = *argc_p; int argc = *argc_p;
char **argv = *argv_p; char **argv = *argv_p;
...@@ -507,7 +507,7 @@ int tc_action_modify(int cmd, unsigned flags, int *argc_p, char ***argv_p) ...@@ -507,7 +507,7 @@ int tc_action_modify(int cmd, unsigned flags, int *argc_p, char ***argv_p)
return ret; return ret;
} }
int tc_act_list_or_flush(int argc, char **argv, int event) static int tc_act_list_or_flush(int argc, char **argv, int event)
{ {
int ret = 0, prio = 0, msg_size = 0; int ret = 0, prio = 0, msg_size = 0;
char k[16]; char k[16];
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "utils.h" #include "utils.h"
#include "tc_util.h" #include "tc_util.h"
#include "tc_common.h"
static void est_help(void); static void est_help(void);
...@@ -31,7 +32,6 @@ static void est_help(void) ...@@ -31,7 +32,6 @@ static void est_help(void)
fprintf(stderr, " INTERVAL is interval between measurements\n"); fprintf(stderr, " INTERVAL is interval between measurements\n");
fprintf(stderr, " TIME-CONST is averaging time constant\n"); fprintf(stderr, " TIME-CONST is averaging time constant\n");
fprintf(stderr, "Example: ... est 1sec 8sec\n"); fprintf(stderr, "Example: ... est 1sec 8sec\n");
return;
} }
int parse_estimator(int *p_argc, char ***p_argv, struct tc_estimator *est) int parse_estimator(int *p_argc, char ***p_argv, struct tc_estimator *est)
......
...@@ -68,7 +68,7 @@ usage(void) ...@@ -68,7 +68,7 @@ usage(void)
exit(-1); exit(-1);
} }
int static int
get_act(char ***argv_p) get_act(char ***argv_p)
{ {
char **argv = *argv_p; char **argv = *argv_p;
...@@ -89,8 +89,9 @@ get_act(char ***argv_p) ...@@ -89,8 +89,9 @@ get_act(char ***argv_p)
} }
} }
int static int
parse_gact(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n) parse_gact(struct action_util *a, int *argc_p, char ***argv_p,
int tca_id, struct nlmsghdr *n)
{ {
int argc = *argc_p; int argc = *argc_p;
char **argv = *argv_p; char **argv = *argv_p;
...@@ -202,7 +203,7 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struc ...@@ -202,7 +203,7 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struc
return 0; return 0;
} }
int static int
print_gact(struct action_util *au,FILE * f, struct rtattr *arg) print_gact(struct action_util *au,FILE * f, struct rtattr *arg)
{ {
SPRINT_BUF(b1); SPRINT_BUF(b1);
......
...@@ -45,7 +45,7 @@ usage(void) ...@@ -45,7 +45,7 @@ usage(void)
exit(-1); exit(-1);
} }
char *mirred_n2a(int action) static const char *mirred_n2a(int action)
{ {
switch (action) { switch (action) {
case TCA_EGRESS_REDIR: case TCA_EGRESS_REDIR:
...@@ -61,8 +61,9 @@ char *mirred_n2a(int action) ...@@ -61,8 +61,9 @@ char *mirred_n2a(int action)
} }
} }
int static int
parse_egress(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n) parse_egress(struct action_util *a, int *argc_p, char ***argv_p,
int tca_id, struct nlmsghdr *n)
{ {
int argc = *argc_p; int argc = *argc_p;
...@@ -205,8 +206,9 @@ parse_egress(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, str ...@@ -205,8 +206,9 @@ parse_egress(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, str
} }
int static int
parse_mirred(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n) parse_mirred(struct action_util *a, int *argc_p, char ***argv_p,
int tca_id, struct nlmsghdr *n)
{ {
int argc = *argc_p; int argc = *argc_p;
...@@ -245,7 +247,7 @@ parse_mirred(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, str ...@@ -245,7 +247,7 @@ parse_mirred(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, str
} }
int static int
print_mirred(struct action_util *au,FILE * f, struct rtattr *arg) print_mirred(struct action_util *au,FILE * f, struct rtattr *arg)
{ {
struct tc_mirred *p; struct tc_mirred *p;
......
...@@ -73,8 +73,7 @@ pedit_parse_nopopt (int *argc_p, char ***argv_p,struct tc_pedit_sel *sel,struct ...@@ -73,8 +73,7 @@ pedit_parse_nopopt (int *argc_p, char ***argv_p,struct tc_pedit_sel *sel,struct
} }
struct m_pedit_util static struct m_pedit_util *get_pedit_kind(const char *str)
*get_pedit_kind(char *str)
{ {
static void *pBODY; static void *pBODY;
void *dlh; void *dlh;
...@@ -411,7 +410,7 @@ done: ...@@ -411,7 +410,7 @@ done:
return res; return res;
} }
int static int
parse_munge(int *argc_p, char ***argv_p,struct tc_pedit_sel *sel) parse_munge(int *argc_p, char ***argv_p,struct tc_pedit_sel *sel)
{ {
struct tc_pedit_key tkey; struct tc_pedit_key tkey;
......
...@@ -50,7 +50,7 @@ static void explain1(char *arg) ...@@ -50,7 +50,7 @@ static void explain1(char *arg)
fprintf(stderr, "Illegal \"%s\"\n", arg); fprintf(stderr, "Illegal \"%s\"\n", arg);
} }
char *police_action_n2a(int action, char *buf, int len) static const char *police_action_n2a(int action, char *buf, int len)
{ {
switch (action) { switch (action) {
case -1: case -1:
...@@ -72,7 +72,7 @@ char *police_action_n2a(int action, char *buf, int len) ...@@ -72,7 +72,7 @@ char *police_action_n2a(int action, char *buf, int len)
} }
} }
int police_action_a2n(char *arg, int *result) static int police_action_a2n(const char *arg, int *result)
{ {
int res; int res;
...@@ -100,7 +100,7 @@ int police_action_a2n(char *arg, int *result) ...@@ -100,7 +100,7 @@ int police_action_a2n(char *arg, int *result)
} }
int get_police_result(int *action, int *result, char *arg) static int get_police_result(int *action, int *result, char *arg)
{ {
char *p = strchr(arg, '/'); char *p = strchr(arg, '/');
......
...@@ -76,7 +76,7 @@ static struct xtables_globals tcipt_globals = { ...@@ -76,7 +76,7 @@ static struct xtables_globals tcipt_globals = {
/* /*
* we may need to check for version mismatch * we may need to check for version mismatch
*/ */
int static int
build_st(struct xtables_target *target, struct xt_entry_target *t) build_st(struct xtables_target *target, struct xt_entry_target *t)
{ {
...@@ -98,7 +98,7 @@ build_st(struct xtables_target *target, struct xt_entry_target *t) ...@@ -98,7 +98,7 @@ build_st(struct xtables_target *target, struct xt_entry_target *t)
} }
inline void set_lib_dir(void) static void set_lib_dir(void)
{ {
lib_dir = getenv("XTABLES_LIBDIR"); lib_dir = getenv("XTABLES_LIBDIR");
......
...@@ -104,7 +104,7 @@ static int mqprio_parse_opt(struct qdisc_util *qu, int argc, ...@@ -104,7 +104,7 @@ static int mqprio_parse_opt(struct qdisc_util *qu, int argc,
return 0; return 0;
} }
int mqprio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) static int mqprio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
{ {
int i; int i;
struct tc_mqprio_qopt *qopt; struct tc_mqprio_qopt *qopt;
......
...@@ -61,7 +61,7 @@ static int multiq_parse_opt(struct qdisc_util *qu, int argc, char **argv, ...@@ -61,7 +61,7 @@ static int multiq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
return 0; return 0;
} }
int multiq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) static int multiq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
{ {
struct tc_multiq_qopt *qopt; struct tc_multiq_qopt *qopt;
......
...@@ -87,12 +87,12 @@ static int get_percent(__u32 *percent, const char *str) ...@@ -87,12 +87,12 @@ static int get_percent(__u32 *percent, const char *str)
return 0; return 0;
} }
void print_percent(char *buf, int len, __u32 per) static void print_percent(char *buf, int len, __u32 per)
{ {
snprintf(buf, len, "%g%%", 100. * (double) per / max_percent_value); snprintf(buf, len, "%g%%", 100. * (double) per / max_percent_value);
} }
char * sprint_percent(__u32 per, char *buf) static char * sprint_percent(__u32 per, char *buf)
{ {
print_percent(buf, SPRINT_BSIZE-1, per); print_percent(buf, SPRINT_BSIZE-1, per);
return buf; return buf;
......
...@@ -88,7 +88,7 @@ static int rr_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlm ...@@ -88,7 +88,7 @@ static int rr_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlm
return 0; return 0;
} }
int rr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) static int rr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
{ {
int i; int i;
struct tc_prio_qopt *qopt; struct tc_prio_qopt *qopt;
......
...@@ -40,7 +40,7 @@ static void usage(void) ...@@ -40,7 +40,7 @@ static void usage(void)
return; return;
} }
int tc_class_modify(int cmd, unsigned flags, int argc, char **argv) static int tc_class_modify(int cmd, unsigned flags, int argc, char **argv)
{ {
struct { struct {
struct nlmsghdr n; struct nlmsghdr n;
...@@ -232,7 +232,7 @@ int print_class(const struct sockaddr_nl *who, ...@@ -232,7 +232,7 @@ int print_class(const struct sockaddr_nl *who,
} }
int tc_class_list(int argc, char **argv) static int tc_class_list(int argc, char **argv)
{ {
struct tcmsg t; struct tcmsg t;
char d[16]; char d[16];
......
...@@ -76,7 +76,7 @@ unsigned tc_calc_xmitsize(unsigned rate, unsigned ticks) ...@@ -76,7 +76,7 @@ unsigned tc_calc_xmitsize(unsigned rate, unsigned ticks)
* (as the table will always be aligned for 48 bytes). * (as the table will always be aligned for 48 bytes).
* --Hawk, d.7/11-2004. <hawk@diku.dk> * --Hawk, d.7/11-2004. <hawk@diku.dk>
*/ */
unsigned tc_align_to_atm(unsigned size) static unsigned tc_align_to_atm(unsigned size)
{ {
int linksize, cells; int linksize, cells;
cells = size / ATM_CELL_PAYLOAD; cells = size / ATM_CELL_PAYLOAD;
...@@ -87,7 +87,7 @@ unsigned tc_align_to_atm(unsigned size) ...@@ -87,7 +87,7 @@ unsigned tc_align_to_atm(unsigned size)
return linksize; return linksize;
} }
unsigned tc_adjust_size(unsigned sz, unsigned mpu, enum link_layer linklayer) static unsigned tc_adjust_size(unsigned sz, unsigned mpu, enum link_layer linklayer)
{ {
if (sz < mpu) if (sz < mpu)
sz = mpu; sz = mpu;
...@@ -181,7 +181,7 @@ again: ...@@ -181,7 +181,7 @@ again:
return 0; return 0;
} }
int tc_core_init() int tc_core_init(void)
{ {
FILE *fp; FILE *fp;
__u32 clock_res; __u32 clock_res;
......
...@@ -45,7 +45,7 @@ static void usage(void) ...@@ -45,7 +45,7 @@ static void usage(void)
} }
int tc_filter_modify(int cmd, unsigned flags, int argc, char **argv) static int tc_filter_modify(int cmd, unsigned flags, int argc, char **argv)
{ {
struct { struct {
struct nlmsghdr n; struct nlmsghdr n;
...@@ -260,7 +260,7 @@ int print_filter(const struct sockaddr_nl *who, ...@@ -260,7 +260,7 @@ int print_filter(const struct sockaddr_nl *who,
} }
int tc_filter_list(int argc, char **argv) static int tc_filter_list(int argc, char **argv)
{ {
struct tcmsg t; struct tcmsg t;
char d[16]; char d[16];
......
...@@ -35,7 +35,8 @@ static void usage(void) ...@@ -35,7 +35,8 @@ static void usage(void)
} }
int accept_tcmsg(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) static int accept_tcmsg(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg)
{ {
FILE *fp = (FILE*)arg; FILE *fp = (FILE*)arg;
......
...@@ -44,7 +44,7 @@ static int usage(void) ...@@ -44,7 +44,7 @@ static int usage(void)
return -1; return -1;
} }
int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv) static int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv)
{ {
struct qdisc_util *q = NULL; struct qdisc_util *q = NULL;
struct tc_estimator est; struct tc_estimator est;
...@@ -277,7 +277,7 @@ int print_qdisc(const struct sockaddr_nl *who, ...@@ -277,7 +277,7 @@ int print_qdisc(const struct sockaddr_nl *who,
} }
int tc_qdisc_list(int argc, char **argv) static int tc_qdisc_list(int argc, char **argv)
{ {
struct tcmsg t; struct tcmsg t;
char d[16]; char d[16];
......
...@@ -167,35 +167,6 @@ int get_rate(unsigned *rate, const char *str) ...@@ -167,35 +167,6 @@ int get_rate(unsigned *rate, const char *str)
return -1; return -1;
} }
int get_rate_and_cell(unsigned *rate, int *cell_log, char *str)
{
char * slash = strchr(str, '/');
if (slash)
*slash = 0;
if (get_rate(rate, str))
return -1;
if (slash) {
int cell;
int i;
if (get_integer(&cell, slash+1, 0))
return -1;
*slash = '/';
for (i=0; i<32; i++) {
if ((1<<i) == cell) {
*cell_log = i;
return 0;
}
}
return -1;
}
return 0;
}
void print_rate(char *buf, int len, __u32 rate) void print_rate(char *buf, int len, __u32 rate)
{ {
double tmp = (double)rate*8; double tmp = (double)rate*8;
......
...@@ -97,5 +97,6 @@ extern int tc_print_action(FILE *f, const struct rtattr *tb); ...@@ -97,5 +97,6 @@ extern int tc_print_action(FILE *f, const struct rtattr *tb);
extern int tc_print_ipt(FILE *f, const struct rtattr *tb); extern int tc_print_ipt(FILE *f, const struct rtattr *tb);
extern int parse_action(int *, char ***, int, struct nlmsghdr *); extern int parse_action(int *, char ***, int, struct nlmsghdr *);
extern void print_tm(FILE *f, const struct tcf_t *tm); extern void print_tm(FILE *f, const struct tcf_t *tm);
extern int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt);
#endif #endif
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