#define MAX_BRIDGES 1024
static struct sock_filter lldpd_filter_f[] = { LLDPD_FILTER_F };
-int
-interfaces_set_filter(const char *name, int fd)
+static int
+iflinux_set_filter(const char *name, int fd)
{
struct sock_fprog prog;
log_debug("interfaces", "set BPF filter for %s", name);
return 0;
}
+static int
+iflinux_eth_init(struct lldpd *cfg, struct lldpd_hardware *hardware)
+{
+ int fd, status;
+
+ log_debug("interfaces", "initialize ethernet device %s",
+ hardware->h_ifname);
+ if ((fd = priv_iface_init(hardware->h_ifindex)) == -1)
+ return -1;
+ hardware->h_sendfd = fd; /* Send */
+
+ /* Set filter */
+ if ((status = iflinux_set_filter(hardware->h_ifname, fd)) != 0) {
+ close(fd);
+ return status;
+ }
+
+ interfaces_setup_multicast(cfg, hardware->h_ifname, 0);
+
+ levent_hardware_add_fd(hardware, fd); /* Receive */
+ log_debug("interfaces", "interface %s initialized (fd=%d)", hardware->h_ifname,
+ fd);
+ return 0;
+}
+
static int
old_iflinux_is_bridge(struct lldpd *cfg,
struct interfaces_device_list *interfaces,
if ((fd = priv_iface_init(hardware->h_ifindex)) == -1)
return -1;
hardware->h_sendfd = fd;
- if ((status = interfaces_set_filter(hardware->h_ifname, fd)) != 0) {
+ if ((status = iflinux_set_filter(hardware->h_ifname, fd)) != 0) {
close(fd);
return status;
}
close(hardware->h_sendfd);
return -1;
}
- if ((status = interfaces_set_filter(master->name, fd)) != 0) {
+ if ((status = iflinux_set_filter(master->name, fd)) != 0) {
close(hardware->h_sendfd);
close(fd);
return status;
interfaces_helper_whitelist(cfg, interfaces);
iflinux_handle_bond(cfg, interfaces);
- interfaces_helper_physical(cfg, interfaces);
+ interfaces_helper_physical(cfg, interfaces,
+ iflinux_eth_init);
#ifdef ENABLE_DOT1
interfaces_helper_vlan(cfg, interfaces);
#endif
}
}
-static int
-iface_eth_init(struct lldpd *cfg, struct lldpd_hardware *hardware)
-{
- int fd, status;
-
- log_debug("interfaces", "initialize ethernet device %s",
- hardware->h_ifname);
- if ((fd = priv_iface_init(hardware->h_ifindex)) == -1)
- return -1;
- hardware->h_sendfd = fd; /* Send */
-
- /* Set filter */
- if ((status = interfaces_set_filter(hardware->h_ifname, fd)) != 0) {
- close(fd);
- return status;
- }
-
- interfaces_setup_multicast(cfg, hardware->h_ifname, 0);
-
- levent_hardware_add_fd(hardware, fd); /* Receive */
- log_debug("interfaces", "interface %s initialized (fd=%d)", hardware->h_ifname,
- fd);
- return 0;
-}
-
/**
* Free an interface.
*
void
interfaces_helper_physical(struct lldpd *cfg,
- struct interfaces_device_list *interfaces)
+ struct interfaces_device_list *interfaces,
+ int(*init)(struct lldpd *, struct lldpd_hardware *))
{
struct interfaces_device *iface;
struct lldpd_hardware *hardware;
iface->name);
continue;
}
- if (iface_eth_init(cfg, hardware) != 0) {
+ if (init(cfg, hardware) != 0) {
log_warn("interfaces",
"unable to initialize %s",
hardware->h_ifname);
* `interfaces.c` as helper by providing a list of OS-independent interface
* devices. */
void interfaces_update(struct lldpd *);
-int interfaces_set_filter(const char *name, int fd);
/* interfaces.c */
/* An interface cannot be both physical and (bridge or bond or vlan) */
void interfaces_helper_chassis(struct lldpd *,
struct interfaces_device_list *);
void interfaces_helper_physical(struct lldpd *,
- struct interfaces_device_list *);
+ struct interfaces_device_list *,
+ int(*init)(struct lldpd *, struct lldpd_hardware *));
void interfaces_helper_port_name_desc(struct lldpd_hardware *,
struct interfaces_device *);
void interfaces_helper_mgmt(struct lldpd *,