Skip to content

Commit

Permalink
Bugfix: Properly obtain status code when response message is UDP over…
Browse files Browse the repository at this point in the history
… IPv6.
  • Loading branch information
dreibh committed Jan 28, 2025
1 parent 51956d7 commit a1428ce
Showing 1 changed file with 59 additions and 48 deletions.
107 changes: 59 additions & 48 deletions src/iomodule-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -363,68 +363,79 @@ void IOModuleBase::recordResult(const ReceivedData& receivedData,
receivedData.ReceiveHWSource,
receivedData.ReceiveHWTime);

// Set ICMP error status:
// ====== Obtain status code from response ============================
HopStatus status = Unknown;
if(SourceAddress.is_v6()) {
if(icmpType == ICMP6_TIME_EXCEEDED) {
status = TimeExceeded;

// ------ Not ICMP/ICMPv6 ---------------------------------------------
if( (icmpType == 0) && (icmpCode == 0) ) {
// This is used for non-ICMP payload replies (success):
status = Success;
}

// ------ ICMP/ICMPv6 -------------------------------------------------
else {
// Set ICMP error status:
if(SourceAddress.is_v6()) {
if(icmpType == ICMP6_TIME_EXCEEDED) {
status = TimeExceeded;
}
else if(icmpType == ICMP6_DST_UNREACH) {
if(SourceAddress.is_v6()) {
switch(icmpCode) {
case ICMP6_DST_UNREACH_ADMIN:
status = UnreachableProhibited;
break;
case ICMP6_DST_UNREACH_BEYONDSCOPE:
status = UnreachableScope;
break;
case ICMP6_DST_UNREACH_NOROUTE:
status = UnreachableNetwork;
break;
case ICMP6_DST_UNREACH_ADDR:
status = UnreachableHost;
break;
case ICMP6_DST_UNREACH_NOPORT:
status = UnreachablePort;
break;
default:
status = UnreachableUnknown;
break;
}
}
}
else if(icmpType == ICMP6_ECHO_REPLY) {
status = Success;
}
}
else if(icmpType == ICMP6_DST_UNREACH) {
if(SourceAddress.is_v6()) {
else {
if(icmpType == ICMP_TIMXCEED) {
status = TimeExceeded;
}
else if(icmpType == ICMP_UNREACH) {
switch(icmpCode) {
case ICMP6_DST_UNREACH_ADMIN:
case ICMP_UNREACH_FILTER_PROHIB:
status = UnreachableProhibited;
break;
case ICMP6_DST_UNREACH_BEYONDSCOPE:
status = UnreachableScope;
break;
case ICMP6_DST_UNREACH_NOROUTE:
break;
case ICMP_UNREACH_NET:
case ICMP_UNREACH_NET_UNKNOWN:
status = UnreachableNetwork;
break;
case ICMP6_DST_UNREACH_ADDR:
break;
case ICMP_UNREACH_HOST:
case ICMP_UNREACH_HOST_UNKNOWN:
status = UnreachableHost;
break;
case ICMP6_DST_UNREACH_NOPORT:
break;
case ICMP_UNREACH_PORT:
status = UnreachablePort;
break;
break;
default:
status = UnreachableUnknown;
break;
}
}
}
else if(icmpType == ICMP6_ECHO_REPLY) {
status = Success;
}
}
else {
if(icmpType == ICMP_TIMXCEED) {
status = TimeExceeded;
}
else if(icmpType == ICMP_UNREACH) {
switch(icmpCode) {
case ICMP_UNREACH_FILTER_PROHIB:
status = UnreachableProhibited;
break;
case ICMP_UNREACH_NET:
case ICMP_UNREACH_NET_UNKNOWN:
status = UnreachableNetwork;
break;
case ICMP_UNREACH_HOST:
case ICMP_UNREACH_HOST_UNKNOWN:
status = UnreachableHost;
break;
case ICMP_UNREACH_PORT:
status = UnreachablePort;
break;
default:
status = UnreachableUnknown;
break;
else if(icmpType == ICMP_ECHOREPLY) {
status = Success;
}
}
else if(icmpType == ICMP_ECHOREPLY) {
status = Success;
}
}
resultEntry->setStatus(status);

Expand Down

0 comments on commit a1428ce

Please sign in to comment.