* Dump a line if an unhandled ICMP packet was received.

* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37584 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-07-19 11:10:45 +00:00
parent 0fc7ab7be6
commit 51b6847f5f
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -48,7 +48,9 @@ struct icmp_header {
}; };
}; };
typedef NetBufferField<uint16, offsetof(icmp_header, checksum)> ICMPChecksumField; typedef NetBufferField<uint16, offsetof(icmp_header, checksum)>
ICMPChecksumField;
#define ICMP_TYPE_ECHO_REPLY 0 #define ICMP_TYPE_ECHO_REPLY 0
#define ICMP_TYPE_UNREACH 3 #define ICMP_TYPE_UNREACH 3
@@ -56,7 +58,9 @@ typedef NetBufferField<uint16, offsetof(icmp_header, checksum)> ICMPChecksumFiel
#define ICMP_TYPE_ECHO_REQUEST 8 #define ICMP_TYPE_ECHO_REQUEST 8
// type unreach codes // type unreach codes
#define ICMP_CODE_UNREACH_NEED_FRAGMENT 4 // this is used for path MTU discovery #define ICMP_CODE_UNREACH_NEED_FRAGMENT 4
// this is used for path MTU discovery
struct icmp_protocol : net_protocol { struct icmp_protocol : net_protocol {
}; };
@@ -130,8 +134,8 @@ icmp_control(net_protocol *protocol, int level, int option, void *value,
status_t status_t
icmp_getsockopt(net_protocol *protocol, int level, int option, icmp_getsockopt(net_protocol* protocol, int level, int option, void* value,
void *value, int *length) int* length)
{ {
return protocol->next->module->getsockopt(protocol->next, level, option, return protocol->next->module->getsockopt(protocol->next, level, option,
value, length); value, length);
@@ -186,7 +190,8 @@ status_t
icmp_send_routed_data(net_protocol* protocol, struct net_route* route, icmp_send_routed_data(net_protocol* protocol, struct net_route* route,
net_buffer* buffer) net_buffer* buffer)
{ {
return protocol->next->module->send_routed_data(protocol->next, route, buffer); return protocol->next->module->send_routed_data(protocol->next, route,
buffer);
} }
@@ -239,7 +244,8 @@ icmp_receive_data(net_buffer *buffer)
TRACE((" got type %u, code %u, checksum %u\n", header.type, header.code, TRACE((" got type %u, code %u, checksum %u\n", header.type, header.code,
ntohs(header.checksum))); ntohs(header.checksum)));
TRACE((" computed checksum: %ld\n", gBufferModule->checksum(buffer, 0, buffer->size, true))); TRACE((" computed checksum: %ld\n",
gBufferModule->checksum(buffer, 0, buffer->size, true)));
if (gBufferModule->checksum(buffer, 0, buffer->size, true) != 0) if (gBufferModule->checksum(buffer, 0, buffer->size, true) != 0)
return B_BAD_DATA; return B_BAD_DATA;
@@ -289,6 +295,11 @@ icmp_receive_data(net_buffer *buffer)
return status; return status;
} }
} }
default:
dprintf("ICMP: received unhandled type %u, code %u\n", header.type,
header.code);
break;
} }
gBufferModule->free(buffer); gBufferModule->free(buffer);
@@ -320,13 +331,14 @@ icmp_std_ops(int32 op, ...)
switch (op) { switch (op) {
case B_MODULE_INIT: case B_MODULE_INIT:
{ {
sStackModule->register_domain_protocols(AF_INET, SOCK_DGRAM, IPPROTO_ICMP, sStackModule->register_domain_protocols(AF_INET, SOCK_DGRAM,
IPPROTO_ICMP,
"network/protocols/icmp/v1", "network/protocols/icmp/v1",
"network/protocols/ipv4/v1", "network/protocols/ipv4/v1",
NULL); NULL);
sStackModule->register_domain_receiving_protocol(AF_INET, IPPROTO_ICMP, sStackModule->register_domain_receiving_protocol(AF_INET,
"network/protocols/icmp/v1"); IPPROTO_ICMP, "network/protocols/icmp/v1");
return B_OK; return B_OK;
} }