Example #1
0
    def get_if_bcast(self, iff):
        for net, msk, gw, iface, addr, metric in self.routes:
            if net == 0:
                continue
            if scapy.consts.WINDOWS:
                if iff.guid != iface.guid:
                    continue
            elif iff != iface:
                continue
            bcast = atol(addr) | (
                ~msk & 0xffffffff
            )  # FIXME: check error in atol()  # noqa: E501
            return ltoa(bcast)
        warning("No broadcast address found for iface %s\n", iff)


conf.route = Route()

iface = conf.route.route("0.0.0.0", verbose=0)[0]

# Warning: scapy.consts.LOOPBACK_INTERFACE must always be used statically, because it  # noqa: E501
# may be changed by scapy/arch/windows during execution

if getattr(iface, "name", iface) == scapy.consts.LOOPBACK_INTERFACE:
    from scapy.arch import get_working_if
    conf.iface = get_working_if()
else:
    conf.iface = iface

del iface
Example #2
0
        return ret

    def get_if_bcast(self, iff):
        for net, msk, gw, iface, addr, metric in self.routes:
            if net == 0:
                continue
            if scapy.consts.WINDOWS:
                if iff.guid != iface.guid:
                    continue
            elif iff != iface:
                continue
            bcast = atol(addr) | (~msk & 0xffffffff)  # FIXME: check error in atol()  # noqa: E501
            return ltoa(bcast)
        warning("No broadcast address found for iface %s\n", iff)


conf.route = Route()

iface = conf.route.route("0.0.0.0", verbose=0)[0]

# Warning: scapy.consts.LOOPBACK_INTERFACE must always be used statically, because it  # noqa: E501
# may be changed by scapy/arch/windows during execution

if getattr(iface, "name", iface) == scapy.consts.LOOPBACK_INTERFACE:
    from scapy.arch import get_working_if
    conf.iface = get_working_if()
else:
    conf.iface = iface

del iface