From: Vincent Bernat Date: Fri, 26 Dec 2008 11:12:04 +0000 (+0100) Subject: Use static for all not to be exported symbols X-Git-Tag: 0.3.1~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8888d1917256e3e223916fb4c7e17596a37eb179;p=thirdparty%2Flldpd.git Use static for all not to be exported symbols --- diff --git a/src/agent.c b/src/agent.c index 8aa703f6..eba7edd1 100644 --- a/src/agent.c +++ b/src/agent.c @@ -31,7 +31,7 @@ extern struct timeval starttime; /* Global variable because no way to pass it as argument. Should not be used * elsewhere. */ -struct lldpd *scfg; +static struct lldpd *scfg; static inline uint8_t swap_bits(uint8_t n) @@ -43,7 +43,7 @@ swap_bits(uint8_t n) return n; }; -struct lldpd_hardware* +static struct lldpd_hardware* header_portindexed_table(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method) { @@ -85,7 +85,7 @@ header_portindexed_table(struct variable *vp, oid *name, size_t *length, #define TPR_VARIANT_IP 1 #define TPR_VARIANT_MED_POLICY 2 #define TPR_VARIANT_MED_LOCATION 3 -struct lldpd_hardware* +static struct lldpd_hardware* header_tprindexed_table(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method, int variant) { @@ -179,7 +179,7 @@ header_tprindexed_table(struct variable *vp, oid *name, size_t *length, } #ifdef ENABLE_DOT1 -struct lldpd_vlan* +static struct lldpd_vlan* header_pvindexed_table(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method) { @@ -231,7 +231,7 @@ header_pvindexed_table(struct variable *vp, oid *name, size_t *length, return pvlan; } -struct lldpd_vlan* +static struct lldpd_vlan* header_tprvindexed_table(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method) { diff --git a/src/agent_priv.c b/src/agent_priv.c index caf7cea6..d6ef1d8c 100644 --- a/src/agent_priv.c +++ b/src/agent_priv.c @@ -31,7 +31,7 @@ #include #include -oid netsnmp_UnixDomain[] = { TRANSPORT_DOMAIN_LOCAL }; +static oid netsnmp_unix[] = { TRANSPORT_DOMAIN_LOCAL }; static netsnmp_tdomain unixDomain; static char * @@ -112,7 +112,7 @@ agent_priv_unix_accept(netsnmp_transport *t) return -1; } -netsnmp_transport * +static netsnmp_transport * agent_priv_unix_transport(const char *string, int len, int local) { struct sockaddr_un addr; @@ -139,9 +139,9 @@ agent_priv_unix_transport(const char *string, int len, int local) memset(t, 0, sizeof(netsnmp_transport)); - t->domain = netsnmp_UnixDomain; + t->domain = netsnmp_unix; t->domain_length = - sizeof(netsnmp_UnixDomain) / sizeof(netsnmp_UnixDomain[0]); + sizeof(netsnmp_unix) / sizeof(netsnmp_unix[0]); if ((t->sock = priv_snmp_socket(&addr)) < 0) { netsnmp_transport_free(t); @@ -187,7 +187,7 @@ agent_priv_unix_create_tstring(const char *string, int local, char *default_targ return agent_priv_unix_transport(string, strlen(string), local); } -netsnmp_transport * +static netsnmp_transport * agent_priv_unix_create_ostring(const u_char * o, size_t o_len, int local) { return agent_priv_unix_transport((char *)o, o_len, local); @@ -196,8 +196,8 @@ agent_priv_unix_create_ostring(const u_char * o, size_t o_len, int local) void agent_priv_register_domain() { - unixDomain.name = netsnmp_UnixDomain; - unixDomain.name_length = sizeof(netsnmp_UnixDomain) / sizeof(oid); + unixDomain.name = netsnmp_unix; + unixDomain.name_length = sizeof(netsnmp_unix) / sizeof(oid); unixDomain.prefix = (const char**)calloc(2, sizeof(char *)); unixDomain.prefix[0] = "unix"; #if !HAVE_NETSNMP_TDOMAIN_F_CREATE_FROM_TSTRING_NEW diff --git a/src/cdp.c b/src/cdp.c index c16193ef..e9761516 100644 --- a/src/cdp.c +++ b/src/cdp.c @@ -22,7 +22,7 @@ #include #include -int +static int cdp_send(struct lldpd *global, struct lldpd_chassis *chassis, struct lldpd_hardware *hardware, int version) { @@ -467,7 +467,7 @@ fdp_send(struct lldpd *global, struct lldpd_chassis *chassis, return cdp_send(global, chassis, hardware, 0); } -int +static int cdp_guess(char *frame, int len, int version) { const u_int8_t mcastaddr[] = CDP_MULTICAST_ADDR; diff --git a/src/client.c b/src/client.c index 30ebc36f..8d1d6d39 100644 --- a/src/client.c +++ b/src/client.c @@ -16,7 +16,7 @@ #include "lldpd.h" -struct client_handle client_handles[] = { +static struct client_handle client_handles[] = { { HMSG_NONE, client_handle_none }, { HMSG_GET_INTERFACES, client_handle_get_interfaces }, { HMSG_GET_CHASSIS, client_handle_port_related }, diff --git a/src/ctl.c b/src/ctl.c index 950b1c46..f2b582fc 100644 --- a/src/ctl.c +++ b/src/ctl.c @@ -175,7 +175,7 @@ struct formatdef { /* void** is a pointer to a pointer to the end of struct hmsg*. It should be * updated. void* is a pointer to the entity to pack */ -int +static int ctl_alloc_pointer(struct gc_l *pointers, void *pointer) { struct gc *gpointer; @@ -191,7 +191,7 @@ ctl_alloc_pointer(struct gc_l *pointers, void *pointer) return 0; } -void +static void ctl_free_pointers(struct gc_l *pointers, int listonly) { struct gc *pointer, *pointer_next; @@ -206,7 +206,7 @@ ctl_free_pointers(struct gc_l *pointers, int listonly) } } -int +static int pack_copy(struct hmsg *h, void **p, void *s, const struct formatdef *ct) { @@ -220,7 +220,7 @@ pack_copy(struct hmsg *h, void **p, void *s, return ct->size; } -int +static int unpack_copy(struct hmsg *h, void **p, void *s, const struct formatdef *ct, struct gc_l *pointers) { @@ -229,7 +229,7 @@ unpack_copy(struct hmsg *h, void **p, void *s, return ct->size; } -int +static int pack_string(struct hmsg *h, void **p, void *s, const struct formatdef *ct) { @@ -255,7 +255,7 @@ pack_string(struct hmsg *h, void **p, void *s, return ss; } -int +static int unpack_string(struct hmsg *h, void **p, void *s, const struct formatdef *ct, struct gc_l *pointers) { @@ -280,7 +280,7 @@ unpack_string(struct hmsg *h, void **p, void *s, return sizeof(char*); } -int +static int pack_chars(struct hmsg *h, void **p, void *s, const struct formatdef *ct) { @@ -303,7 +303,7 @@ pack_chars(struct hmsg *h, void **p, void *s, return sizeof(int) + string_len; } -int +static int unpack_chars(struct hmsg *h, void **p, void *s, const struct formatdef *ct, struct gc_l *pointers) { @@ -330,7 +330,7 @@ unpack_chars(struct hmsg *h, void **p, void *s, return sizeof(char*); } -int +static int pack_zero(struct hmsg *h, void **p, void *s, const struct formatdef *ct) { @@ -374,7 +374,7 @@ struct fakelist_m { }; TAILQ_HEAD(fakelist_l, fakelist_m); -int ctl_msg_get_alignment(char *format) +static int ctl_msg_get_alignment(char *format) { char *f; int maxalign = 0, align; @@ -414,7 +414,7 @@ struct stack_align { int align; }; -int +static int ctl_msg_packunpack_structure(char *format, void *structure, unsigned int size, struct hmsg *h, void **p, struct gc_l *pointers, int pack) { diff --git a/src/edp.c b/src/edp.c index 40b2a907..64184555 100644 --- a/src/edp.c +++ b/src/edp.c @@ -23,7 +23,7 @@ #include #include -int seq = 0; +static int seq = 0; int edp_send(struct lldpd *global, struct lldpd_chassis *chassis, diff --git a/src/features.c b/src/features.c index 02c81744..de84ea8e 100644 --- a/src/features.c +++ b/src/features.c @@ -41,7 +41,7 @@ extern unsigned int if_nametoindex (__const char *__ifname) __THROW; extern char *if_indextoname (unsigned int __ifindex, char *__ifname) __THROW; -int +static int old_iface_is_bridge(struct lldpd *cfg, const char *name) { int ifindices[MAX_BRIDGES]; diff --git a/src/lldpctl.c b/src/lldpctl.c index 8eb90bbb..fd622f46 100644 --- a/src/lldpctl.c +++ b/src/lldpctl.c @@ -24,7 +24,7 @@ #include #include -void usage(void); +static void usage(void); TAILQ_HEAD(interfaces, lldpd_interface); #ifdef ENABLE_DOT1 @@ -128,7 +128,7 @@ static const struct value_string operational_mau_type_values[] = { }; #endif -void +static void usage(void) { extern const char *__progname; @@ -165,7 +165,7 @@ dump(void *data, int size, int max, char sep) } -void +static void get_interfaces(int s, struct interfaces *ifs) { void *p; @@ -187,7 +187,7 @@ get_interfaces(int s, struct interfaces *ifs) } #ifdef ENABLE_DOT1 -int +static int get_vlans(int s, struct vlans *vls, char *interface) { void *p; @@ -212,7 +212,7 @@ get_vlans(int s, struct vlans *vls, char *interface) } #endif -int +static int get_chassis(int s, struct lldpd_chassis *chassis, char *interface) { struct hmsg *h; @@ -239,7 +239,7 @@ get_chassis(int s, struct lldpd_chassis *chassis, char *interface) return 1; } -int +static int get_port(int s, struct lldpd_port *port, char *interface) { struct hmsg *h; @@ -267,7 +267,7 @@ get_port(int s, struct lldpd_port *port, char *interface) return 1; } -void +static void display_cap(struct lldpd_chassis *chassis, u_int8_t bit, char *symbol) { if (chassis->c_cap_available & bit) @@ -275,7 +275,7 @@ display_cap(struct lldpd_chassis *chassis, u_int8_t bit, char *symbol) (chassis->c_cap_enabled & bit)?'E':'d'); } -void +static void pretty_print(char *string) { char *s = NULL; @@ -295,7 +295,7 @@ pretty_print(char *string) } #ifdef ENABLE_LLDPMED -int +static int display_fixed_precision(u_int64_t value, int intpart, int floatpart, int displaysign) { u_int64_t tmp = value; @@ -314,7 +314,7 @@ display_fixed_precision(u_int64_t value, int intpart, int floatpart, int display return negative; } -void +static void display_latitude_or_longitude(int option, u_int64_t value) { int negative; @@ -325,7 +325,7 @@ display_latitude_or_longitude(int option, u_int64_t value) printf("%s", negative?" West":" East"); } -void +static void display_med(struct lldpd_chassis *chassis, struct lldpd_port *port) { int i; @@ -607,7 +607,7 @@ display_med(struct lldpd_chassis *chassis, struct lldpd_port *port) } #endif -void +static void display_chassis(struct lldpd_chassis *chassis) { char *cid; @@ -658,7 +658,7 @@ display_chassis(struct lldpd_chassis *chassis) } #ifdef ENABLE_DOT3 -void +static void display_autoneg(struct lldpd_port *port, int bithd, int bitfd, char *desc) { if (!((port->p_autoneg_advertised & bithd) || @@ -678,7 +678,7 @@ display_autoneg(struct lldpd_port *port, int bithd, int bitfd, char *desc) } #endif -void +static void display_port(struct lldpd_port *port) { char *pid; @@ -764,7 +764,7 @@ display_port(struct lldpd_port *port) } #ifdef ENABLE_DOT1 -void +static void display_vlans(struct lldpd_port *port) { int i = 0; @@ -779,7 +779,7 @@ display_vlans(struct lldpd_port *port) } #endif -void +static void display_interfaces(int s, int argc, char *argv[]) { int i; @@ -834,7 +834,7 @@ display_interfaces(int s, int argc, char *argv[]) } #ifdef ENABLE_LLDPMED -int +static int lldpd_parse_location(struct lldpd_port *port, const char *location) { char *l, *e, *s, *data, *n; @@ -1018,7 +1018,7 @@ invalid_location: return -1; } -void +static void set_location(int s, int argc, char *argv[]) { int i, ch; diff --git a/src/lldpd.c b/src/lldpd.c index 1d2364fb..3ad0ef39 100644 --- a/src/lldpd.c +++ b/src/lldpd.c @@ -46,13 +46,13 @@ #include #endif /* USE_SNMP */ -void usage(void); +static void usage(void); -int lldpd_iface_init(struct lldpd *, struct lldpd_hardware *); -int lldpd_iface_init_vlan(struct lldpd *, struct lldpd_vif *); -void lldpd_iface_init_mtu(struct lldpd *, struct lldpd_hardware *); -int lldpd_iface_close(struct lldpd *, struct lldpd_hardware *); -void lldpd_iface_multicast(struct lldpd *, const char *, int); +static int lldpd_iface_init(struct lldpd *, struct lldpd_hardware *); +static int lldpd_iface_init_vlan(struct lldpd *, struct lldpd_vif *); +static void lldpd_iface_init_mtu(struct lldpd *, struct lldpd_hardware *); +static int lldpd_iface_close(struct lldpd *, struct lldpd_hardware *); +static void lldpd_iface_multicast(struct lldpd *, const char *, int); /* "ether proto 0x88cc and ether dst 01:80:c2:00:00:0e" */ #define LLDPD_FILTER_LLDP_F \ @@ -64,7 +64,7 @@ void lldpd_iface_multicast(struct lldpd *, const char *, int); { 0x15, 0, 1, 0x00000180 }, \ { 0x6, 0, 0, 0x0000ffff }, \ { 0x6, 0, 0, 0x00000000 }, -struct sock_filter lldpd_filter_lldp_f[] = { LLDPD_FILTER_LLDP_F }; +static struct sock_filter lldpd_filter_lldp_f[] = { LLDPD_FILTER_LLDP_F }; #ifdef ENABLE_FDP /* "ether dst 01:e0:52:cc:cc:cc" */ #define LLDPD_FILTER_FDP_F \ @@ -74,7 +74,7 @@ struct sock_filter lldpd_filter_lldp_f[] = { LLDPD_FILTER_LLDP_F }; { 0x15, 0, 1, 0x000001e0 }, \ { 0x6, 0, 0, 0x0000ffff }, \ { 0x6, 0, 0, 0x00000000 }, -struct sock_filter lldpd_filter_fdp_f[] = { LLDPD_FILTER_FDP_F }; +static struct sock_filter lldpd_filter_fdp_f[] = { LLDPD_FILTER_FDP_F }; #endif /* ENABLE_FDP */ #ifdef ENABLE_CDP /* "ether dst 01:00:0c:cc:cc:cc" */ @@ -85,7 +85,7 @@ struct sock_filter lldpd_filter_fdp_f[] = { LLDPD_FILTER_FDP_F }; { 0x15, 0, 1, 0x00000100 }, \ { 0x6, 0, 0, 0x0000ffff }, \ { 0x6, 0, 0, 0x00000000 }, -struct sock_filter lldpd_filter_cdp_f[] = { LLDPD_FILTER_CDP_F }; +static struct sock_filter lldpd_filter_cdp_f[] = { LLDPD_FILTER_CDP_F }; #endif /* ENABLE_CDP */ #ifdef ENABLE_SONMP /* "ether dst 01:00:81:00:01:00" */ @@ -96,7 +96,7 @@ struct sock_filter lldpd_filter_cdp_f[] = { LLDPD_FILTER_CDP_F }; { 0x15, 0, 1, 0x00000100 }, \ { 0x6, 0, 0, 0x0000ffff }, \ { 0x6, 0, 0, 0x00000000 }, -struct sock_filter lldpd_filter_sonmp_f[] = { LLDPD_FILTER_SONMP_F }; +static struct sock_filter lldpd_filter_sonmp_f[] = { LLDPD_FILTER_SONMP_F }; #endif /* ENABLE_SONMP */ #ifdef ENABLE_EDP /* "ether dst 00:e0:2b:00:00:00" */ @@ -107,7 +107,7 @@ struct sock_filter lldpd_filter_sonmp_f[] = { LLDPD_FILTER_SONMP_F }; { 0x15, 0, 1, 0x000000e0 }, \ { 0x6, 0, 0, 0x0000ffff }, \ { 0x6, 0, 0, 0x00000000 }, -struct sock_filter lldpd_filter_edp_f[] = { LLDPD_FILTER_EDP_F }; +static struct sock_filter lldpd_filter_edp_f[] = { LLDPD_FILTER_EDP_F }; #endif /* ENABLE_EDP */ #define LLDPD_FILTER_ANY_F \ { 0x28, 0, 0, 0x0000000c }, \ @@ -129,9 +129,9 @@ struct sock_filter lldpd_filter_edp_f[] = { LLDPD_FILTER_EDP_F }; { 0x15, 0, 1, 0x000001e0 }, \ { 0x6, 0, 0, 0x0000ffff }, \ { 0x6, 0, 0, 0x00000000 }, -struct sock_filter lldpd_filter_any_f[] = { LLDPD_FILTER_ANY_F }; +static struct sock_filter lldpd_filter_any_f[] = { LLDPD_FILTER_ANY_F }; -struct protocol protos[] = +static struct protocol protos[] = { { LLDPD_MODE_LLDP, 1, "LLDP", ' ', lldp_send, lldp_decode, NULL, LLDP_MULTICAST_ADDR, lldpd_filter_lldp_f, sizeof(lldpd_filter_lldp_f) }, @@ -157,24 +157,25 @@ struct protocol protos[] = {0,0,0,0,0,0}, lldpd_filter_any_f, sizeof(lldpd_filter_any_f) } }; -int lldpd_iface_switchto(struct lldpd *, short int, +static int lldpd_iface_switchto(struct lldpd *, short int, struct lldpd_hardware *); +static struct lldpd_hardware *lldpd_port_add(struct lldpd *, struct ifaddrs *); -void lldpd_loop(struct lldpd *); -void lldpd_shutdown(int); -void lldpd_exit(); -void lldpd_send_all(struct lldpd *); -void lldpd_recv_all(struct lldpd *); -int lldpd_guess_type(struct lldpd *, char *, int); -void lldpd_decode(struct lldpd *, char *, int, +static void lldpd_loop(struct lldpd *); +static void lldpd_shutdown(int); +static void lldpd_exit(); +static void lldpd_send_all(struct lldpd *); +static void lldpd_recv_all(struct lldpd *); +static int lldpd_guess_type(struct lldpd *, char *, int); +static void lldpd_decode(struct lldpd *, char *, int, struct lldpd_hardware *, int); #ifdef ENABLE_LLDPMED -void lldpd_med(struct lldpd_chassis *); +static void lldpd_med(struct lldpd_chassis *); #endif -char **saved_argv; +static char **saved_argv; -void +static void usage(void) { extern const char *__progname; @@ -183,7 +184,7 @@ usage(void) exit(1); } -void +static void lldpd_iface_init_mtu(struct lldpd *global, struct lldpd_hardware *hardware) { struct ifreq ifr; @@ -198,7 +199,7 @@ lldpd_iface_init_mtu(struct lldpd *global, struct lldpd_hardware *hardware) hardware->h_mtu = hardware->h_lport.p_mfs = ifr.ifr_mtu; } -int +static int lldpd_iface_init_vlan(struct lldpd *global, struct lldpd_vif *vif) { int status; @@ -227,7 +228,7 @@ lldpd_iface_init_vlan(struct lldpd *global, struct lldpd_vif *vif) return 0; } -int +static int lldpd_iface_init(struct lldpd *global, struct lldpd_hardware *hardware) { int master; /* Bond device */ @@ -277,7 +278,7 @@ lldpd_iface_init(struct lldpd *global, struct lldpd_hardware *hardware) return 0; } -void +static void lldpd_iface_multicast(struct lldpd *global, const char *name, int remove) { int i, rc; @@ -296,7 +297,7 @@ lldpd_iface_multicast(struct lldpd *global, const char *name, int remove) } } -int +static int lldpd_iface_close(struct lldpd *global, struct lldpd_hardware *hardware) { char listen[IFNAMSIZ]; @@ -320,7 +321,7 @@ lldpd_iface_close(struct lldpd *global, struct lldpd_hardware *hardware) return 0; } -int +static int lldpd_iface_switchto(struct lldpd *cfg, short int filter, struct lldpd_hardware *hardware) { struct sock_fprog prog; @@ -463,7 +464,7 @@ lldpd_cleanup(struct lldpd *cfg) } } -struct lldpd_vif * +static struct lldpd_vif * lldpd_port_add_vlan(struct lldpd *cfg, struct ifaddrs *ifa) { struct lldpd_vif *vif; @@ -517,7 +518,7 @@ lldpd_port_add_vlan(struct lldpd *cfg, struct ifaddrs *ifa) return vif; } -struct lldpd_hardware * +static struct lldpd_hardware * lldpd_port_add(struct lldpd *cfg, struct ifaddrs *ifa) { #if defined (ENABLE_DOT1) || defined (ENABLE_DOT3) @@ -709,7 +710,7 @@ lldpd_port_add(struct lldpd *cfg, struct ifaddrs *ifa) return (hardware); } -int +static int lldpd_guess_type(struct lldpd *cfg, char *frame, int s) { int i; @@ -729,7 +730,7 @@ lldpd_guess_type(struct lldpd *cfg, char *frame, int s) return -1; } -void +static void lldpd_decode(struct lldpd *cfg, char *frame, int s, struct lldpd_hardware *hardware, int bond) { @@ -977,7 +978,7 @@ cleanup: return; } -void +static void lldpd_recv_all(struct lldpd *cfg) { struct lldpd_hardware *hardware; @@ -1186,7 +1187,7 @@ lldpd_recv_all(struct lldpd *cfg) } while ((rc != 0) || (time(NULL) - cfg->g_lastsent < cfg->g_delay)); } -void +static void lldpd_send_all(struct lldpd *cfg) { struct lldpd_hardware *hardware; @@ -1223,7 +1224,7 @@ lldpd_send_all(struct lldpd *cfg) } #ifdef ENABLE_LLDPMED -void +static void lldpd_med(struct lldpd_chassis *chassis) { free(chassis->c_med_hw); @@ -1241,7 +1242,7 @@ lldpd_med(struct lldpd_chassis *chassis) } #endif -void +static void lldpd_loop(struct lldpd *cfg) { struct ifaddrs *ifap, *ifa; @@ -1369,7 +1370,7 @@ lldpd_loop(struct lldpd *cfg) lldpd_recv_all(cfg); } -void +static void lldpd_shutdown(int sig) { LLOG_INFO("signal received, exiting"); @@ -1377,9 +1378,9 @@ lldpd_shutdown(int sig) } /* For signal handling */ -struct lldpd *gcfg = NULL; +static struct lldpd *gcfg = NULL; -void +static void lldpd_exit() { struct lldpd_hardware *hardware; diff --git a/src/log.c b/src/log.c index 7fa90bbf..3f85eda9 100644 --- a/src/log.c +++ b/src/log.c @@ -26,18 +26,10 @@ #include #include -void log_init(int); -void log_warn(const char *, ...); -void log_warnx(const char *, ...); -void log_info(const char *, ...); -void log_debug(const char *, ...); -void fatal(const char *); -void fatalx(const char *); +static int debug; -int debug; - -void vlog(int, const char *, va_list); -void logit(int, const char *, ...); +static void vlog(int, const char *, va_list); +static void logit(int, const char *, ...); void log_init(int n_debug) @@ -52,7 +44,7 @@ log_init(int n_debug) tzset(); } -void +static void logit(int pri, const char *fmt, ...) { va_list ap; @@ -62,7 +54,7 @@ logit(int pri, const char *fmt, ...) va_end(ap); } -void +static void vlog(int pri, const char *fmt, va_list ap) { char *nfmt; diff --git a/src/priv.c b/src/priv.c index dafe2fa3..21f4bf99 100644 --- a/src/priv.c +++ b/src/priv.c @@ -56,17 +56,17 @@ static int may_read(int, void *, size_t); static void must_read(int, void *, size_t); static void must_write(int, void *, size_t); -int remote; /* Other side */ -int monitored = -1; /* Child */ -int sock = -1; +static int remote; /* Other side */ +static int monitored = -1; /* Child */ +static int sock = -1; /* UID/GID of unprivileged user */ -gid_t gid = 0; -uid_t uid = 0; +static gid_t gid = 0; +static uid_t uid = 0; /* Proxies */ -void +static void priv_ping() { int cmd, rc; @@ -189,14 +189,14 @@ priv_snmp_socket(struct sockaddr_un *addr) return receive_fd(remote); } -void +static void asroot_ping() { int rc = 1; must_write(remote, &rc, sizeof(int)); } -void +static void asroot_ctl_create() { int rc; @@ -216,7 +216,7 @@ asroot_ctl_create() close(rc); } -void +static void asroot_ctl_cleanup() { int rc = 0; @@ -226,7 +226,7 @@ asroot_ctl_cleanup() must_write(remote, &rc, sizeof(int)); } -void +static void asroot_gethostbyname() { struct utsname un; @@ -246,7 +246,7 @@ asroot_gethostbyname() } } -void +static void asroot_open() { const char* authorized[] = { @@ -303,7 +303,7 @@ asroot_open() close(fd); } -void +static void asroot_ethtool() { struct ifreq ifr; @@ -332,7 +332,7 @@ asroot_ethtool() must_write(remote, ðc, sizeof(struct ethtool_cmd)); } -void +static void asroot_iface_init() { struct sockaddr_ll sa; @@ -380,7 +380,7 @@ asroot_iface_init() close(s); } -void +static void asroot_iface_multicast() { int add, rc = 0; @@ -442,7 +442,7 @@ struct dispatch_actions { void(*function)(void); }; -struct dispatch_actions actions[] = { +static struct dispatch_actions actions[] = { {PRIV_PING, asroot_ping}, {PRIV_CREATE_CTL_SOCKET, asroot_ctl_create}, {PRIV_DELETE_CTL_SOCKET, asroot_ctl_cleanup}, @@ -456,7 +456,7 @@ struct dispatch_actions actions[] = { }; /* Main loop, run as root */ -void +static void priv_loop() { int cmd; @@ -475,7 +475,7 @@ priv_loop() /* Should never be there */ } -void +static void priv_exit() { int status; diff --git a/src/sonmp.c b/src/sonmp.c index ab794a2a..cccce679 100644 --- a/src/sonmp.c +++ b/src/sonmp.c @@ -23,7 +23,7 @@ #include #include -struct sonmp_chassis sonmp_chassis_types[] = { +static struct sonmp_chassis sonmp_chassis_types[] = { {1, "unknown (via SONMP)"}, {2, "Nortel 3000"}, {3, "Nortel 3030"},