[openbeosnetteam] Re: Network stack question

  • From: Ivo Vachkov <ivo@xxxxxxxxxxx>
  • To: openbeosnetteam@xxxxxxxxxxxxx
  • Date: Tue, 03 Jul 2007 12:45:43 +0300

Axel Dörfler wrote:
Hugo wrote:
  -> IP
    -> UDP
      -> No endpoint found, return "Port not reachable"
  -> IP sends ICMP Port not reachable.

  Axel may have a different view on this.

Not really :-)
But in addition to that, I think we should have a register_error_handler() 
function in the stack that the ICMP module would use. Then, IPv4 would just 
forward the error to the error module. On the other side, the ICMP module would 
need a way to report an error to a protocol as well.

Bye,
   Axel.

OK, guys :)

Last several days I've been thinking how to organize this code. Here is what i have in mind.

It all starts with ipv4_receive_data(); At the end we see:

   return module->receive_data(buffer);

Well, we can extend it like this:

status_t st = module->receive_data(buffer);

switch (st) {
   case FROM_PROTO_UDP_PORT_UNREACH: {
       net_protocol_module_info *m = receiving_protocol(IPPROTO_ICMP);

       // set some flags describing what ICMP should do with the packet
       // ...
       return m->receive_data(buffer);
   }
   ...
   case FROM_PROTO_ICMP_XXX {
       net_protocol_module_info *m = receiving_protocol(IPPROTO_UDP);

       // set some flags describing what UDP should do with the packet
       // ...
       return m->receive_data(buffer);
   }
   default: break;
}

or we can add an error/info handler in net_protocol_module_info which will change the code to look like this:

status_t st = module->receive_data(buffer);

switch (st) {
   case FROM_PROTO_UDP_PORT_UNREACH: {
       net_protocol_module_info *m = receiving_protocol(IPPROTO_ICMP);
       return m->error_info_handler(buffer, ACTION_TO_TAKE_XXX);
   }
   ...
   case FROM_PROTO_ICMP_XXX {
       net_protocol_module_info *m = receiving_protocol(IPPROTO_UDP);
       return m->error_info_handler(buffer, ACTION_TO_TAKE_YYY);
   }
   default: break;
}

with according error_info_handler() for each protocol to decide what to do.

I'm looking forward to your comments. Thank you in advance.

/ipv


Other related posts: