* First part of ICMP support: this is based on the work by Ivo Vachkov (GSoC

2007), and Yin Qiu (GSoC 2008). And even though I needed to rewrite pretty
  much all of it because of the countless bugs and problems it had, it still
  shares the same architectural problems of introducing a domain dependent
  error mechanism to the upper layers, and needing the
  net_buffer::network_header hack. This I will rework later.
* net_buffer's append_size(), and prepend_size() will now gracefully handle
  buffers without a data node.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37647 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-07-21 12:00:27 +00:00
parent f6a57629c3
commit 1978fb81ee
8 changed files with 386 additions and 105 deletions
+59
View File
@@ -0,0 +1,59 @@
/*
* Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef ICMP_H
#define ICMP_H
// TODO: this will go private soon
// RFC 792
#define ICMP_TYPE_ECHO_REPLY 0
#define ICMP_TYPE_UNREACH 3
#define ICMP_TYPE_SOURCE_QUENCH 4
#define ICMP_TYPE_REDIRECT 5
#define ICMP_TYPE_ECHO_REQUEST 8
#define ICMP_TYPE_TIME_EXCEEDED 11
#define ICMP_TYPE_PARAM_PROBLEM 12
#define ICMP_TYPE_TIMESTAMP_REQUEST 13
#define ICMP_TYPE_TIMESTAMP_REPLY 14
#define ICMP_TYPE_INFO_REQUEST 15
#define ICMP_TYPE_INFO_REPLY 16
// RFC 950
#define ICMP_TYPE_ADDR_MASK_REQUEST 17
#define ICMP_TYPE_ADDR_MASK_REPLY 18
#define ICMP_CODE_TIMEEX_IN_TRANSIT 0
#define ICMP_CODE_TIMEEX_FRAG 1
#define ICMP_CODE_PARAM_PROBLEM 0
#define ICMP_CODE_SOURCE_QUENCH 0
#define ICMP_CODE_NET_UNREACH 0
#define ICMP_CODE_HOST_UNREACH 1
#define ICMP_CODE_PROTO_UNREACH 2
#define ICMP_CODE_PORT_UNREACH 3
#define ICMP_CODE_FRAG_NEEDED 4
#define ICMP_CODE_SOURCE_ROUTE_FAIL 5
#define ICMP_CODE_REDIRECT_NET 0
#define ICMP_CODE_REDIRECT_HOST 1
#define ICMP_CODE_REDIRECT_TOS_NET 2
#define ICMP_CODE_REDIRECT_TOS_HOST 3
static inline void
icmp_decode(uint32 errorCode, uint8 &type, uint8 &code)
{
type = errorCode >> 8;
code = errorCode & 0x0FF;
}
static inline uint32
icmp_encode(uint8 type, uint8 code)
{
return ((uint32)type) << 8 + code;
}
#endif // ICMP_H
+6 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
* Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef NET_BUFFER_H
@@ -14,6 +14,7 @@
#define NET_BUFFER_MODULE_NAME "network/stack/buffer/v1"
typedef struct net_buffer {
struct list_link link;
@@ -36,7 +37,10 @@ typedef struct net_buffer {
uint32 flags;
uint32 size;
uint8 protocol;
// TODO: these two should go away again
uint8 hoplimit;
void * network_header;
} net_buffer;
struct ancillary_data_container;
@@ -98,4 +102,5 @@ struct net_buffer_module_info {
void (*dump)(net_buffer *buffer);
};
#endif // NET_BUFFER_H
+1 -1
View File
@@ -70,7 +70,7 @@ struct net_protocol_module_info {
status_t (*receive_data)(net_buffer *data);
status_t (*deliver_data)(net_protocol *protocol, net_buffer *data);
status_t (*error)(uint32 code, net_buffer *data);
status_t (*error_received)(uint32 code, net_buffer *data);
status_t (*error_reply)(net_protocol *self, net_buffer *causedError,
uint32 code, void *errorData);