Esempio n. 1
0
class HPAI(Packet):
    name = "HPAI"
    fields_desc = [
        ByteField("structure_length", None),
        ByteEnumField("host_protocol", 0x01, HOST_PROTOCOL_CODES),
        IPField("ip_address", None),
        ShortField("port", None)
    ]

    def post_build(self, p, pay):
        p = (len(p)).to_bytes(1, byteorder='big') + p[1:]
        return p + pay
Esempio n. 2
0
class _RadiusAttrIPv4AddrVal(_SpecificRadiusAttr):
    """
    Implements a RADIUS attribute which value field is an IPv4 address.
    """

    __slots__ = ["val"]

    fields_desc = [
        ByteEnumField("type", 4, _radius_attribute_types),
        ByteField("len", 6),
        IPField("value", "0.0.0.0")
    ]
Esempio n. 3
0
class CDPAddrRecordIPv4(CDPAddrRecord):
    name = "CDP Address IPv4"
    fields_desc = [
        ByteEnumField("ptype", 0x01, _cdp_addr_record_ptype),
        FieldLenField("plen", 1, "proto", "B"),
        StrLenField("proto",
                    _cdp_addrrecord_proto_ip,
                    length_from=lambda x: x.plen,
                    max_length=255),
        ShortField("addrlen", 4),
        IPField("addr", "0.0.0.0")
    ]
Esempio n. 4
0
class AllowedPreviewGroupsRow1(Packet):
    name = "AllowedPreviewGroupsRow1"
    fields_desc = [
        BitField("set_ctrl", 0, 2),
        BitField("row_part_id", 0, 3),
        BitField("reserved0", 0, 1),
        BitField("row_key", 0, 10),
        StrFixedLenField("ipv6_pad", 0, 12),
        IPField("dst_ip", None),
        ShortField("duration", None),
        ShortField("time_left", None)
    ]
Esempio n. 5
0
class PWOSPF(Packet):
    name = "PWOSPF"
    fields_desc = [
        ByteField("version", None),
        ByteField("type", None),
        ShortField("length", None),
        IPField("routerID", None),
        IntField("areaID", None),
        ShortField("checksum", None),
        ShortField("auType", 0),
        LongField("auth", 0)
    ]
Esempio n. 6
0
class PPP_IPCP_Option_IPAddress(PPP_IPCP_Option):
    name = "PPP IPCP Option: IP Address"
    fields_desc = [
        ByteEnumField("type", 3, _PPP_ipcpopttypes),
        FieldLenField("len",
                      None,
                      length_of="data",
                      fmt="B",
                      adjust=lambda _, val: val + 2),
        IPField("data", "0.0.0.0"),
        StrLenField("garbage", "", length_from=lambda pkt: pkt.len - 6),
    ]
Esempio n. 7
0
class IpHostConfigData(EntityClass):
    class_id = 134
    attributes = [
        ECA(ShortField("managed_entity_id", None), {AA.R}),
        ECA(ByteField("ip_options", None), {AA.R, AA.W}),
        ECA(MACField("mac_address", None), {AA.R}),
        ECA(StrFixedLenField("ont_identifier", None, 25), {AA.R, AA.W}),
        ECA(IPField("ip_address", None), {AA.R, AA.W}),
        ECA(IPField("mask", None), {AA.R, AA.W}),
        ECA(IPField("gateway", None), {AA.R, AA.W}),
        ECA(IPField("primary_dns", None), {AA.R, AA.W}),
        ECA(IPField("secondary_dns", None), {AA.R, AA.W}),
        ECA(IPField("current_address", None), {AA.R}),
        ECA(IPField("current_mask", None), {AA.R}),
        ECA(IPField("current_gateway", None), {AA.R}),
        ECA(IPField("current_primary_dns", None), {AA.R}),
        ECA(IPField("current_secondary_dns", None), {AA.R}),
        ECA(StrFixedLenField("domain_name", None, 25), {AA.R}),
        ECA(StrFixedLenField("host_name", None, 25), {AA.R}),
    ]
    mandatory_operations = {OP.Get, OP.Set, OP.Test}
Esempio n. 8
0
class AllowedPreviewGroupsRow0(Packet):
    name = "AllowedPreviewGroupsRow0"
    fields_desc = [
        BitField("set_ctrl", 0, 2),
        BitField("row_part_id", 0, 3),
        BitField("reserved0", 0, 1),
        BitField("row_key", 0, 10),
        StrFixedLenField("ipv6_pad", 0, 12),
        IPField("src_ip", None),
        ShortField("vlan_id_ani", None),
        ShortField("vlan_id_uni", None)
    ]
Esempio n. 9
0
class BOOTP(Packet):
    name = "BOOTP"
    fields_desc = [ByteEnumField("op", 1, {1: "BOOTREQUEST", 2: "BOOTREPLY"}),
                   ByteField("htype", 1),
                   ByteField("hlen", 6),
                   ByteField("hops", 0),
                   IntField("xid", 0),
                   ShortField("secs", 0),
                   FlagsField("flags", 0, 16, "???????????????B"),
                   IPField("ciaddr", "0.0.0.0"),
                   IPField("yiaddr", "0.0.0.0"),
                   IPField("siaddr", "0.0.0.0"),
                   IPField("giaddr", "0.0.0.0"),
                   Field("chaddr", b"", "16s"),
                   Field("sname", b"", "64s"),
                   Field("file", b"", "128s"),
                   StrField("options", b"")]

    def guess_payload_class(self, payload):
        if self.options[:len(dhcpmagic)] == dhcpmagic:
            return DHCP
        else:
            return Packet.guess_payload_class(self, payload)

    def extract_padding(self, s):
        if self.options[:len(dhcpmagic)] == dhcpmagic:
            # set BOOTP options to DHCP magic cookie and make rest a payload of DHCP options  # noqa: E501
            payload = self.options[len(dhcpmagic):]
            self.options = self.options[:len(dhcpmagic)]
            return payload, None
        else:
            return b"", None

    def hashret(self):
        return struct.pack("!I", self.xid)

    def answers(self, other):
        if not isinstance(other, BOOTP):
            return 0
        return self.xid == other.xid
Esempio n. 10
0
class LLDPDUPortID(LLDPDU):
    """
        ieee 802.1ab-2016 - sec. 8.5.3 / p. 26
    """
    LLDP_PORT_ID_TLV_SUBTYPES = {
        0x00: 'reserved',
        0x01: 'interface alias',
        0x02: 'port component',
        0x03: 'MAC address',
        0x04: 'network address',
        0x05: 'interface name',
        0x06: 'agent circuit ID',
        0x07: 'locally assigned',
        range(0x08, 0xff): 'reserved'
    }

    SUBTYPE_RESERVED = 0x00
    SUBTYPE_INTERFACE_ALIAS = 0x01
    SUBTYPE_PORT_COMPONENT = 0x02
    SUBTYPE_MAC_ADDRESS = 0x03
    SUBTYPE_NETWORK_ADDRESS = 0x04
    SUBTYPE_INTERFACE_NAME = 0x05
    SUBTYPE_AGENT_CIRCUIT_ID = 0x06
    SUBTYPE_LOCALLY_ASSIGNED = 0x07

    fields_desc = [
        BitEnumField('_type', 0x02, 7, LLDPDU.TYPES),
        BitFieldLenField('_length',
                         None,
                         9,
                         length_of='id',
                         adjust=lambda pkt, x: _ldp_id_adjustlen(pkt, x)),
        ByteEnumField('subtype', 0x00, LLDP_PORT_ID_TLV_SUBTYPES),
        ConditionalField(ByteField('family', 0),
                         lambda pkt: pkt.subtype == 0x04),
        MultipleTypeField([
            (MACField('id', None), lambda pkt: pkt.subtype == 0x03),
            (IPField('id', None), lambda pkt: pkt.subtype == 0x04),
        ],
                          StrLenField(
                              'id',
                              '',
                              length_from=lambda pkt: 0
                              if pkt._length is None else pkt._length - 1))
    ]

    def _check(self):
        """
        run layer specific checks
        """
        if conf.contribs['LLDP'].strict_mode() and not self.id:
            raise LLDPInvalidLengthField('id must be >= 1 characters long')
