/* 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)
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)
{
#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)
{
}
#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)
{
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)
{
#include <net-snmp/agent/util_funcs.h>
#include <net-snmp/library/snmpUnixDomain.h>
-oid netsnmp_UnixDomain[] = { TRANSPORT_DOMAIN_LOCAL };
+static oid netsnmp_unix[] = { TRANSPORT_DOMAIN_LOCAL };
static netsnmp_tdomain unixDomain;
static char *
return -1;
}
-netsnmp_transport *
+static netsnmp_transport *
agent_priv_unix_transport(const char *string, int len, int local)
{
struct sockaddr_un addr;
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);
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);
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
#include <errno.h>
#include <arpa/inet.h>
-int
+static int
cdp_send(struct lldpd *global, struct lldpd_chassis *chassis,
struct lldpd_hardware *hardware, int version)
{
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;
#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 },
/* 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;
return 0;
}
-void
+static void
ctl_free_pointers(struct gc_l *pointers, int listonly)
{
struct gc *pointer, *pointer_next;
}
}
-int
+static int
pack_copy(struct hmsg *h, void **p, void *s,
const struct formatdef *ct)
{
return ct->size;
}
-int
+static int
unpack_copy(struct hmsg *h, void **p, void *s,
const struct formatdef *ct, struct gc_l *pointers)
{
return ct->size;
}
-int
+static int
pack_string(struct hmsg *h, void **p, void *s,
const struct formatdef *ct)
{
return ss;
}
-int
+static int
unpack_string(struct hmsg *h, void **p, void *s,
const struct formatdef *ct, struct gc_l *pointers)
{
return sizeof(char*);
}
-int
+static int
pack_chars(struct hmsg *h, void **p, void *s,
const struct formatdef *ct)
{
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)
{
return sizeof(char*);
}
-int
+static int
pack_zero(struct hmsg *h, void **p, void *s,
const struct formatdef *ct)
{
};
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;
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)
{
#include <arpa/inet.h>
#include <fnmatch.h>
-int seq = 0;
+static int seq = 0;
int
edp_send(struct lldpd *global, struct lldpd_chassis *chassis,
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];
#include <sys/un.h>
#include <arpa/inet.h>
-void usage(void);
+static void usage(void);
TAILQ_HEAD(interfaces, lldpd_interface);
#ifdef ENABLE_DOT1
};
#endif
-void
+static void
usage(void)
{
extern const char *__progname;
}
-void
+static void
get_interfaces(int s, struct interfaces *ifs)
{
void *p;
}
#ifdef ENABLE_DOT1
-int
+static int
get_vlans(int s, struct vlans *vls, char *interface)
{
void *p;
}
#endif
-int
+static int
get_chassis(int s, struct lldpd_chassis *chassis, char *interface)
{
struct hmsg *h;
return 1;
}
-int
+static int
get_port(int s, struct lldpd_port *port, char *interface)
{
struct hmsg *h;
return 1;
}
-void
+static void
display_cap(struct lldpd_chassis *chassis, u_int8_t bit, char *symbol)
{
if (chassis->c_cap_available & bit)
(chassis->c_cap_enabled & bit)?'E':'d');
}
-void
+static void
pretty_print(char *string)
{
char *s = NULL;
}
#ifdef ENABLE_LLDPMED
-int
+static int
display_fixed_precision(u_int64_t value, int intpart, int floatpart, int displaysign)
{
u_int64_t tmp = value;
return negative;
}
-void
+static void
display_latitude_or_longitude(int option, u_int64_t value)
{
int negative;
printf("%s", negative?" West":" East");
}
-void
+static void
display_med(struct lldpd_chassis *chassis, struct lldpd_port *port)
{
int i;
}
#endif
-void
+static void
display_chassis(struct lldpd_chassis *chassis)
{
char *cid;
}
#ifdef ENABLE_DOT3
-void
+static void
display_autoneg(struct lldpd_port *port, int bithd, int bitfd, char *desc)
{
if (!((port->p_autoneg_advertised & bithd) ||
}
#endif
-void
+static void
display_port(struct lldpd_port *port)
{
char *pid;
}
#ifdef ENABLE_DOT1
-void
+static void
display_vlans(struct lldpd_port *port)
{
int i = 0;
}
#endif
-void
+static void
display_interfaces(int s, int argc, char *argv[])
{
int i;
}
#ifdef ENABLE_LLDPMED
-int
+static int
lldpd_parse_location(struct lldpd_port *port, const char *location)
{
char *l, *e, *s, *data, *n;
return -1;
}
-void
+static void
set_location(int s, int argc, char *argv[])
{
int i, ch;
#include <net-snmp/agent/snmp_vars.h>
#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 \
{ 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 \
{ 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" */
{ 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" */
{ 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" */
{ 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 }, \
{ 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) },
{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;
exit(1);
}
-void
+static void
lldpd_iface_init_mtu(struct lldpd *global, struct lldpd_hardware *hardware)
{
struct ifreq ifr;
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;
return 0;
}
-int
+static int
lldpd_iface_init(struct lldpd *global, struct lldpd_hardware *hardware)
{
int master; /* Bond device */
return 0;
}
-void
+static void
lldpd_iface_multicast(struct lldpd *global, const char *name, int remove)
{
int i, rc;
}
}
-int
+static int
lldpd_iface_close(struct lldpd *global, struct lldpd_hardware *hardware)
{
char listen[IFNAMSIZ];
return 0;
}
-int
+static int
lldpd_iface_switchto(struct lldpd *cfg, short int filter, struct lldpd_hardware *hardware)
{
struct sock_fprog prog;
}
}
-struct lldpd_vif *
+static struct lldpd_vif *
lldpd_port_add_vlan(struct lldpd *cfg, struct ifaddrs *ifa)
{
struct lldpd_vif *vif;
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)
return (hardware);
}
-int
+static int
lldpd_guess_type(struct lldpd *cfg, char *frame, int s)
{
int i;
return -1;
}
-void
+static void
lldpd_decode(struct lldpd *cfg, char *frame, int s,
struct lldpd_hardware *hardware, int bond)
{
return;
}
-void
+static void
lldpd_recv_all(struct lldpd *cfg)
{
struct lldpd_hardware *hardware;
} while ((rc != 0) || (time(NULL) - cfg->g_lastsent < cfg->g_delay));
}
-void
+static void
lldpd_send_all(struct lldpd *cfg)
{
struct lldpd_hardware *hardware;
}
#ifdef ENABLE_LLDPMED
-void
+static void
lldpd_med(struct lldpd_chassis *chassis)
{
free(chassis->c_med_hw);
}
#endif
-void
+static void
lldpd_loop(struct lldpd *cfg)
{
struct ifaddrs *ifap, *ifa;
lldpd_recv_all(cfg);
}
-void
+static void
lldpd_shutdown(int sig)
{
LLOG_INFO("signal received, exiting");
}
/* For signal handling */
-struct lldpd *gcfg = NULL;
+static struct lldpd *gcfg = NULL;
-void
+static void
lldpd_exit()
{
struct lldpd_hardware *hardware;
#include <syslog.h>
#include <time.h>
-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)
tzset();
}
-void
+static void
logit(int pri, const char *fmt, ...)
{
va_list ap;
va_end(ap);
}
-void
+static void
vlog(int pri, const char *fmt, va_list ap)
{
char *nfmt;
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;
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;
close(rc);
}
-void
+static void
asroot_ctl_cleanup()
{
int rc = 0;
must_write(remote, &rc, sizeof(int));
}
-void
+static void
asroot_gethostbyname()
{
struct utsname un;
}
}
-void
+static void
asroot_open()
{
const char* authorized[] = {
close(fd);
}
-void
+static void
asroot_ethtool()
{
struct ifreq ifr;
must_write(remote, ðc, sizeof(struct ethtool_cmd));
}
-void
+static void
asroot_iface_init()
{
struct sockaddr_ll sa;
close(s);
}
-void
+static void
asroot_iface_multicast()
{
int add, rc = 0;
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},
};
/* Main loop, run as root */
-void
+static void
priv_loop()
{
int cmd;
/* Should never be there */
}
-void
+static void
priv_exit()
{
int status;
#include <errno.h>
#include <arpa/inet.h>
-struct sonmp_chassis sonmp_chassis_types[] = {
+static struct sonmp_chassis sonmp_chassis_types[] = {
{1, "unknown (via SONMP)"},
{2, "Nortel 3000"},
{3, "Nortel 3030"},