Annotation of embedaddon/mtr/packet/protocols.h, revision 1.1
1.1 ! misho 1: /*
! 2: mtr -- a network diagnostic tool
! 3: Copyright (C) 2016 Matt Kimball
! 4:
! 5: This program is free software; you can redistribute it and/or modify
! 6: it under the terms of the GNU General Public License version 2 as
! 7: published by the Free Software Foundation.
! 8:
! 9: This program is distributed in the hope that it will be useful,
! 10: but WITHOUT ANY WARRANTY; without even the implied warranty of
! 11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! 12: GNU General Public License for more details.
! 13:
! 14: You should have received a copy of the GNU General Public License
! 15: along with this program; if not, write to the Free Software
! 16: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
! 17: */
! 18:
! 19: #ifndef PROTOCOLS_H
! 20: #define PROTOCOLS_H
! 21:
! 22: /* ICMPv4 type codes */
! 23: #define ICMP_ECHOREPLY 0
! 24: #define ICMP_DEST_UNREACH 3
! 25: #define ICMP_ECHO 8
! 26: #define ICMP_TIME_EXCEEDED 11
! 27:
! 28: /* ICMP_DEST_UNREACH codes */
! 29: #define ICMP_PORT_UNREACH 3
! 30:
! 31: /* ICMPv6 type codes */
! 32: #define ICMP6_DEST_UNREACH 1
! 33: #define ICMP6_TIME_EXCEEDED 3
! 34: #define ICMP6_ECHO 128
! 35: #define ICMP6_ECHOREPLY 129
! 36:
! 37: /* ICMP6_DEST_UNREACH codes */
! 38: #define ICMP6_PORT_UNREACH 4
! 39:
! 40: /*
! 41: The minimum size of the ICMP "original datagram" when
! 42: using ICMP extensions
! 43: */
! 44: #define ICMP_ORIGINAL_DATAGRAM_MIN_SIZE 128
! 45:
! 46: /* The classnum and type of MPLS labels in an ICMP extension object */
! 47: #define ICMP_EXT_MPLS_CLASSNUM 1
! 48: #define ICMP_EXT_MPLS_CTYPE 1
! 49:
! 50: #define HTTP_PORT 80
! 51:
! 52: /* We can't rely on header files to provide this information, because
! 53: the fields have different names between, for instance, Linux and
! 54: Solaris */
! 55: struct ICMPHeader {
! 56: uint8_t type;
! 57: uint8_t code;
! 58: uint16_t checksum;
! 59: uint16_t id;
! 60: uint16_t sequence;
! 61: };
! 62:
! 63: /* ICMP extension header, which might contain MPLS labels */
! 64: /* See RFC 4884 */
! 65: struct ICMPExtensionHeader {
! 66: uint8_t version;
! 67: uint8_t reserved;
! 68: uint16_t checksum;
! 69: };
! 70:
! 71: /* An object in an extended ICMP object */
! 72: struct ICMPExtensionObject {
! 73: uint16_t len;
! 74: uint8_t classnum;
! 75: uint8_t ctype;
! 76: };
! 77:
! 78: /* An MPLS label included in an ICMP extension */
! 79: /* See RFC 4950 */
! 80: struct ICMPExtMPLSLabel {
! 81: uint8_t label[3]; // Low 4 bits are Experimental Use, Stack
! 82: uint8_t ttl;
! 83: };
! 84:
! 85: /* Structure of an UDP header. */
! 86: struct UDPHeader {
! 87: uint16_t srcport;
! 88: uint16_t dstport;
! 89: uint16_t length;
! 90: uint16_t checksum;
! 91: };
! 92:
! 93: /* Structure of an TCP header, as far as we need it. */
! 94: struct TCPHeader {
! 95: uint16_t srcport;
! 96: uint16_t dstport;
! 97: uint32_t seq;
! 98: };
! 99:
! 100: /* Structure of an SCTP header */
! 101: struct SCTPHeader {
! 102: uint16_t srcport;
! 103: uint16_t dstport;
! 104: uint32_t veri_tag;
! 105: };
! 106:
! 107: /* Structure of an IPv4 UDP pseudoheader. */
! 108: struct UDPPseudoHeader {
! 109: uint32_t saddr;
! 110: uint32_t daddr;
! 111: uint8_t zero;
! 112: uint8_t protocol;
! 113: uint16_t len;
! 114: };
! 115:
! 116: /* Structure of an IP header. */
! 117: struct IPHeader {
! 118: uint8_t version;
! 119: uint8_t tos;
! 120: uint16_t len;
! 121: uint16_t id;
! 122: uint16_t frag;
! 123: uint8_t ttl;
! 124: uint8_t protocol;
! 125: uint16_t check;
! 126: uint32_t saddr;
! 127: uint32_t daddr;
! 128: };
! 129:
! 130: /* IP version 6 header */
! 131: struct IP6Header {
! 132: uint8_t version;
! 133: uint8_t flow[3];
! 134: uint16_t len;
! 135: uint8_t protocol;
! 136: uint8_t ttl;
! 137: uint8_t saddr[16];
! 138: uint8_t daddr[16];
! 139: };
! 140:
! 141: /* The pseudo-header used for checksum computation for ICMPv6 and UDPv6 */
! 142: struct IP6PseudoHeader {
! 143: uint8_t saddr[16];
! 144: uint8_t daddr[16];
! 145: uint32_t len;
! 146: uint8_t zero[3];
! 147: uint8_t protocol;
! 148: };
! 149:
! 150: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>