Esempio n. 11
0
class LDP(_LDP_Packet):
    name = "LDP"
    fields_desc = [ShortField("version", 1),
                   ShortField("len", None),
                   IPField("id", "127.0.0.1"),
                   ShortField("space", 0)]

    def post_build(self, p, pay):
        pay = pay or b""
        if self.len is None:
            tmp_len = len(p) + len(pay) - 4
            p = p[:2] + struct.pack("!H", tmp_len) + p[4:]
        return p + pay
Esempio n. 12
0
class NetflowRecordV5(Packet):
    name = "Netflow Record v5"
    fields_desc = [IPField("src", "127.0.0.1"),
                   IPField("dst", "127.0.0.1"),
                   IPField("nexthop", "0.0.0.0"),
                   ShortField("input", 0),
                   ShortField("output", 0),
                   IntField("dpkts", 1),
                   IntField("dOctets", 60),
                   IntField("first", 0),
                   IntField("last", 0),
                   ShortField("srcport", 0),
                   ShortField("dstport", 0),
                   ByteField("pad1", 0),
                   FlagsField("tcpFlags", 0x2, 8, "FSRPAUEC"),
                   ByteEnumField("prot", IP_PROTOS["tcp"], IP_PROTOS),
                   ByteField("tos", 0),
                   ShortField("src_as", 0),
                   ShortField("dst_as", 0),
                   ByteField("src_mask", 0),
                   ByteField("dst_mask", 0),
                   ShortField("pad2", 0)]
Esempio n. 13
0
class HPAI(Packet):
    name = "HPAI"
    fields_desc = [
        ByteField("structure_length", None),
        ByteEnumField("host_protocol", 0x01, HOST_PROTOCOL_CODES),
        IPField("ip_address", None),
        ShortField("port", None)
    ]

    def post_build(self, p, pay):
        if self.structure_length is None:
            p = struct.pack("!B", len(p)) + p[1:]
        return p + pay
Esempio n. 14
0
class PWOSPF_LSA(Packet):
    """
    Link state advertisements

    Each link state update packet should contain 1 or more link state
    advertisements.  The advertisements are the reachable routes directly
    connected to the advertising router.  Routes are in the form of the subnet,
    mask and router neighor for the attached link. Link state advertisements
    look specifically as follows:

    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                           Subnet                              |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                           Mask                                |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                         Router ID                             |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

    subnet
        Subnet number of the advertised route.  Note that default routes
        will have a subnet value of 0.0.0.0.

    Mask
        Subnet mask of the advertised route

    Router ID
        ID of the neighboring router on the advertised link.  If there is no
        connected router to the link the RID should be set to 0.
    """
    name = "PWOSPF Link State Advertisement"

    fields_desc = [
        IPField('subnet', '10.0.0.0'),
        IPField('mask', '255.255.255.0'),
        IPField('routerid', '1.1.1.1')
    ]

    def extract_padding(self, s):
        return '', s
Esempio n. 15
0
class PIMv2CRPAdv(_PIMGenericTlvBase):
    name = "Bootstrap crp adv"
    fields_desc = [
        BitFieldLenField("prefix_count", None, size=8, count_of="groups"),
        ByteField("priority", 192),
        ShortField("holdtime", 150),
        ByteField("rp_address_family", 1),
        ByteField("rp_address_type", 0),
        IPField("rp_address", "0.0.0.0"),
        PacketListField("groups", [],
                        EncodedGroupAddr,
                        count_from=lambda x: x.groups)
    ]
