mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-31 01:04:03 -05:00
drivers: Move driver_wired_deinit_common() to a common file
This continues refactoring of the common parts of wired drivers code into a shared file, so that they can be reused by other drivers. Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
This commit is contained in:
parent
ed5ae61193
commit
ec9cfb96c2
@ -174,43 +174,8 @@ static void * macsec_qca_init(void *ctx, const char *ifname)
|
||||
static void macsec_qca_deinit(void *priv)
|
||||
{
|
||||
struct macsec_qca_data *drv = priv;
|
||||
int flags;
|
||||
|
||||
if (drv->common.membership &&
|
||||
wired_multicast_membership(drv->common.pf_sock,
|
||||
if_nametoindex(drv->common.ifname),
|
||||
pae_group_addr, 0) < 0) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"%s: Failed to remove PAE multicast group (PACKET)",
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (drv->common.multi &&
|
||||
driver_wired_multi(drv->common.ifname, pae_group_addr, 0) < 0) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"%s: Failed to remove PAE multicast group (SIOCDELMULTI)",
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (drv->common.iff_allmulti &&
|
||||
(driver_wired_get_ifflags(drv->common.ifname, &flags) < 0 ||
|
||||
driver_wired_set_ifflags(drv->common.ifname,
|
||||
flags & ~IFF_ALLMULTI) < 0)) {
|
||||
wpa_printf(MSG_DEBUG, "%s: Failed to disable allmulti mode",
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (drv->common.iff_up &&
|
||||
driver_wired_get_ifflags(drv->common.ifname, &flags) == 0 &&
|
||||
(flags & IFF_UP) &&
|
||||
driver_wired_set_ifflags(drv->common.ifname, flags & ~IFF_UP) < 0) {
|
||||
wpa_printf(MSG_DEBUG, "%s: Failed to set the interface down",
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (drv->common.pf_sock != -1)
|
||||
close(drv->common.pf_sock);
|
||||
|
||||
driver_wired_deinit_common(&drv->common);
|
||||
os_free(drv);
|
||||
}
|
||||
|
||||
|
@ -410,41 +410,8 @@ static void * wpa_driver_wired_init(void *ctx, const char *ifname)
|
||||
static void wpa_driver_wired_deinit(void *priv)
|
||||
{
|
||||
struct wpa_driver_wired_data *drv = priv;
|
||||
int flags;
|
||||
|
||||
if (drv->common.membership &&
|
||||
wired_multicast_membership(drv->common.pf_sock,
|
||||
if_nametoindex(drv->common.ifname),
|
||||
pae_group_addr, 0) < 0) {
|
||||
wpa_printf(MSG_DEBUG, "%s: Failed to remove PAE multicast "
|
||||
"group (PACKET)", __func__);
|
||||
}
|
||||
|
||||
if (drv->common.multi &&
|
||||
driver_wired_multi(drv->common.ifname, pae_group_addr, 0) < 0) {
|
||||
wpa_printf(MSG_DEBUG, "%s: Failed to remove PAE multicast "
|
||||
"group (SIOCDELMULTI)", __func__);
|
||||
}
|
||||
|
||||
if (drv->common.iff_allmulti &&
|
||||
(driver_wired_get_ifflags(drv->common.ifname, &flags) < 0 ||
|
||||
driver_wired_set_ifflags(drv->common.ifname,
|
||||
flags & ~IFF_ALLMULTI) < 0)) {
|
||||
wpa_printf(MSG_DEBUG, "%s: Failed to disable allmulti mode",
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (drv->common.iff_up &&
|
||||
driver_wired_get_ifflags(drv->common.ifname, &flags) == 0 &&
|
||||
(flags & IFF_UP) &&
|
||||
driver_wired_set_ifflags(drv->common.ifname, flags & ~IFF_UP) < 0) {
|
||||
wpa_printf(MSG_DEBUG, "%s: Failed to set the interface down",
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (drv->common.pf_sock != -1)
|
||||
close(drv->common.pf_sock);
|
||||
|
||||
driver_wired_deinit_common(&drv->common);
|
||||
os_free(drv);
|
||||
}
|
||||
|
||||
|
@ -256,3 +256,44 @@ int driver_wired_init_common(struct driver_wired_common_data *common,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void driver_wired_deinit_common(struct driver_wired_common_data *common)
|
||||
{
|
||||
int flags;
|
||||
|
||||
if (common->membership &&
|
||||
wired_multicast_membership(common->pf_sock,
|
||||
if_nametoindex(common->ifname),
|
||||
pae_group_addr, 0) < 0) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"%s: Failed to remove PAE multicast group (PACKET)",
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (common->multi &&
|
||||
driver_wired_multi(common->ifname, pae_group_addr, 0) < 0) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"%s: Failed to remove PAE multicast group (SIOCDELMULTI)",
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (common->iff_allmulti &&
|
||||
(driver_wired_get_ifflags(common->ifname, &flags) < 0 ||
|
||||
driver_wired_set_ifflags(common->ifname,
|
||||
flags & ~IFF_ALLMULTI) < 0)) {
|
||||
wpa_printf(MSG_DEBUG, "%s: Failed to disable allmulti mode",
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (common->iff_up &&
|
||||
driver_wired_get_ifflags(common->ifname, &flags) == 0 &&
|
||||
(flags & IFF_UP) &&
|
||||
driver_wired_set_ifflags(common->ifname, flags & ~IFF_UP) < 0) {
|
||||
wpa_printf(MSG_DEBUG, "%s: Failed to set the interface down",
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (common->pf_sock != -1)
|
||||
close(common->pf_sock);
|
||||
}
|
||||
|
@ -30,5 +30,6 @@ int driver_wired_get_ifstatus(const char *ifname, int *status);
|
||||
|
||||
int driver_wired_init_common(struct driver_wired_common_data *common,
|
||||
const char *ifname, void *ctx);
|
||||
void driver_wired_deinit_common(struct driver_wired_common_data *common);
|
||||
|
||||
#endif /* DRIVER_WIRED_COMMON_H */
|
||||
|
Loading…
Reference in New Issue
Block a user