Skip to content

Commit b2fbaa4

Browse files
committed
Extract ICMP type/code enums into networklayer/common
Move ICMPv4 enums (IcmpType, IcmpDestinationUnreachableCodes, etc.) from IcmpHeader.msg into new IcmpType.msg in networklayer/common. Move ICMPv6 enums (Icmpv6Type, Icmpv6DestUnav, etc.) from Icmpv6Header.msg into new Icmpv6Type.msg in networklayer/common. IcmpHeader.msg and Icmpv6Header.msg now import the new type files. Icmpv4ErrorTag.msg and Icmpv6ErrorTag.msg import the type files directly instead of the full header files.
1 parent 71a169f commit b2fbaa4

File tree

6 files changed

+169
-150
lines changed

6 files changed

+169
-150
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
//
2+
// Copyright (C) 2000 Institut fuer Telematik, Universitaet Karlsruhe
3+
// Copyright (C) 2004 OpenSim Ltd.
4+
//
5+
// SPDX-License-Identifier: LGPL-3.0-or-later
6+
//
7+
8+
import inet.common.INETDefs;
9+
10+
namespace inet;
11+
12+
//
13+
// The real ICMP codes
14+
//
15+
enum IcmpType
16+
{
17+
18+
ICMP_DESTINATION_UNREACHABLE = 3;
19+
ICMP_SOURCEQUENCH = 4; // packet lost, slow down
20+
ICMP_REDIRECT = 5;
21+
ICMP_ECHO_REQUEST = 8;
22+
ICMP_ROUTER_ADVERTISEMENT = 9; // router advertisement
23+
ICMP_ROUTER_SOLICITATION = 10; // router solicitation
24+
ICMP_TIME_EXCEEDED = 11;
25+
ICMP_PARAMETER_PROBLEM = 12;
26+
27+
ICMP_ECHO_REPLY = 0;
28+
ICMP_TIMESTAMP_REQUEST = 13;
29+
ICMP_TIMESTAMP_REPLY = 14;
30+
ICMP_INFORMATION_REQUEST = 15; // information request
31+
ICMP_INFORMATION_REPLY = 16; // information reply
32+
ICMP_MASK_REQUEST = 17; // address mask request
33+
ICMP_MASK_REPLY = 18; // address mask reply
34+
}
35+
36+
enum IcmpRedirectSubcodes
37+
{
38+
ICMP_REDIRECT_NET = 0; // for network
39+
ICMP_REDIRECT_HOST = 1; // for host
40+
ICMP_REDIRECT_TOSNET = 2; // for tos and net
41+
ICMP_REDIRECT_TOSHOST = 3; // for tos and host
42+
}
43+
44+
enum IcmpTimeExceededSubcodes
45+
{
46+
ICMP_TIMXCEED_INTRANS = 0; // ttl==0 in transit
47+
ICMP_TIMXCEED_REASS = 1; // ttl==0 in reass
48+
}
49+
50+
enum IcmpParameterProblemSubcodes
51+
{
52+
ICMP_PARAMPROB_ERRATPTR = 0; // error at param ptr
53+
ICMP_PARAMPROB_OPTABSENT = 1; // req. opt. absent
54+
ICMP_PARAMPROB_LENGTH = 2; // bad length
55+
}
56+
57+
//
58+
// Codes for type ICMP_DESTINATION_UNREACHABLE
59+
//
60+
enum IcmpDestinationUnreachableCodes
61+
{
62+
ICMP_DU_NETWORK_UNREACHABLE = 0;
63+
ICMP_DU_HOST_UNREACHABLE = 1;
64+
ICMP_DU_PROTOCOL_UNREACHABLE = 2;
65+
ICMP_DU_PORT_UNREACHABLE = 3;
66+
ICMP_DU_FRAGMENTATION_NEEDED = 4;
67+
ICMP_DU_SOURCE_ROUTE_FAILED = 5;
68+
ICMP_DU_DESTINATION_NETWORK_UNKNOWN = 6;
69+
ICMP_DU_DESTINATION_HOST_UNKNOWN = 7;
70+
ICMP_DU_SOURCE_HOST_ISOLATED = 8;
71+
ICMP_DU_NETWORK_PROHIBITED = 9;
72+
ICMP_DU_HOST_PROHIBITED = 10;
73+
ICMP_DU_NETWORK_UNREACHABLE_FOR_TYPE_OF_SERVICE = 11;
74+
ICMP_DU_HOST_UNREACHABLE_FOR_TYPE_OF_SERVICE = 12;
75+
ICMP_DU_COMMUNICATION_PROHIBITED = 13;
76+
ICMP_DU_HOST_PRECEDENCE_VIOLATION = 14;
77+
ICMP_DU_PRECEDENCE_CUTOFF_IN_EFFECT = 15;
78+
ICMP_AODV_QUEUE_FULL = 16;
79+
}
80+
81+
cplusplus {{
82+
typedef int IcmpCode;
83+
84+
inline bool isIcmpInfoType(int type)
85+
{
86+
return (type == ICMP_ECHO_REPLY
87+
|| type == ICMP_ECHO_REQUEST
88+
|| type == ICMP_ROUTER_ADVERTISEMENT
89+
|| type == ICMP_ROUTER_SOLICITATION
90+
|| type == ICMP_TIMESTAMP_REQUEST
91+
|| type == ICMP_TIMESTAMP_REPLY
92+
|| type == ICMP_INFORMATION_REQUEST
93+
|| type == ICMP_INFORMATION_REPLY
94+
|| type == ICMP_MASK_REQUEST
95+
|| type == ICMP_MASK_REPLY);
96+
}
97+
98+
}}

src/inet/networklayer/common/Icmpv4ErrorTag.msg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import inet.common.INETDefs;
88
import inet.common.TagBase;
99
import inet.common.packet.chunk.Chunk;
1010
import inet.common.packet.Packet;
11-
import inet.networklayer.ipv4.IcmpHeader;
11+
import inet.networklayer.common.IcmpType;
1212

1313
namespace inet;
1414

src/inet/networklayer/common/Icmpv6ErrorTag.msg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import inet.common.INETDefs;
88
import inet.common.TagBase;
99
import inet.common.packet.chunk.Chunk;
1010
import inet.common.packet.Packet;
11-
import inet.networklayer.icmpv6.Icmpv6Header;
11+
import inet.networklayer.common.Icmpv6Type;
1212

1313
namespace inet;
1414

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//
2+
// Copyright (C) 2001 CTIE, Monash University
3+
// Copyright (C) 2005 OpenSim Ltd.
4+
// Copyright (C) 2005 Wei Yang, Ng
5+
//
6+
// SPDX-License-Identifier: LGPL-3.0-or-later
7+
//
8+
9+
import inet.common.INETDefs;
10+
11+
namespace inet;
12+
13+
enum Icmpv6Type
14+
{
15+
16+
ICMPv6_UNSPECIFIED = 0;
17+
ICMPv6_DESTINATION_UNREACHABLE = 1;
18+
ICMPv6_PACKET_TOO_BIG = 2;
19+
ICMPv6_TIME_EXCEEDED = 3;
20+
ICMPv6_PARAMETER_PROBLEM = 4;
21+
ICMPv6_ECHO_REQUEST = 128;
22+
ICMPv6_ECHO_REPLY = 129;
23+
ICMPv6_MLD_QUERY = 130;
24+
ICMPv6_MLD_REPORT = 131;
25+
ICMPv6_MLD_DONE = 132;
26+
ICMPv6_ROUTER_SOL = 133;
27+
ICMPv6_ROUTER_AD = 134;
28+
ICMPv6_NEIGHBOUR_SOL = 135;
29+
ICMPv6_NEIGHBOUR_AD = 136;
30+
ICMPv6_REDIRECT = 137;
31+
ICMPv6_MLDv2_REPORT = 143;
32+
ICMPv6_EXPERIMENTAL_MOBILITY = 150; //Zarrar Yousaf 02.08.07 (FMIPv6 Implementation)
33+
}
34+
35+
//
36+
// ICMPv6 "codes" for type ICMPv6_DESTINATION_UNREACHABLE
37+
//
38+
enum Icmpv6DestUnav
39+
{
40+
41+
NO_ROUTE_TO_DEST = 0;
42+
COMM_WITH_DEST_PROHIBITED = 1;
43+
//2 - NOT ASSIGNED
44+
ADDRESS_UNREACHABLE = 3;
45+
PORT_UNREACHABLE = 4;
46+
}
47+
48+
//
49+
// ICMPv6 "codes" for type ICMPv6_TIME_EXCEEDED
50+
//
51+
enum Icmpv6TimeEx
52+
{
53+
54+
ND_HOP_LIMIT_EXCEEDED = 0;
55+
ND_FRAGMENT_REASSEMBLY_TIME = 1;
56+
}
57+
58+
//
59+
// ICMPv6 "codes" for type ICMPv6_PARAMETER_PROBLEM
60+
//
61+
enum Icmpv6ParameterProblem
62+
{
63+
64+
ERROREOUS_HDR_FIELD = 0;
65+
UNRECOGNIZED_NEXT_HDR_TYPE = 1;
66+
UNRECOGNIZED_IPV6_OPTION = 2;
67+
}