Esempio n. 16
0
class EIGRPExtRoute(EIGRPGeneric):
    name = "EIGRP External Route"
    fields_desc = [XShortField("type", 0x0103),
                   FieldLenField("len", None, "dst", "!H", adjust=lambda pkt, x: x + 45),  # noqa: E501
                   IPField("nexthop", "192.168.0.0"),
                   IPField("originrouter", "192.168.0.1"),
                   IntField("originasn", 0),
                   IntField("tag", 0),
                   IntField("externalmetric", 0),
                   ShortField("reserved", 0),
                   ByteEnumField("extprotocolid", 3, _EIGRP_EXTERNAL_PROTOCOL_ID),  # noqa: E501
                   FlagsField("flags", 0, 8, _EIGRP_EXTROUTE_FLAGS),
                   IntField("delay", 0),
                   IntField("bandwidth", 256),
                   ThreeBytesField("mtu", 1500),
                   ByteField("hopcount", 0),
                   ByteField("reliability", 255),
                   ByteField("load", 0),
                   XShortField("reserved2", 0),
                   ByteField("prefixlen", 24),
                   EigrpIPField("dst", "192.168.1.0", length_from=lambda pkt: pkt.prefixlen)  # noqa: E501
                   ]
Esempio n. 17
0
class SkinnyMessageCloseReceiveChannel(Packet):
    name = 'close receive channel'
    fields_desc = [
        LEIntField('conference', 0),
        LEIntField('passthru', 0),
        IPField('remote', '0.0.0.0'),
        LEIntField('port', RandShort()),
        SkinnyRateField('rate', 20),
        LEIntEnumField('codec', 4, _skinny_codecs),
        LEIntField('precedence', 200),
        LEIntEnumField('silence', 0, _skinny_silence),
        LEIntField('callid', 0)
    ]
Esempio n. 18
0
class OSPF_Hello(Packet):
    name = "OSPF Hello"
    fields_desc = [
        IPField("mask", "255.255.255.0"),
        ShortField("hellointerval", 10),
        OSPFOptionsField(),
        ByteField("prio", 1),
        IntField("deadinterval", 40),
        IPField("router", "0.0.0.0"),
        IPField("backup", "0.0.0.0"),
        FieldListField("neighbors", [],
                       IPField("", "0.0.0.0"),
                       length_from=lambda pkt: (pkt.underlayer.len - 44)
                       if pkt.underlayer else None)
    ]  # noqa: E501

    def guess_payload_class(self, payload):
        # check presence of LLS data block flag
        if self.options & 0x10 == 0x10:
            return OSPF_LLS_Hdr
        else:
            return Packet.guess_payload_class(self, payload)
Esempio n. 19
0
class OSPFv3_Link(Packet):
    name = "OSPFv3 Link"
    fields_desc = [
        ByteEnumField("type", 1, _OSPFv3_Router_LSA_types),
        ByteField("reserved", 0),
        ShortField("metric", 10),
        IntField("intid", 0),
        IntField("neighintid", 0),
        IPField("neighbor", "2.2.2.2")
    ]

    def extract_padding(self, s):
        return "", s
Esempio n. 20
0
class PIMv2JoinPrune(_PIMGenericTlvBase):
    name = "PIMv2 Join/Prune Options"
    fields_desc = [
        ByteField("up_addr_family", 1),
        ByteField("up_encoding_type", 0),
        IPField("up_neighbor_ip", "0.0.0.0"),
        ByteField("reserved", 0),
        FieldLenField("num_group", None, count_of="jp_ips", fmt="B"),
        ShortField("holdtime", 210),
        PacketListField("jp_ips", [],
                        PIMv2GroupAddrs,
                        count_from=lambda pkt: pkt.num_group)
    ]
Esempio n. 21
0
class DCPIPBlock(Packet):
    fields_desc = [
        ByteEnumField("option", 1, DCP_OPTIONS),
        MultiEnumField("sub_option",
                       2,
                       DCP_SUBOPTIONS,
                       fmt='B',
                       depends_on=lambda p: p.option),
        LenField("dcp_block_length", None),
        ShortEnumField("block_info", 1, IP_BLOCK_INFOS),
        IPField("ip", "192.168.0.2"),
        IPField("netmask", "255.255.255.0"),
        IPField("gateway", "192.168.0.1"),
        PadField(StrLenField("padding",
                             b"\x00",
                             length_from=lambda p: p.dcp_block_length % 2),
                 1,
                 padwith=b"\x00")
    ]

    def extract_padding(self, s):
        return '', s
