summaryrefslogtreecommitdiff
path: root/include/libnet/libnet-headers.h
diff options
context:
space:
mode:
authorValery Ivanov <ivalery111@gmail.com>2023-04-16 20:46:29 +0300
committerValery Ivanov <ivalery111@gmail.com>2023-05-03 22:01:02 +0300
commit4b3af3b99e5ccb82a66f5f961cc603ed16e7cb87 (patch)
tree812bbf7f2eb20c04a0ed834692f69581b8ef0e00 /include/libnet/libnet-headers.h
parentb19e727ab52d4cd1c54f725c7d30e0c3db669c36 (diff)
downloadlibnet-4b3af3b99e5ccb82a66f5f961cc603ed16e7cb87.tar.gz
udld: initial support
Summary of changes: - Complete UDLD protocol support was added according to RFC5171 - UDLD checksum implementation was added - UDLD unit tests were added - CI has been updated to run UDLD unit tests That's how sample/udld looks in tcpdump: tcpdump: listening on lo0, link-type EN10MB (Ethernet), capture size 262144 bytes 06:23:33.536964 UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x03), length 60 Checksum 0x6d85 (unverified) Device-ID TLV (0x0001) TLV, length 15, FOC1031Z7JG Port-ID TLV (0x0002) TLV, length 9, Gi0/1 Echo TLV (0x0003) TLV, length 8, ^@^@^@^@ Message Interval TLV (0x0004) TLV, length 5, 7s Timeout Interval TLV (0x0005) TLV, length 5, 5s Device Name TLV (0x0006) TLV, length 6, S1 Sequence Number TLV (0x0007) TLV, length 8, 1 0x0000: 2103 6d85 0001 000f 464f 4331 3033 315a !.m.....FOC1031Z 0x0010: 374a 4700 0200 0947 6930 2f31 0003 0008 7JG....Gi0/1.... 0x0020: 0000 0000 0004 0005 0700 0500 0505 0006 ................ 0x0030: 0006 5331 0007 0008 0000 0001 ..S1........ Signed-off-by: Valery Ivanov <ivalery111@gmail.com>
Diffstat (limited to 'include/libnet/libnet-headers.h')
-rw-r--r--include/libnet/libnet-headers.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/include/libnet/libnet-headers.h b/include/libnet/libnet-headers.h
index afbb5c3..01194c9 100644
--- a/include/libnet/libnet-headers.h
+++ b/include/libnet/libnet-headers.h
@@ -107,6 +107,7 @@
#define LIBNET_SEBEK_H 0x30 /* sebek header: 48 bytes */
#define LIBNET_STP_CONF_H 0x23 /**< STP conf header: 35 bytes */
#define LIBNET_STP_TCN_H 0x04 /**< STP tcn header: 4 bytes */
+#define LIBNET_UDLD_H 0x04 /**< UDLD header: 4 bytes */
#define LIBNET_TOKEN_RING_H 0x16 /**< Token Ring header: 22 bytes */
#define LIBNET_TCP_H 0x14 /**< TCP header: 20 bytes */
#define LIBNET_UDP_H 0x08 /**< UDP header: 8 bytes */
@@ -1734,6 +1735,64 @@ struct libnet_stp_tcn_hdr
uint8_t stp_bpdu_type; /* bridge protocol data unit type */
};
+/*
+ * UDLD header
+ * UniDirectional Link Detection
+ * Base header size: 4 bytes
+*/
+struct libnet_udld_hdr
+{
+ /* LLC Info */
+#define LIBNET_UDLD_DEST_MAC {0x01, 0x00, 0x0C, 0xCC, 0xCC, 0xCC}
+
+ /* UDLD SNAP Format */
+#define LIBNET_UDLD_LLC_DSAP 0xAA
+#define LIBNET_UDLD_LLC_SSAP 0xAA
+#define LIBNET_UDLD_LLC_CONTROL 0x03
+#define LIBNET_UDLD_OID {0x00, 0x00, 0x0C}
+#define LIBNET_UDLD_HDLC_PROTO_TYPE 0x0111
+
+ /* Protocol Data Unit (PDU) Format */
+ uint8_t version_opcode;
+#define LIBNET_UDLD_PDU_VERSION 0x01
+#define LIBNET_UDLD_PDU_VERSION_OFFSET (5)
+
+#define LIBNET_UDLD_PDU_OPCODE_RESERVED 0x00 /* Reserved opcode message */
+#define LIBNET_UDLD_PDU_OPCODE_PROBE 0x01 /* Probe opcode message */
+#define LIBNET_UDLD_PDU_OPCODE_ECHO 0x02 /* Echo opcode message */
+#define LIBNET_UDLD_PDU_OPCODE_FLUSH 0x03 /* Flush opcode message */
+#define LIBNET_UDLD_PDU_OPCODE_RESERVED_FUTURE 0x04 /* Reserved for future use 0x04-0x1F */
+#define LIBNET_UDLD_PDU_OPCODE_MASK 0x1F
+
+ uint8_t flags;
+#define LIBNET_UDLD_FLAG_RT 0x01 /* Bit 0 : Recommended timeout flag (RT) */
+#define LIBNET_UDLD_FLAG_RSY 0x02 /* Bit 1 : ReSynch flag (RSY) */
+#define LIBNET_UDLD_FLAG_RESERVED 0x03 /* Bit 2-7: Reserved for future use */
+
+ uint16_t checksum; /* IP-like checksum */
+#define LIBNET_PROTO_UDLD 202
+
+ /* TLVs */
+#define LIBNET_UDLD_TLV_HDR_SIZE 0x04 /* UDLD TLV's header size 4 bytes */
+
+ uint16_t tlv__type;
+#define LIBNET_UDLD_DEVICE_ID 0x0001 /* Value format: ASCII character string */
+#define LIBNET_UDLD_PORT_ID 0x0002 /* Value format: ASCII character string */
+#define LIBNET_UDLD_ECHO 0x0003 /* Value format: List of ID pairs */
+#define LIBNET_UDLD_MESSAGE_INTERVAL 0x0004 /* Value format: 8-bit unsigned integer */
+#define LIBNET_UDLD_TIMEOUT_INTERVAL 0x0005 /* Value format: 8-bit unsigned integer */
+#define LIBNET_UDLD_DEVICE_NAME 0x0006 /* Value format: ASCII character string */
+#define LIBNET_UDLD_SEQUENCE_NUMBER 0x0007 /* Value format: 32-bit unsigned integer */
+/* Reserved TLVs >0x0007 Value format: To be skipped by parsing routine */
+
+ uint16_t tlv__length;
+
+ /* TLV value types */
+#define LIBNET_UDLD_VALUE_TYPE_ASCII (0)
+#define LIBNET_UDLD_VALUE_TYPE_ID_PAIRS (1)
+#define LIBNET_UDLD_VALUE_TYPE_8_BIT_UINT (2)
+#define LIBNET_UDLD_VALUE_TYPE_32_BIT_UINT (3)
+};
/*
* TCP header