#ifndef IP_HPP
#define IP_HPP
#include <netinet/ip.h>
#include <iostream>
#include <string>
#include "tcp.hpp"
#include "udp.hpp"
#include <arpa/inet.h>
#include "ipaddress.hpp"
/*
struct ip
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int ip_hl:4; // header length
unsigned int ip_v:4; // version
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned int ip_v:4; // version
unsigned int ip_hl:4; // header length
#endif
u_int8_t ip_tos; // type of service
u_short ip_len; // total length
u_short ip_id; // identification
u_short ip_off; // fragment offset field
#define IP_RF 0x8000 // reserved fragment flag
#define IP_DF 0x4000 // dont fragment flag
#define IP_MF 0x2000 // more fragments flag
#define IP_OFFMASK 0x1fff // mask for fragmenting bits
u_int8_t ip_ttl; // time to live
u_int8_t ip_p; // protocol
u_short ip_sum; // checksum
struct in_addr ip_src, ip_dst; // source and dest address
};
PROTOCOL NUMBERS
(last updated 08 September 2005)
In the Internet Protocol version 4 (IPv4) [RFC791] there is a field,
called "Protocol", to identify the next level protocol. This is an 8
bit field. In Internet Protocol version 6 (IPv6) [RFC1883] this field
is called the "Next Header" field.
Assigned Internet Protocol Numbers
Decimal Keyword Protocol References
------- ------- -------- ----------
0 HOPOPT IPv6 Hop-by-Hop Option [RFC1883]
1 ICMP Internet Control Message [RFC792]
2 IGMP Internet Group Management [RFC1112]
3 GGP Gateway-to-Gateway [RFC823]
4 IP IP in IP (encapsulation) [RFC2003]
5 ST Stream [RFC1190,RFC1819]
6 TCP Transmission Control [RFC793]
7 CBT CBT [Ballardie]
8 EGP Exterior Gateway Protocol [RFC888,DLM1]
9 IGP any private interior gateway [IANA]
(used by Cisco for their IGRP)
10 BBN-RCC-MON BBN RCC Monitoring [SGC]
11 NVP-II Network Voice Protocol [RFC741,SC3]
12 PUP PUP [PUP,XEROX]
13 ARGUS ARGUS [RWS4]
14 EMCON EMCON [BN7]
15 XNET Cross Net Debugger [IEN158,JFH2]
16 CHAOS Chaos [NC3]
17 UDP User Datagram [RFC768,JBP]
18 MUX Multiplexing [IEN90,JBP]
19 DCN-MEAS DCN Measurement Subsystems [DLM1]
20 HMP Host Monitoring [RFC869,RH6]
21 PRM Packet Radio Measurement [ZSU]
22 XNS-IDP XEROX NS IDP [ETHERNET,XEROX]
23 TRUNK-1 Trunk-1 [BWB6]
24 TRUNK-2 Trunk-2 [BWB6]
25 LEAF-1 Leaf-1 [BWB6]
26 LEAF-2 Leaf-2 [BWB6]
27 RDP Reliable Data Protocol [RFC908,RH6]
28 IRTP Internet Reliable Transaction [RFC938,TXM]
29 ISO-TP4 ISO Transport Protocol Class 4 [RFC905,RC77]
30 NETBLT Bulk Data Transfer Protocol [RFC969,DDC1]
31 MFE-NSP MFE Network Services Protocol [MFENET,BCH2]
32 MERIT-INP MERIT Internodal Protocol [HWB]
33 DCCP Datagram Congestion Control Protocol [RFC-ietf-dccp-spec-11.txt]
34 3PC Third Party Connect Protocol [SAF3]
35 IDPR Inter-Domain Policy Routing Protocol [MXS1]
36 XTP XTP [GXC]
37 DDP Datagram Delivery Protocol [WXC]
38 IDPR-CMTP IDPR Control Message Transport Proto [MXS1]
39 TP++ TP++ Transport Protocol [DXF]
40 IL IL Transport Protocol [Presotto]
41 IPv6 Ipv6 [Deering]
42 SDRP Source Demand Routing Protocol [DXE1]
43 IPv6-Route Routing Header for IPv6 [Deering]
44 IPv6-Frag Fragment Header for IPv6 [Deering]
45 IDRP Inter-Domain Routing Protocol [Sue Hares]
46 RSVP Reservation Protocol [Bob Braden]
47 GRE General Routing Encapsulation [Tony Li]
48 MHRP Mobile Host Routing Protocol[David Johnson]
49 BNA BNA [Gary Salamon]
50 ESP Encap Security Payload [RFC2406]
51 AH Authentication Header [RFC2402]
52 I-NLSP Integrated Net Layer Security TUBA [GLENN]
53 SWIPE IP with Encryption [JI6]
54 NARP NBMA Address Resolution Protocol [RFC1735]
55 MOBILE IP Mobility [Perkins]
56 TLSP Transport Layer Security Protocol [Oberg]
using Kryptonet key management
57 SKIP SKIP [Markson]
58 IPv6-ICMP ICMP for IPv6 [RFC1883]
59 IPv6-NoNxt No Next Header for IPv6 [RFC1883]
60 IPv6-Opts Destination Options for IPv6 [RFC1883]
61 any host internal protocol [IANA]
62 CFTP CFTP [CFTP,HCF2]
63 any local network [IANA]
64 SAT-EXPAK SATNET and Backroom EXPAK [SHB]
65 KRYPTOLAN Kryptolan [PXL1]
66 RVD MIT Remote Virtual Disk Protocol [MBG]
67 IPPC Internet Pluribus Packet Core [SHB]
68 any distributed file system [IANA]
69 SAT-MON SATNET Monitoring [SHB]
70 VISA VISA Protocol [GXT1]
71 IPCV Internet Packet Core Utility [SHB]
72 CPNX Computer Protocol Network Executive [DXM2]
73 CPHB Computer Protocol Heart Beat [DXM2]
74 WSN Wang Span Network [VXD]
75 PVP Packet Video Protocol [SC3]
76 BR-SAT-MON Backroom SATNET Monitoring [SHB]
77 SUN-ND SUN ND PROTOCOL-Temporary [WM3]
78 WB-MON WIDEBAND Monitoring [SHB]
79 WB-EXPAK WIDEBAND EXPAK [SHB]
80 ISO-IP ISO Internet Protocol [MTR]
81 VMTP VMTP [DRC3]
82 SECURE-VMTP SECURE-VMTP [DRC3]
83 VINES VINES [BXH]
84 TTP TTP [JXS]
85 NSFNET-IGP NSFNET-IGP [HWB]
86 DGP Dissimilar Gateway Protocol [DGP,ML109]
87 TCF TCF [GAL5]
88 EIGRP EIGRP [CISCO,GXS]
89 OSPFIGP OSPFIGP [RFC1583,JTM4]
90 Sprite-RPC Sprite RPC Protocol [SPRITE,BXW]
91 LARP Locus Address Resolution Protocol [BXH]
92 MTP Multicast Transport Protocol [SXA]
93 AX.25 AX.25 Frames [BK29]
94 IPIP IP-within-IP Encapsulation Protocol [JI6]
95 MICP Mobile Internetworking Control Pro. [JI6]
96 SCC-SP Semaphore Communications Sec. Pro. [HXH]
97 ETHERIP Ethernet-within-IP Encapsulation [RFC3378]
98 ENCAP Encapsulation Header [RFC1241,RXB3]
99 any private encryption scheme [IANA]
100 GMTP GMTP [RXB5]
101 IFMP Ipsilon Flow Management Protocol [Hinden]
102 PNNI PNNI over IP [Callon]
103 PIM Protocol Independent Multicast [Farinacci]
104 ARIS ARIS [Feldman]
105 SCPS SCPS [Durst]
106 QNX QNX [Hunter]
107 A/N Active Networks [Braden]
108 IPComp IP Payload Compression Protocol [RFC2393]
109 SNP Sitara Networks Protocol [Sridhar]
110 Compaq-Peer Compaq Peer Protocol [Volpe]
111 IPX-in-IP IPX in IP [Lee]
112 VRRP Virtual Router Redundancy Protocol [RFC3768]
113 PGM PGM Reliable Transport Protocol [Speakman]
114 any 0-hop protocol [IANA]
115 L2TP Layer Two Tunneling Protocol [Aboba]
116 DDX D-II Data Exchange (DDX) [Worley]
117 IATP Interactive Agent Transfer Protocol [Murphy]
118 STP Schedule Transfer Protocol [JMP]
119 SRP SpectraLink Radio Protocol [Hamilton]
120 UTI UTI [Lothberg]
121 SMP Simple Message Protocol [Ekblad]
122 SM SM [Crowcroft]
123 PTP Performance Transparency Protocol [Welzl]
124 ISIS over IPv4 [Przygienda]
125 FIRE [Partridge]
126 CRTP Combat Radio Transport Protocol [Sautter]
127 CRUDP Combat Radio User Datagram [Sautter]
128 SSCOPMCE [Waber]
129 IPLT [Hollbach]
130 SPS Secure Packet Shield [McIntosh]
131 PIPE Private IP Encapsulation within IP [Petri]
132 SCTP Stream Control Transmission Protocol [Stewart]
133 FC Fibre Channel [Rajagopal]
134 RSVP-E2E-IGNORE [RFC3175]
135 Mobility Header [RFC3775]
136 UDPLite [RFC3828]
137 MPLS-in-IP [RFC4023]
138-252 Unassigned [IANA]
253 Use for experimentation and testing [RFC3692]
254 Use for experimentation and testing [RFC3692]
255 Reserved [IANA
*/
static ipaddress::ip_contain ip_pool("QQWry.Dat");
void del_ip(const u_char* ptr_packet, size_t used_len)
{
const ip* ptr_ip = (struct ip*)(ptr_packet+used_len);
std::string protocol;
ipaddress::ip_record record;
std::string src_ip(inet_ntoa(ptr_ip->ip_src));
if (ip_pool.get_record_by(src_ip, record))
{
std::cout<<_("geography address:")<<src_ip<<record.get_country()<<_("--")<<record.get_city();
}
else
{
std::cout<<_("find not geography address")<<src_ip;
}
std::cout<<_("------>");
std::string dest_ip(inet_ntoa(ptr_ip->ip_dst));
if (ip_pool.get_record_by(dest_ip, record))
{
std::cout<<_("geography address:")<<dest_ip<<record.get_country()<<"--"<<record.get_city()<<std::endl;
}
else
{
std::cout<<_("find not geography address")<<dest_ip<<std::endl;
}
switch (ptr_ip->ip_p)
{
case 0:
protocol = _("HOPOPT");//IPv6 Hop-by-Hop Option[RFC1883]
break;
case 1:
protocol = _("ICMP");//Internet Control Message[RFC792]
break;
case 2:
protocol = _("IGMP");//Internet Group Management[RFC1112]
break;
case 3:
protocol = _("GGP");//Gateway-to-Gateway[RFC823]
break;
case 4:
protocol = _("IP-in-IP");//IP in IP(encapsulation)[RFC2003]
break;
case 5:
protocol = _("ST");//Stream[RFC1190,RFC1819]
break;
case 6:
protocol = _("TCP");//Transmission Control[RFC793]
del_tcp(ptr_packet, used_len+sizeof(struct ip));
break;
case 7:
protocol = _("CBT");//CBT[Ballardie]
break;
case 8:
protocol = _("EGP");//Exterior Gateway Protocol[RFC888,DLM1]
break;
case 9:
protocol = _("IGP");//any private interior gateway[IANA](used by Cisco for their IGRP)
break;
case 10:
protocol = _("BBN-RCC-MON");//BBN RCC Monitoring[SGC]
break;
case 11:
protocol = _("NVP-II");//Network Voice Protocol[RFC741,SC3]
break;
case 12:
protocol = _("PUP");//PUP[PUP,XEROX]
break;
case 13:
protocol = _("ARGUS");//ARGUS[RWS4]
break;
case 14:
protocol = _("EMCON");//EMCON[BN7]
break;
case 15:
protocol = _("XNET");//Cross Net Debugger[IEN158,JFH2]
break;
case 16:
protocol = _("CHAOS");//Chaos[NC3]
break;
case 17:
protocol = _("UDP");//User Datagram[RFC768,JBP]
del_udp(ptr_packet, sizeof(struct ip)+used_len);
break;
case 18:
protocol = _("MUX");//Multiplexing[IEN90,JBP]
break;
case 19:
protocol = _("DCN-MEAS");//DCN Measurement Subsystems[DLM1]
break;
case 20:
protocol = _("HMP");//Host Monitoring[RFC869,RH6]
break;
case 21:
protocol = _("PRM");//Packet Radio Measurement[ZSU]
break;
case 22:
protocol = _("XNS-IDP");//XEROX NS IDP[ETHERNET,XEROX]
break;
case 23:
protocol = _("TRUNK-1");//Trunk-1[BWB6]
break;
case 24:
protocol = _("TRUNK-2");//Trunk-2[BWB6]
break;
case 25:
protocol = _("LEAF-1");//Leaf-1[BWB6]
break;
case 26:
protocol = _("LEAF-2");//Leaf-2[BWB6]
break;
case 27:
protocol = _("RDP");//Reliable Data Protocol[RFC908,RH6]
break;
case 28:
protocol = _("IRTP");//Internet Reliable Transaction[RFC938,TXM]
break;
case 29:
protocol = _("ISO-TP4");//ISO Transport Protocol Class 4[RFC905,RC77]
break;
case 30:
protocol = _("NETBLT");//Bulk Data Transfer Protocol[RFC969,DDC1]
break;
case 31:
protocol = _("MFE-NSP");//MFE Network Services Protocol[MFENET,BCH2]
break;
case 32:
protocol = _("MERIT-INP");//MERIT Internodal Protocol[HWB]
break;
case 33:
protocol = _("DCCP");//Datagram Congestion Control Protocol[RFC-ietf-dccp-spec-11.txt]
break;
case 34:
protocol = _("3PC");//Third Party Connect Protocol[SAF3]
break;
case 35:
protocol = _("IDPR");//Inter-Domain Policy Routing Protocol[MXS1]
break;
case 36:
protocol = _("XTP");//XTP[GXC]
break;
case 37:
protocol = _("DDP");//Datagram Delivery Protocol[WXC]
break;
case 38:
protocol = _("IDPR-CMTP");//IDPR Control Message Transport Proto [MXS1]
break;
case 39:
protocol = _("TP++");//TP++ Transport Protocol[DXF]
break;
case 40:
protocol = _("IL");//IL Transport Protocol[Presotto]
break;
case 41:
protocol = _("IPv6");//Ipv6[Deering]
break;
case 42:
protocol = _("SDRP");//Source Demand Routing Protocol[DXE1]
break;
case 43:
protocol = _("IPv6-Route");//Routing Header for IPv6[Deering]
break;
case 44:
protocol = _("IPv6-Frag");//Fragment Header for IPv6[Deering]
break;
case 45:
protocol = _("IDRP");//Inter-Domain Routing Protocol[Sue Hares]
break;
case 46:
protocol = _("RSVP");//Reservation Protocol[Bob Braden]
break;
case 47:
protocol = _("GRE");//General Routing Encapsulation[Tony Li]
break;
case 48:
protocol = _("MHRP");//Mobile Host Routing Protocol[David Johnson]
break;
case 49:
protocol = _("BNA");//BNA[Gary Salamon]
break;
case 50:
protocol = _("ESP");//Encap Security Payload[RFC2406]
break;
case 51:
protocol = _("AH");//Authentication Header[RFC2402]
break;
case 52:
protocol = _("I-NLSP");//Integrated Net Layer Security TUBA[GLENN]
break;
case 53:
protocol = _("SWIPE");//IP with Encryption[JI6]
break;
case 54:
protocol = _("NARP");//NBMA Address Resolution Protocol[RFC1735]
break;
case 55:
protocol = _("MOBILE");//IP Mobility[Perkins]
break;
case 56:
protocol = _("TLSP");//Transport Layer Security Protocol[Oberg]using Kryptonet key management
break;
case 57:
protocol = _("SKIP");//SKIP[Markson]
break;
case 58:
protocol = _("IPv6-ICMP");//ICMP for IPv6[RFC1883]
break;
case 59:
protocol = _("IPv6-NoNxt");//No Next Header for IPv6[RFC1883]
break;
case 60:
protocol = _("IPv6-Opts");//Destination Options for IPv6[RFC1883]
break;
case 61:
protocol = _("any-host-internal");//any host internal protocol[IANA]
break;
case 62:
protocol = _("CFTP");//CFTP[CFTP,HCF2]
break;
case 63:
protocol = _("any-local-network");//any local network[IANA]
break;
case 64:
protocol = _("SAT-EXPAK");//SATNET and Backroom EXPAK[SHB]
break;
case 65:
protocol = _("KRYPTOLAN");//Kryptolan[PXL1]
break;
case 66:
protocol = _("RVD");//MIT Remote Virtual Disk Protocol[MBG]
break;
case 67:
protocol = _("IPPC");//Internet Pluribus Packet Core[SHB]
break;
case 68:
protocol = _("any-distributed-fs");//any distributed file system[IANA]
break;
case 69:
protocol = _("SAT-MON");//SATNET Monitoring[SHB]
break;
case 70:
protocol = _("VISA");//VISA Protocol[GXT1]
break;
case 71:
protocol = _("IPCV");//Internet Packet Core Utility[SHB]
break;
case 72:
protocol = _("CPNX");//Computer Protocol Network Executive[DXM2]
break;
case 73:
protocol = _("CPHB");//Computer Protocol Heart Beat[DXM2]
break;
case 74:
protocol = _("WSN");//Wang Span Network[VXD]
break;
case 75:
protocol = _("PVP");//Packet Video Protocol[SC3]
break;
case 76:
protocol = _("BR-SAT-MON");//Backroom SATNET Monitoring[SHB]
break;
case 77:
protocol = _("SUN-ND");//SUN ND PROTOCOL-Temporary[WM3]
break;
case 78:
protocol = _("WB-MON");//WIDEBAND Monitoring[SHB]
break;
case 79:
protocol = _("WB-EXPAK");//WIDEBAND EXPAK[SHB]
break;
case 80:
protocol = _("ISO-IP");//ISO Internet Protocol[MTR]
break;
case 81:
protocol = _("VMTP");//VMTP[DRC3]
break;
case 82:
protocol = _("SECURE-VMTP");//SECURE-VMTP[DRC3]
break;
case 83:
protocol = _("VINES");//VINES[BXH]
break;
case 84:
protocol = _("TTP");//TTP[JXS]
break;
case 85:
protocol = _("NSFNET-IGP");// NSFNET-IGP[HWB]
break;
case 86:
protocol = _("DGP");//Dissimilar Gateway Protocol[DGP,ML109]
break;
case 87:
protocol = _("TCF");//TCF[GAL5]
break;
case 88:
protocol = _("EIGRP");//EIGRP[CISCO,GXS]
break;
case 89:
protocol = _("OSPFIGP");//OSPFIGP[RFC1583,JTM4]
break;
case 90:
protocol = _("Sprite-RPC");//Sprite RPC Protocol[SPRITE,BXW]
break;
case 91:
protocol = _("LARP");//Locus Address Resolution Protocol[BXH]
break;
case 92:
protocol = _("MTP");//Multicast Transport Protocol[SXA]
break;
case 93:
protocol = _("AX.25");//AX.25 Frames[BK29]
break;
case 94:
protocol = _("IPIP");//IP-within-IP Encapsulation Protocol[JI6]
break;
case 95:
protocol = _("MICP");//Mobile Internetworking Control Pro.[JI6]
break;
case 96:
protocol = _("SCC-SP");//Semaphore Communications Sec. Pro.[HXH]
break;
case 97:
protocol = _("ETHERIP");//Ethernet-within-IP Encapsulation[RFC3378]
break;
case 98:
protocol = _("ENCAP");//Encapsulation Header[RFC1241,RXB3]
break;
case 99:
protocol = _("any-private-encypt");//any private encryption scheme[IANA]
break;
case 100:
protocol = _("GMTP");//GMTP[RXB5]
break;
case 101:
protocol = _("IFMP");//Ipsilon Flow Management Protocol[Hinden]
break;
case 102:
protocol = _("PNNI");//PNNI over IP[Callon]
break;
case 103:
protocol = _("PIM");//Protocol Independent Multicast[Farinacci]
break;
case 104:
protocol = _("ARIS");//ARIS[Feldman]
break;
case 105:
protocol = _("SCPS");//SCPS[Durst]
break;
case 106:
protocol = _("QNX");//QNX[Hunter]
break;
case 107:
protocol = _("A/N");//Active Networks[Braden]
break;
case 108:
protocol = _("IPComp");//IP Payload Compression Protocol[RFC2393]
break;
case 109:
protocol = _("SNP");//Sitara Networks Protocol[Sridhar]
break;
case 110:
protocol = _("Compaq-Peer");//Compaq Peer Protocol[Volpe]
break;
case 111:
protocol = _("IPX-in-IP");//IPX in IP[Lee]
break;
case 112:
protocol = _("VRRP");//Virtual Router Redundancy Protocol[RFC3768]
break;
case 113:
protocol = _("PGM");//PGM Reliable Transport Protocol[Speakman]
break;
case 114:
protocol = _("any-0-hop");//any 0-hop protocol[IANA]
break;
case 115:
protocol = _("L2TP");//Layer Two Tunneling Protocol[Aboba]
break;
case 116:
protocol = _("DDX");//D-II Data Exchange (DDX)[Worley]
break;
case 117:
protocol = _("IATP");//Interactive Agent Transfer Protocol[Murphy]
break;
case 118:
protocol = _("STP");//Schedule Transfer Protocol[JMP]
break;
case 119:
protocol = _("SRP");//SpectraLink Radio Protocol[Hamilton]
break;
case 120:
protocol = _("UTI");//UTI[Lothberg]
break;
case 121:
protocol = _("SMP");//Simple Message Protocol[Ekblad]
break;
case 122:
protocol = _("SM");//SM[Crowcroft]
break;
case 123:
protocol = _("PTP");//Performance Transparency Protocol[Welzl]
break;
case 124:
protocol = _("ISIS-over-IPv4");//ISIS over IPv4[Przygienda]
break;
case 125:
protocol = _("FIRE");//FIRE[Partridge]
break;
case 126:
protocol = _("CRTP");//Combat Radio Transport Protocol[Sautter]
break;
case 127:
protocol = _("CRUDP");//Combat Radio User Datagram[Sautter]
break;
case 128:
protocol = _("SSCOPMCE");//SSCOPMCE[Waber]
break;
case 129:
protocol = _("IPLT");//IPLT[Hollbach]
break;
case 130:
protocol = _("SPS");//Secure Packet Shield[McIntosh]
break;
case 131:
protocol = _("PIPE");//Private IP Encapsulation within IP[Petri]
break;
case 132:
protocol = _("SCTP");//Stream Control Transmission Protocol[Stewart]
break;
case 133:
protocol = _("FC");//Fibre Channel[Rajagopal]
break;
case 134:
protocol = _("RSVP-E2E-IGNORE");//RSVP-E2E-IGNORE[RFC3175]
break;
case 135:
protocol = _("Mobility Header");//Mobility Header[RFC3775]
break;
case 136:
protocol = _("UDPLite");//UDPLite[RFC3828]
break;
case 137:
protocol = _("MPLS-in-IP");//MPLS-in-IP[RFC4023]
break;
case 253:
protocol = _("experiment-test");//Use for experimentation and testing[RFC3692]
break;
case 254:
protocol = _("experiment-test");//Use for experimentation and testing[RFC3692]
break;
case 255:
protocol = _("Reserved");
break;
default:
protocol = _("undefined service");//138-252,Unassigned[IANA]
break;
}
}
#endif
#define IP_HPP
#include <netinet/ip.h>
#include <iostream>
#include <string>
#include "tcp.hpp"
#include "udp.hpp"
#include <arpa/inet.h>
#include "ipaddress.hpp"
/*
struct ip
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int ip_hl:4; // header length
unsigned int ip_v:4; // version
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned int ip_v:4; // version
unsigned int ip_hl:4; // header length
#endif
u_int8_t ip_tos; // type of service
u_short ip_len; // total length
u_short ip_id; // identification
u_short ip_off; // fragment offset field
#define IP_RF 0x8000 // reserved fragment flag
#define IP_DF 0x4000 // dont fragment flag
#define IP_MF 0x2000 // more fragments flag
#define IP_OFFMASK 0x1fff // mask for fragmenting bits
u_int8_t ip_ttl; // time to live
u_int8_t ip_p; // protocol
u_short ip_sum; // checksum
struct in_addr ip_src, ip_dst; // source and dest address
};
PROTOCOL NUMBERS
(last updated 08 September 2005)
In the Internet Protocol version 4 (IPv4) [RFC791] there is a field,
called "Protocol", to identify the next level protocol. This is an 8
bit field. In Internet Protocol version 6 (IPv6) [RFC1883] this field
is called the "Next Header" field.
Assigned Internet Protocol Numbers
Decimal Keyword Protocol References
------- ------- -------- ----------
0 HOPOPT IPv6 Hop-by-Hop Option [RFC1883]
1 ICMP Internet Control Message [RFC792]
2 IGMP Internet Group Management [RFC1112]
3 GGP Gateway-to-Gateway [RFC823]
4 IP IP in IP (encapsulation) [RFC2003]
5 ST Stream [RFC1190,RFC1819]
6 TCP Transmission Control [RFC793]
7 CBT CBT [Ballardie]
8 EGP Exterior Gateway Protocol [RFC888,DLM1]
9 IGP any private interior gateway [IANA]
(used by Cisco for their IGRP)
10 BBN-RCC-MON BBN RCC Monitoring [SGC]
11 NVP-II Network Voice Protocol [RFC741,SC3]
12 PUP PUP [PUP,XEROX]
13 ARGUS ARGUS [RWS4]
14 EMCON EMCON [BN7]
15 XNET Cross Net Debugger [IEN158,JFH2]
16 CHAOS Chaos [NC3]
17 UDP User Datagram [RFC768,JBP]
18 MUX Multiplexing [IEN90,JBP]
19 DCN-MEAS DCN Measurement Subsystems [DLM1]
20 HMP Host Monitoring [RFC869,RH6]
21 PRM Packet Radio Measurement [ZSU]
22 XNS-IDP XEROX NS IDP [ETHERNET,XEROX]
23 TRUNK-1 Trunk-1 [BWB6]
24 TRUNK-2 Trunk-2 [BWB6]
25 LEAF-1 Leaf-1 [BWB6]
26 LEAF-2 Leaf-2 [BWB6]
27 RDP Reliable Data Protocol [RFC908,RH6]
28 IRTP Internet Reliable Transaction [RFC938,TXM]
29 ISO-TP4 ISO Transport Protocol Class 4 [RFC905,RC77]
30 NETBLT Bulk Data Transfer Protocol [RFC969,DDC1]
31 MFE-NSP MFE Network Services Protocol [MFENET,BCH2]
32 MERIT-INP MERIT Internodal Protocol [HWB]
33 DCCP Datagram Congestion Control Protocol [RFC-ietf-dccp-spec-11.txt]
34 3PC Third Party Connect Protocol [SAF3]
35 IDPR Inter-Domain Policy Routing Protocol [MXS1]
36 XTP XTP [GXC]
37 DDP Datagram Delivery Protocol [WXC]
38 IDPR-CMTP IDPR Control Message Transport Proto [MXS1]
39 TP++ TP++ Transport Protocol [DXF]
40 IL IL Transport Protocol [Presotto]
41 IPv6 Ipv6 [Deering]
42 SDRP Source Demand Routing Protocol [DXE1]
43 IPv6-Route Routing Header for IPv6 [Deering]
44 IPv6-Frag Fragment Header for IPv6 [Deering]
45 IDRP Inter-Domain Routing Protocol [Sue Hares]
46 RSVP Reservation Protocol [Bob Braden]
47 GRE General Routing Encapsulation [Tony Li]
48 MHRP Mobile Host Routing Protocol[David Johnson]
49 BNA BNA [Gary Salamon]
50 ESP Encap Security Payload [RFC2406]
51 AH Authentication Header [RFC2402]
52 I-NLSP Integrated Net Layer Security TUBA [GLENN]
53 SWIPE IP with Encryption [JI6]
54 NARP NBMA Address Resolution Protocol [RFC1735]
55 MOBILE IP Mobility [Perkins]
56 TLSP Transport Layer Security Protocol [Oberg]
using Kryptonet key management
57 SKIP SKIP [Markson]
58 IPv6-ICMP ICMP for IPv6 [RFC1883]
59 IPv6-NoNxt No Next Header for IPv6 [RFC1883]
60 IPv6-Opts Destination Options for IPv6 [RFC1883]
61 any host internal protocol [IANA]
62 CFTP CFTP [CFTP,HCF2]
63 any local network [IANA]
64 SAT-EXPAK SATNET and Backroom EXPAK [SHB]
65 KRYPTOLAN Kryptolan [PXL1]
66 RVD MIT Remote Virtual Disk Protocol [MBG]
67 IPPC Internet Pluribus Packet Core [SHB]
68 any distributed file system [IANA]
69 SAT-MON SATNET Monitoring [SHB]
70 VISA VISA Protocol [GXT1]
71 IPCV Internet Packet Core Utility [SHB]
72 CPNX Computer Protocol Network Executive [DXM2]
73 CPHB Computer Protocol Heart Beat [DXM2]
74 WSN Wang Span Network [VXD]
75 PVP Packet Video Protocol [SC3]
76 BR-SAT-MON Backroom SATNET Monitoring [SHB]
77 SUN-ND SUN ND PROTOCOL-Temporary [WM3]
78 WB-MON WIDEBAND Monitoring [SHB]
79 WB-EXPAK WIDEBAND EXPAK [SHB]
80 ISO-IP ISO Internet Protocol [MTR]
81 VMTP VMTP [DRC3]
82 SECURE-VMTP SECURE-VMTP [DRC3]
83 VINES VINES [BXH]
84 TTP TTP [JXS]
85 NSFNET-IGP NSFNET-IGP [HWB]
86 DGP Dissimilar Gateway Protocol [DGP,ML109]
87 TCF TCF [GAL5]
88 EIGRP EIGRP [CISCO,GXS]
89 OSPFIGP OSPFIGP [RFC1583,JTM4]
90 Sprite-RPC Sprite RPC Protocol [SPRITE,BXW]
91 LARP Locus Address Resolution Protocol [BXH]
92 MTP Multicast Transport Protocol [SXA]
93 AX.25 AX.25 Frames [BK29]
94 IPIP IP-within-IP Encapsulation Protocol [JI6]
95 MICP Mobile Internetworking Control Pro. [JI6]
96 SCC-SP Semaphore Communications Sec. Pro. [HXH]
97 ETHERIP Ethernet-within-IP Encapsulation [RFC3378]
98 ENCAP Encapsulation Header [RFC1241,RXB3]
99 any private encryption scheme [IANA]
100 GMTP GMTP [RXB5]
101 IFMP Ipsilon Flow Management Protocol [Hinden]
102 PNNI PNNI over IP [Callon]
103 PIM Protocol Independent Multicast [Farinacci]
104 ARIS ARIS [Feldman]
105 SCPS SCPS [Durst]
106 QNX QNX [Hunter]
107 A/N Active Networks [Braden]
108 IPComp IP Payload Compression Protocol [RFC2393]
109 SNP Sitara Networks Protocol [Sridhar]
110 Compaq-Peer Compaq Peer Protocol [Volpe]
111 IPX-in-IP IPX in IP [Lee]
112 VRRP Virtual Router Redundancy Protocol [RFC3768]
113 PGM PGM Reliable Transport Protocol [Speakman]
114 any 0-hop protocol [IANA]
115 L2TP Layer Two Tunneling Protocol [Aboba]
116 DDX D-II Data Exchange (DDX) [Worley]
117 IATP Interactive Agent Transfer Protocol [Murphy]
118 STP Schedule Transfer Protocol [JMP]
119 SRP SpectraLink Radio Protocol [Hamilton]
120 UTI UTI [Lothberg]
121 SMP Simple Message Protocol [Ekblad]
122 SM SM [Crowcroft]
123 PTP Performance Transparency Protocol [Welzl]
124 ISIS over IPv4 [Przygienda]
125 FIRE [Partridge]
126 CRTP Combat Radio Transport Protocol [Sautter]
127 CRUDP Combat Radio User Datagram [Sautter]
128 SSCOPMCE [Waber]
129 IPLT [Hollbach]
130 SPS Secure Packet Shield [McIntosh]
131 PIPE Private IP Encapsulation within IP [Petri]
132 SCTP Stream Control Transmission Protocol [Stewart]
133 FC Fibre Channel [Rajagopal]
134 RSVP-E2E-IGNORE [RFC3175]
135 Mobility Header [RFC3775]
136 UDPLite [RFC3828]
137 MPLS-in-IP [RFC4023]
138-252 Unassigned [IANA]
253 Use for experimentation and testing [RFC3692]
254 Use for experimentation and testing [RFC3692]
255 Reserved [IANA
*/
static ipaddress::ip_contain ip_pool("QQWry.Dat");
void del_ip(const u_char* ptr_packet, size_t used_len)
{
const ip* ptr_ip = (struct ip*)(ptr_packet+used_len);
std::string protocol;
ipaddress::ip_record record;
std::string src_ip(inet_ntoa(ptr_ip->ip_src));
if (ip_pool.get_record_by(src_ip, record))
{
std::cout<<_("geography address:")<<src_ip<<record.get_country()<<_("--")<<record.get_city();
}
else
{
std::cout<<_("find not geography address")<<src_ip;
}
std::cout<<_("------>");
std::string dest_ip(inet_ntoa(ptr_ip->ip_dst));
if (ip_pool.get_record_by(dest_ip, record))
{
std::cout<<_("geography address:")<<dest_ip<<record.get_country()<<"--"<<record.get_city()<<std::endl;
}
else
{
std::cout<<_("find not geography address")<<dest_ip<<std::endl;
}
switch (ptr_ip->ip_p)
{
case 0:
protocol = _("HOPOPT");//IPv6 Hop-by-Hop Option[RFC1883]
break;
case 1:
protocol = _("ICMP");//Internet Control Message[RFC792]
break;
case 2:
protocol = _("IGMP");//Internet Group Management[RFC1112]
break;
case 3:
protocol = _("GGP");//Gateway-to-Gateway[RFC823]
break;
case 4:
protocol = _("IP-in-IP");//IP in IP(encapsulation)[RFC2003]
break;
case 5:
protocol = _("ST");//Stream[RFC1190,RFC1819]
break;
case 6:
protocol = _("TCP");//Transmission Control[RFC793]
del_tcp(ptr_packet, used_len+sizeof(struct ip));
break;
case 7:
protocol = _("CBT");//CBT[Ballardie]
break;
case 8:
protocol = _("EGP");//Exterior Gateway Protocol[RFC888,DLM1]
break;
case 9:
protocol = _("IGP");//any private interior gateway[IANA](used by Cisco for their IGRP)
break;
case 10:
protocol = _("BBN-RCC-MON");//BBN RCC Monitoring[SGC]
break;
case 11:
protocol = _("NVP-II");//Network Voice Protocol[RFC741,SC3]
break;
case 12:
protocol = _("PUP");//PUP[PUP,XEROX]
break;
case 13:
protocol = _("ARGUS");//ARGUS[RWS4]
break;
case 14:
protocol = _("EMCON");//EMCON[BN7]
break;
case 15:
protocol = _("XNET");//Cross Net Debugger[IEN158,JFH2]
break;
case 16:
protocol = _("CHAOS");//Chaos[NC3]
break;
case 17:
protocol = _("UDP");//User Datagram[RFC768,JBP]
del_udp(ptr_packet, sizeof(struct ip)+used_len);
break;
case 18:
protocol = _("MUX");//Multiplexing[IEN90,JBP]
break;
case 19:
protocol = _("DCN-MEAS");//DCN Measurement Subsystems[DLM1]
break;
case 20:
protocol = _("HMP");//Host Monitoring[RFC869,RH6]
break;
case 21:
protocol = _("PRM");//Packet Radio Measurement[ZSU]
break;
case 22:
protocol = _("XNS-IDP");//XEROX NS IDP[ETHERNET,XEROX]
break;
case 23:
protocol = _("TRUNK-1");//Trunk-1[BWB6]
break;
case 24:
protocol = _("TRUNK-2");//Trunk-2[BWB6]
break;
case 25:
protocol = _("LEAF-1");//Leaf-1[BWB6]
break;
case 26:
protocol = _("LEAF-2");//Leaf-2[BWB6]
break;
case 27:
protocol = _("RDP");//Reliable Data Protocol[RFC908,RH6]
break;
case 28:
protocol = _("IRTP");//Internet Reliable Transaction[RFC938,TXM]
break;
case 29:
protocol = _("ISO-TP4");//ISO Transport Protocol Class 4[RFC905,RC77]
break;
case 30:
protocol = _("NETBLT");//Bulk Data Transfer Protocol[RFC969,DDC1]
break;
case 31:
protocol = _("MFE-NSP");//MFE Network Services Protocol[MFENET,BCH2]
break;
case 32:
protocol = _("MERIT-INP");//MERIT Internodal Protocol[HWB]
break;
case 33:
protocol = _("DCCP");//Datagram Congestion Control Protocol[RFC-ietf-dccp-spec-11.txt]
break;
case 34:
protocol = _("3PC");//Third Party Connect Protocol[SAF3]
break;
case 35:
protocol = _("IDPR");//Inter-Domain Policy Routing Protocol[MXS1]
break;
case 36:
protocol = _("XTP");//XTP[GXC]
break;
case 37:
protocol = _("DDP");//Datagram Delivery Protocol[WXC]
break;
case 38:
protocol = _("IDPR-CMTP");//IDPR Control Message Transport Proto [MXS1]
break;
case 39:
protocol = _("TP++");//TP++ Transport Protocol[DXF]
break;
case 40:
protocol = _("IL");//IL Transport Protocol[Presotto]
break;
case 41:
protocol = _("IPv6");//Ipv6[Deering]
break;
case 42:
protocol = _("SDRP");//Source Demand Routing Protocol[DXE1]
break;
case 43:
protocol = _("IPv6-Route");//Routing Header for IPv6[Deering]
break;
case 44:
protocol = _("IPv6-Frag");//Fragment Header for IPv6[Deering]
break;
case 45:
protocol = _("IDRP");//Inter-Domain Routing Protocol[Sue Hares]
break;
case 46:
protocol = _("RSVP");//Reservation Protocol[Bob Braden]
break;
case 47:
protocol = _("GRE");//General Routing Encapsulation[Tony Li]
break;
case 48:
protocol = _("MHRP");//Mobile Host Routing Protocol[David Johnson]
break;
case 49:
protocol = _("BNA");//BNA[Gary Salamon]
break;
case 50:
protocol = _("ESP");//Encap Security Payload[RFC2406]
break;
case 51:
protocol = _("AH");//Authentication Header[RFC2402]
break;
case 52:
protocol = _("I-NLSP");//Integrated Net Layer Security TUBA[GLENN]
break;
case 53:
protocol = _("SWIPE");//IP with Encryption[JI6]
break;
case 54:
protocol = _("NARP");//NBMA Address Resolution Protocol[RFC1735]
break;
case 55:
protocol = _("MOBILE");//IP Mobility[Perkins]
break;
case 56:
protocol = _("TLSP");//Transport Layer Security Protocol[Oberg]using Kryptonet key management
break;
case 57:
protocol = _("SKIP");//SKIP[Markson]
break;
case 58:
protocol = _("IPv6-ICMP");//ICMP for IPv6[RFC1883]
break;
case 59:
protocol = _("IPv6-NoNxt");//No Next Header for IPv6[RFC1883]
break;
case 60:
protocol = _("IPv6-Opts");//Destination Options for IPv6[RFC1883]
break;
case 61:
protocol = _("any-host-internal");//any host internal protocol[IANA]
break;
case 62:
protocol = _("CFTP");//CFTP[CFTP,HCF2]
break;
case 63:
protocol = _("any-local-network");//any local network[IANA]
break;
case 64:
protocol = _("SAT-EXPAK");//SATNET and Backroom EXPAK[SHB]
break;
case 65:
protocol = _("KRYPTOLAN");//Kryptolan[PXL1]
break;
case 66:
protocol = _("RVD");//MIT Remote Virtual Disk Protocol[MBG]
break;
case 67:
protocol = _("IPPC");//Internet Pluribus Packet Core[SHB]
break;
case 68:
protocol = _("any-distributed-fs");//any distributed file system[IANA]
break;
case 69:
protocol = _("SAT-MON");//SATNET Monitoring[SHB]
break;
case 70:
protocol = _("VISA");//VISA Protocol[GXT1]
break;
case 71:
protocol = _("IPCV");//Internet Packet Core Utility[SHB]
break;
case 72:
protocol = _("CPNX");//Computer Protocol Network Executive[DXM2]
break;
case 73:
protocol = _("CPHB");//Computer Protocol Heart Beat[DXM2]
break;
case 74:
protocol = _("WSN");//Wang Span Network[VXD]
break;
case 75:
protocol = _("PVP");//Packet Video Protocol[SC3]
break;
case 76:
protocol = _("BR-SAT-MON");//Backroom SATNET Monitoring[SHB]
break;
case 77:
protocol = _("SUN-ND");//SUN ND PROTOCOL-Temporary[WM3]
break;
case 78:
protocol = _("WB-MON");//WIDEBAND Monitoring[SHB]
break;
case 79:
protocol = _("WB-EXPAK");//WIDEBAND EXPAK[SHB]
break;
case 80:
protocol = _("ISO-IP");//ISO Internet Protocol[MTR]
break;
case 81:
protocol = _("VMTP");//VMTP[DRC3]
break;
case 82:
protocol = _("SECURE-VMTP");//SECURE-VMTP[DRC3]
break;
case 83:
protocol = _("VINES");//VINES[BXH]
break;
case 84:
protocol = _("TTP");//TTP[JXS]
break;
case 85:
protocol = _("NSFNET-IGP");// NSFNET-IGP[HWB]
break;
case 86:
protocol = _("DGP");//Dissimilar Gateway Protocol[DGP,ML109]
break;
case 87:
protocol = _("TCF");//TCF[GAL5]
break;
case 88:
protocol = _("EIGRP");//EIGRP[CISCO,GXS]
break;
case 89:
protocol = _("OSPFIGP");//OSPFIGP[RFC1583,JTM4]
break;
case 90:
protocol = _("Sprite-RPC");//Sprite RPC Protocol[SPRITE,BXW]
break;
case 91:
protocol = _("LARP");//Locus Address Resolution Protocol[BXH]
break;
case 92:
protocol = _("MTP");//Multicast Transport Protocol[SXA]
break;
case 93:
protocol = _("AX.25");//AX.25 Frames[BK29]
break;
case 94:
protocol = _("IPIP");//IP-within-IP Encapsulation Protocol[JI6]
break;
case 95:
protocol = _("MICP");//Mobile Internetworking Control Pro.[JI6]
break;
case 96:
protocol = _("SCC-SP");//Semaphore Communications Sec. Pro.[HXH]
break;
case 97:
protocol = _("ETHERIP");//Ethernet-within-IP Encapsulation[RFC3378]
break;
case 98:
protocol = _("ENCAP");//Encapsulation Header[RFC1241,RXB3]
break;
case 99:
protocol = _("any-private-encypt");//any private encryption scheme[IANA]
break;
case 100:
protocol = _("GMTP");//GMTP[RXB5]
break;
case 101:
protocol = _("IFMP");//Ipsilon Flow Management Protocol[Hinden]
break;
case 102:
protocol = _("PNNI");//PNNI over IP[Callon]
break;
case 103:
protocol = _("PIM");//Protocol Independent Multicast[Farinacci]
break;
case 104:
protocol = _("ARIS");//ARIS[Feldman]
break;
case 105:
protocol = _("SCPS");//SCPS[Durst]
break;
case 106:
protocol = _("QNX");//QNX[Hunter]
break;
case 107:
protocol = _("A/N");//Active Networks[Braden]
break;
case 108:
protocol = _("IPComp");//IP Payload Compression Protocol[RFC2393]
break;
case 109:
protocol = _("SNP");//Sitara Networks Protocol[Sridhar]
break;
case 110:
protocol = _("Compaq-Peer");//Compaq Peer Protocol[Volpe]
break;
case 111:
protocol = _("IPX-in-IP");//IPX in IP[Lee]
break;
case 112:
protocol = _("VRRP");//Virtual Router Redundancy Protocol[RFC3768]
break;
case 113:
protocol = _("PGM");//PGM Reliable Transport Protocol[Speakman]
break;
case 114:
protocol = _("any-0-hop");//any 0-hop protocol[IANA]
break;
case 115:
protocol = _("L2TP");//Layer Two Tunneling Protocol[Aboba]
break;
case 116:
protocol = _("DDX");//D-II Data Exchange (DDX)[Worley]
break;
case 117:
protocol = _("IATP");//Interactive Agent Transfer Protocol[Murphy]
break;
case 118:
protocol = _("STP");//Schedule Transfer Protocol[JMP]
break;
case 119:
protocol = _("SRP");//SpectraLink Radio Protocol[Hamilton]
break;
case 120:
protocol = _("UTI");//UTI[Lothberg]
break;
case 121:
protocol = _("SMP");//Simple Message Protocol[Ekblad]
break;
case 122:
protocol = _("SM");//SM[Crowcroft]
break;
case 123:
protocol = _("PTP");//Performance Transparency Protocol[Welzl]
break;
case 124:
protocol = _("ISIS-over-IPv4");//ISIS over IPv4[Przygienda]
break;
case 125:
protocol = _("FIRE");//FIRE[Partridge]
break;
case 126:
protocol = _("CRTP");//Combat Radio Transport Protocol[Sautter]
break;
case 127:
protocol = _("CRUDP");//Combat Radio User Datagram[Sautter]
break;
case 128:
protocol = _("SSCOPMCE");//SSCOPMCE[Waber]
break;
case 129:
protocol = _("IPLT");//IPLT[Hollbach]
break;
case 130:
protocol = _("SPS");//Secure Packet Shield[McIntosh]
break;
case 131:
protocol = _("PIPE");//Private IP Encapsulation within IP[Petri]
break;
case 132:
protocol = _("SCTP");//Stream Control Transmission Protocol[Stewart]
break;
case 133:
protocol = _("FC");//Fibre Channel[Rajagopal]
break;
case 134:
protocol = _("RSVP-E2E-IGNORE");//RSVP-E2E-IGNORE[RFC3175]
break;
case 135:
protocol = _("Mobility Header");//Mobility Header[RFC3775]
break;
case 136:
protocol = _("UDPLite");//UDPLite[RFC3828]
break;
case 137:
protocol = _("MPLS-in-IP");//MPLS-in-IP[RFC4023]
break;
case 253:
protocol = _("experiment-test");//Use for experimentation and testing[RFC3692]
break;
case 254:
protocol = _("experiment-test");//Use for experimentation and testing[RFC3692]
break;
case 255:
protocol = _("Reserved");
break;
default:
protocol = _("undefined service");//138-252,Unassigned[IANA]
break;
}
}
#endif