Esempio n. 22
0
class IE_GSNAddress(IE_Base):
    name = "GSN Address"
    fields_desc = [ByteEnumField("ietype", 133, IEType),
                   ShortField("length", None),
                   ConditionalField(IPField("ipv4_address", RandIP()),
                                    lambda pkt: pkt.length == 4),
                   ConditionalField(IP6Field("ipv6_address", '::1'),
                                    lambda pkt: pkt.length == 16)]

    def post_build(self, p, pay):
        if self.length is None:
            tmp_len = len(p) - 3
            p = p[:2] + struct.pack("!B", tmp_len) + p[3:]
        return p
Esempio n. 23
0
class SCTPChunkParamAddIPAddr(_SCTPChunkParam, Packet):
    fields_desc = [ShortEnumField("type", 0xc001, sctpchunkparamtypes),
                   FieldLenField("len", None, length_of="addr",
                                 adjust=lambda pkt, x:x + 12),
                   XIntField("correlation_id", None),
                   ShortEnumField("addr_type", 5, sctpchunkparamtypes),
                   FieldLenField("addr_len", None, length_of="addr",
                                 adjust=lambda pkt, x:x + 4),
                   ConditionalField(
        IPField("addr", "127.0.0.1"),
        lambda p: p.addr_type == 5),
        ConditionalField(
        IP6Field("addr", "::1"),
        lambda p: p.addr_type == 6), ]
Esempio n. 24
0
class PPP_IPCP_Option_NBNS2(PPP_IPCP_Option):
    name = "PPP IPCP Option: NBNS2 Address"
    fields_desc = [
        ByteEnumField("type", 132, _PPP_ipcpopttypes),
        FieldLenField("len",
                      None,
                      length_of="data",
                      fmt="B",
                      adjust=lambda p, x: x + 2),
        IPField("data", "0.0.0.0"),
        ConditionalField(
            StrLenField("garbage", "", length_from=lambda pkt: pkt.len - 6),
            lambda p: p.len != 6)
    ]
Esempio n. 25
0
class IE_FTEID(gtp.IE_Base):
    name = "IE F-TEID"
    fields_desc = [ByteEnumField("ietype", 87, IEType),
                   ShortField("length", 0),
                   BitField("CR_flag", 0, 4),
                   BitField("instance", 0, 4),
                   BitField("ipv4_present", 0, 1),
                   BitField("ipv6_present", 0, 1),
                   BitField("InterfaceType", 0, 6),
                   XIntField("GRE_Key", 0),
                   ConditionalField(
        IPField("ipv4", RandIP()), lambda pkt: pkt.ipv4_present),
        ConditionalField(XBitField("ipv6", "2001::", 128),
                         lambda pkt: pkt.ipv6_present)]
Esempio n. 26
0
class SLARP(Packet):
    name = "SLARP"
    fields_desc = [
        IntEnumField("type", 2, {
            0: "request",
            1: "reply",
            2: "line keepalive"
        }),  # noqa: E501
        ConditionalField(
            IPField("address", "192.168.0.1"),
            lambda pkt: pkt.type == 0 or pkt.type == 1),  # noqa: E501
        ConditionalField(
            IPField("mask", "255.255.255.0"),
            lambda pkt: pkt.type == 0 or pkt.type == 1),  # noqa: E501
        ConditionalField(
            XShortField("unused", 0),
            lambda pkt: pkt.type == 0 or pkt.type == 1),  # noqa: E501
        ConditionalField(IntField("mysequence", 0), lambda pkt: pkt.type == 2),
        ConditionalField(IntField("yoursequence", 0),
                         lambda pkt: pkt.type == 2),
        ConditionalField(XShortField("reliability", 0xffff),
                         lambda pkt: pkt.type == 2)
    ]