src/inet/networklayer/icmpv6/Icmpv6Header.msg

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -10,73 +10,14 @@ import inet.common.INETDefs;
1010
import inet.common.Units;
1111
import inet.common.packet.chunk.Chunk;
1212
import inet.common.checksum.ChecksumMode;
13+
import inet.networklayer.common.Icmpv6Type;
1314

1415
namespace inet;
1516

1617
cplusplus {{
1718
const B ICMPv6_HEADER_BYTES = B(8);
1819
}}
1920

20-
//
21-
//# TODO consolidate this file's contents with ICMPMessage.msg
22-
//
23-
24-
enum Icmpv6Type
25-
{
26-
27-
ICMPv6_UNSPECIFIED = 0;
28-
ICMPv6_DESTINATION_UNREACHABLE = 1;
29-
ICMPv6_PACKET_TOO_BIG = 2;
30-
ICMPv6_TIME_EXCEEDED = 3;
31-
ICMPv6_PARAMETER_PROBLEM = 4;
32-
ICMPv6_ECHO_REQUEST = 128;
33-
ICMPv6_ECHO_REPLY = 129;
34-
ICMPv6_MLD_QUERY = 130;
35-
ICMPv6_MLD_REPORT = 131;
36-
ICMPv6_MLD_DONE = 132;
37-
ICMPv6_ROUTER_SOL = 133;
38-
ICMPv6_ROUTER_AD = 134;
39-
ICMPv6_NEIGHBOUR_SOL = 135;
40-
ICMPv6_NEIGHBOUR_AD = 136;
41-
ICMPv6_REDIRECT = 137;
42-
ICMPv6_MLDv2_REPORT = 143;
43-
ICMPv6_EXPERIMENTAL_MOBILITY = 150; //Zarrar Yousaf 02.08.07 (FMIPv6 Implementation)
44-
}
45-
46-
//
47-
// ICMPv6 "codes" for type ICMPv6_DESTINATION_UNREACHABLE
48-
//
49-
enum Icmpv6DestUnav
50-
{
51-
52-
NO_ROUTE_TO_DEST = 0;
53-
COMM_WITH_DEST_PROHIBITED = 1;
54-
//2 - NOT ASSIGNED
55-
ADDRESS_UNREACHABLE = 3;
56-
PORT_UNREACHABLE = 4;
57-
}
58-
59-
//
60-
// ICMPv6 "codes" for type ICMPv6_TIME_EXCEEDED
61-
//
62-
enum Icmpv6TimeEx
63-
{
64-
65-
ND_HOP_LIMIT_EXCEEDED = 0;
66-
ND_FRAGMENT_REASSEMBLY_TIME = 1;
67-
}
68-
69-
//
70-
// ICMPv6 "codes" for type ICMPv6_PARAMETER_PROBLEM
71-
//
72-
enum Icmpv6ParameterProblem
73-
{
74-
75-
ERROREOUS_HDR_FIELD = 0;
76-
UNRECOGNIZED_NEXT_HDR_TYPE = 1;
77-
UNRECOGNIZED_IPV6_OPTION = 2;
78-
}
79-
8021
//
8122
// Represents an ICMPv6 packet.
8223
//

src/inet/networklayer/ipv4/IcmpHeader.msg

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -8,97 +8,10 @@
88
import inet.common.INETDefs;
99
import inet.common.packet.chunk.Chunk;
1010
import inet.common.checksum.ChecksumMode;
11+
import inet.networklayer.common.IcmpType;
1112

1213
namespace inet;
1314

