Axel Dörfler wrote:
Looking at the BONE headers, there are the following two functions in what would be net_protocol_module_info in our stack (and I copied them into our's, too):/** interface for error codes (ICMP, etc) to be passed back to protocols* from the network layer */ status_t (*error)(int32 error_code, bone_data_t *error_data); /** interface for error replies (ICMP, etc) to be sent from protocols * to other sites. Error codes can be passed, or a data ptr and length * may be passed. If error_data is non-0 error_code will be assumed to* be a length, otherwise a code. */ status_t (*error_reply)(struct bone_proto_node *you, bone_data_t * caused_error, uint32 error_code, void *error_data);I'd propose that the ICMPv4 module will call error() on the domain protocol (which we could rename to receive_error(), as it's pretty similar to what receive_data() does) if it doesn't handle the packet itself (ie. like echo). Then, IPv4 will either handle the error itself, or pass it on to the protocols, just like it would do in receive_data() - but of course it will also call the protocol's receive_error() method.On the sending side of things, ICMP should register itself as the error handling protocol for the domain (via new stack methods to do that). I am not yet sure how to go from there - probably, there has to be a stack function send_error() that gets the protocol module as well as the data as error_reply() above, and will then call the error handler (ie. ICMPv4) to build a reply buffer then is then pushed down the stack using error_reply() - which I would then rename to send_error() as well. It will probably also need to know where to send the error to - either from the error-causing buffer, or from some route that the stack's send_error() would then also need to get.
I am a bit confused. So I'll try to explain my understanding of the following like this:
1. Handling Received ICMP info/error messages: in IP module: - we see it's an ICMP packet - we send it to icmp receive_data() in ICMP module: - we check if we can deal with that packet- if we can deal - we handle it appropriately (like echo/timestamp/information replies)
- if we can not: - set a module pointer to the appropriate protocol module - call module->error(); 2. Generating/Sending ICMP error messages: in IP module: - module->receive_data() returns error - we call module->error_reply() in module->error_reply(): - set a pointer to the icmp protocol module - call icmp_module->error_reply() Is this the proper way ? Am I missing something ? /ipv