Esempio n. 27
0
class ICMPExtensionInterfaceInformation(ICMPExtensionObject):
    name = 'ICMP Extension Object - Interface Information Object (RFC5837)'

    fields_desc = [
        ShortField('len', None),
        ByteField('classnum', 2),
        BitField('interface_role', 0, 2),
        BitField('reserved', 0, 2),
        BitField('has_ifindex', 0, 1),
        BitField('has_ipaddr', 0, 1),
        BitField('has_ifname', 0, 1),
        BitField('has_mtu', 0, 1),
        ConditionalField(IntField('ifindex', None),
                         lambda pkt: pkt.has_ifindex == 1),
        ConditionalField(ShortField('afi', None),
                         lambda pkt: pkt.has_ipaddr == 1),
        ConditionalField(ShortField('reserved2', 0),
                         lambda pkt: pkt.has_ipaddr == 1),
        ConditionalField(IPField('ip4', None), lambda pkt: pkt.afi == 1),
        ConditionalField(IP6Field('ip6', None), lambda pkt: pkt.afi == 2),
        ConditionalField(
            FieldLenField('ifname_len', None, fmt='B', length_of='ifname'),
            lambda pkt: pkt.has_ifname == 1),
        ConditionalField(
            StrLenField('ifname', None,
                        length_from=lambda pkt: pkt.ifname_len),
            lambda pkt: pkt.has_ifname == 1),
        ConditionalField(IntField('mtu', None), lambda pkt: pkt.has_mtu == 1)
    ]

    def self_build(self, field_pos_list=None):
        if self.afi is None:
            if self.ip4 is not None:
                self.afi = 1
            elif self.ip6 is not None:
                self.afi = 2

        if self.has_ifindex and self.ifindex is None:
            warning('has_ifindex set but ifindex is not set.')
        if self.has_ipaddr and self.afi is None:
            warning('has_ipaddr set but afi is not set.')
        if self.has_ipaddr and self.ip4 is None and self.ip6 is None:
            warning('has_ipaddr set but ip4 or ip6 is not set.')
        if self.has_ifname and self.ifname is None:
            warning('has_ifname set but ifname is not set.')
        if self.has_mtu and self.mtu is None:
            warning('has_mtu set but mtu is not set.')

        return ICMPExtensionObject.self_build(
            self, field_pos_list=field_pos_list)  # noqa: E501
Esempio n. 28
0
class SAPRFC(Packet):
    """SAP Remote Function Call packet

    This packet is used for the Remote Function Call (RFC) protocol.
    """
    name = "SAP Remote Function Call"
    fields_desc = [
        ByteField(
            "version", 3
        ),  # If the version is 3, the packet has a size > 88h, versions 1 and 2 are 40h
        ByteEnumKeysField("req_type", 0, rfc_req_type_values),

        # Normal client fields (GW_NORMAL_CLIENT)
        ConditionalField(IPField("address", "0.0.0.0"),
                         lambda pkt: pkt.req_type == 0x03),
        ConditionalField(IntField("padd1", 0),
                         lambda pkt: pkt.req_type == 0x03),
        ConditionalField(StrFixedLenPaddedField("service", "", length=10),
                         lambda pkt: pkt.req_type == 0x03),
        ConditionalField(StrFixedLenField("codepage", "1100", length=4),
                         lambda pkt: pkt.req_type == 0x03),
        ConditionalField(StrFixedLenField("padd2", "\x00" * 6, length=6),
                         lambda pkt: pkt.req_type == 0x03),
        ConditionalField(StrFixedLenPaddedField("lu", "", length=8),
                         lambda pkt: pkt.req_type == 0x03),
        ConditionalField(StrFixedLenPaddedField("tp", "", length=8),
                         lambda pkt: pkt.req_type == 0x03),
        ConditionalField(
            StrFixedLenPaddedField("conversation_id", "", length=8),
            lambda pkt: pkt.req_type == 0x03),
        ConditionalField(ByteField("appc_header_version", 6),
                         lambda pkt: pkt.req_type == 0x03),
        ConditionalField(ByteField("accept_info", 0xcb),
                         lambda pkt: pkt.req_type == 0x03),
        ConditionalField(SignedShortField("idx", -1),
                         lambda pkt: pkt.req_type == 0x03),
        ConditionalField(
            IP6Field("address6", "::"),
            lambda pkt: pkt.req_type == 0x03 and pkt.version == 3),
        ConditionalField(IntField("rc", 0), lambda pkt: pkt.req_type == 0x03),
        ConditionalField(ByteField("echo_data", 0),
                         lambda pkt: pkt.req_type == 0x03),
        ConditionalField(ByteField("filler", 0),
                         lambda pkt: pkt.req_type == 0x03),

        # Monitor Command fields (GW_SEND_CMD)
        ConditionalField(ByteEnumKeysField("cmd", 0, rfc_monitor_cmd_values),
                         lambda pkt: pkt.req_type == 0x09),
    ]