14-
//
15-
// The real ICMP codes
16-
//
17-
enum IcmpType
18-
{
19-
20-
ICMP_DESTINATION_UNREACHABLE = 3;
21-
ICMP_SOURCEQUENCH = 4; // packet lost, slow down
22-
ICMP_REDIRECT = 5;
23-
ICMP_ECHO_REQUEST = 8;
24-
ICMP_ROUTER_ADVERTISEMENT = 9; // router advertisement
25-
ICMP_ROUTER_SOLICITATION = 10; // router solicitation
26-
ICMP_TIME_EXCEEDED = 11;
27-
ICMP_PARAMETER_PROBLEM = 12;
28-
29-
ICMP_ECHO_REPLY = 0;
30-
ICMP_TIMESTAMP_REQUEST = 13;
31-
ICMP_TIMESTAMP_REPLY = 14;
32-
ICMP_INFORMATION_REQUEST = 15; // information request
33-
ICMP_INFORMATION_REPLY = 16; // information reply
34-
ICMP_MASK_REQUEST = 17; // address mask request
35-
ICMP_MASK_REPLY = 18; // address mask reply
36-
}
37-
38-
enum IcmpRedirectSubcodes
39-
{
40-
ICMP_REDIRECT_NET = 0; // for network
41-
ICMP_REDIRECT_HOST = 1; // for host
42-
ICMP_REDIRECT_TOSNET = 2; // for tos and net
43-
ICMP_REDIRECT_TOSHOST = 3; // for tos and host
44-
}
45-
46-
enum IcmpTimeExceededSubcodes
47-
{
48-
ICMP_TIMXCEED_INTRANS = 0; // ttl==0 in transit
49-
ICMP_TIMXCEED_REASS = 1; // ttl==0 in reass
50-
}
51-
52-
enum IcmpParameterProblemSubcodes
53-
{
54-
ICMP_PARAMPROB_ERRATPTR = 0; // error at param ptr
55-
ICMP_PARAMPROB_OPTABSENT = 1; // req. opt. absent
56-
ICMP_PARAMPROB_LENGTH = 2; // bad length
57-
}
58-
59-
//
60-
// Codes for type ICMP_DESTINATION_UNREACHABLE
61-
//
62-
enum IcmpDestinationUnreachableCodes
63-
{
64-
ICMP_DU_NETWORK_UNREACHABLE = 0;
65-
ICMP_DU_HOST_UNREACHABLE = 1;
66-
ICMP_DU_PROTOCOL_UNREACHABLE = 2;
67-
ICMP_DU_PORT_UNREACHABLE = 3;
68-
ICMP_DU_FRAGMENTATION_NEEDED = 4;
69-
ICMP_DU_SOURCE_ROUTE_FAILED = 5;
70-
ICMP_DU_DESTINATION_NETWORK_UNKNOWN = 6;
71-
ICMP_DU_DESTINATION_HOST_UNKNOWN = 7;
72-
ICMP_DU_SOURCE_HOST_ISOLATED = 8;
73-
ICMP_DU_NETWORK_PROHIBITED = 9;
74-
ICMP_DU_HOST_PROHIBITED = 10;
75-
ICMP_DU_NETWORK_UNREACHABLE_FOR_TYPE_OF_SERVICE = 11;
76-
ICMP_DU_HOST_UNREACHABLE_FOR_TYPE_OF_SERVICE = 12;
77-
ICMP_DU_COMMUNICATION_PROHIBITED = 13;
78-
ICMP_DU_HOST_PRECEDENCE_VIOLATION = 14;
79-
ICMP_DU_PRECEDENCE_CUTOFF_IN_EFFECT = 15;
80-
ICMP_AODV_QUEUE_FULL = 16;
81-
}
82-
83-
cplusplus {{
84-
typedef int IcmpCode;
85-
86-
inline bool isIcmpInfoType(int type)
87-
{
88-
return (type == ICMP_ECHO_REPLY
89-
|| type == ICMP_ECHO_REQUEST
90-
|| type == ICMP_ROUTER_ADVERTISEMENT
91-
|| type == ICMP_ROUTER_SOLICITATION
92-
|| type == ICMP_TIMESTAMP_REQUEST
93-
|| type == ICMP_TIMESTAMP_REPLY
94-
|| type == ICMP_INFORMATION_REQUEST
95-
|| type == ICMP_INFORMATION_REPLY
96-
|| type == ICMP_MASK_REQUEST
97-
|| type == ICMP_MASK_REPLY);
98-
}
99-
100-
}}
101-
10215
//
10316
// ICMP message class
10417
//

0 commit comments

Comments
 (0)