Esempio n. 29
0
class PWOSPF_Hello(Packet):
    """
    HELLO Packet Format

    Hello packets are PWOSPF packet type 1.  These packets are sent periodically
    on all interfaces in order to establish and maintain neighbor relationships.
    In addition, Hellos broadcast enabling dynamic discovery of neighboring
    routers.

    All routers connected to a common network must agree on certain parameters
    (network mask and helloint).  These parameters are included in Hello packets,
    so that differences can inhibit the forming of neighbor relationships.  A
    full HELLO packet with PWOSPF header is as follows:

        0                   1                   2                   3
        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |   Version #   |       1       |         Packet length         |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |                          Router ID                            |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |                           Area ID                             |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |           Checksum            |             Autype            |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |                       Authentication                          |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |                       Authentication                          |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |                        Network Mask                           |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |         HelloInt              |           padding             |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

    Network mask
        The network mask associated with this interface.  For example, if
        the interface is to a class B network whose third byte is used for
        subnetting, the network mask is 0xffffff00.

    HelloInt
        The number of seconds between this router's Hello packets.
    """
    name = "PWOSPF Hello"

    fields_desc = [
        IPField('netmask', '255.255.255.0'),
        ShortField('helloint', 10),
        ShortField('padding', 0)
    ]
Esempio n. 30
0
class IpHostConfigData(EntityClass):
    class_id = 134
    attributes = [
        ECA(ShortField("managed_entity_id", None), {AA.R}),
        ECA(BitField("ip_options", 0, size=8), {AA.R, AA.W}),
        ECA(MACField("mac_address", None), {AA.R}),
        ECA(StrFixedLenField("onu_identifier", None, 25), {AA.R, AA.W}),
        ECA(IPField("ip_address", None), {AA.R, AA.W}),
        ECA(IPField("mask", None), {AA.R, AA.W}),
        ECA(IPField("gateway", None), {AA.R, AA.W}),
        ECA(IPField("primary_dns", None), {AA.R, AA.W}),
        ECA(IPField("secondary_dns", None), {AA.R, AA.W}),
        ECA(IPField("current_address", None), {AA.R}, avc=True),
        ECA(IPField("current_mask", None), {AA.R}, avc=True),
        ECA(IPField("current_gateway", None), {AA.R}, avc=True),
        ECA(IPField("current_primary_dns", None), {AA.R}, avc=True),
        ECA(IPField("current_secondary_dns", None), {AA.R}, avc=True),
        ECA(StrFixedLenField("domain_name", None, 25), {AA.R}, avc=True),
        ECA(StrFixedLenField("host_name", None, 25), {AA.R}, avc=True),
        ECA(ShortField("relay_agent_options", None), {AA.R, AA.W},
            optional=True),
    ]
    mandatory_operations = {OP.Get, OP.Set, OP.Test}
    notifications = {OP.AttributeValueChange}
Esempio n. 31
0
 def h2i(self, pkt, x):
     return IPField.h2i(self, pkt, x)
Esempio n. 32
0
 def randval(self):
     return IPField.randval(self)