Subversion Repositories HelenOS

Rev

Rev 4243 | Rev 4332 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright (c) 2009 Lukas Mejdrech
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  *
  9.  * - Redistributions of source code must retain the above copyright
  10.  *   notice, this list of conditions and the following disclaimer.
  11.  * - Redistributions in binary form must reproduce the above copyright
  12.  *   notice, this list of conditions and the following disclaimer in the
  13.  *   documentation and/or other materials provided with the distribution.
  14.  * - The name of the author may not be used to endorse or promote products
  15.  *   derived from this software without specific prior written permission.
  16.  *
  17.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  18.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27.  */
  28.  
  29. /** @addtogroup eth
  30.  *  @{
  31.  */
  32.  
  33. /** @file
  34.  *  Ethernet module implementation.
  35.  *  @see eth.h
  36.  */
  37.  
  38. #include <async.h>
  39. #include <malloc.h>
  40. #include <mem.h>
  41. #include <stdio.h>
  42.  
  43. #include <ipc/ipc.h>
  44. #include <ipc/services.h>
  45.  
  46. #include "../../err.h"
  47. #include "../../messages.h"
  48. #include "../../modules.h"
  49.  
  50. #include "../../include/byteorder.h"
  51. #include "../../include/crc.h"
  52. #include "../../include/ethernet_lsap.h"
  53. #include "../../include/ethernet_protocols.h"
  54. #include "../../include/protocol_map.h"
  55. #include "../../include/device.h"
  56. #include "../../include/netif_messages.h"
  57. #include "../../include/nil_messages.h"
  58.  
  59. #include "../../structures/measured_strings.h"
  60. #include "../../structures/packet/packet_client.h"
  61.  
  62. #include "../nil_module.h"
  63. #include "../nil_wrappers.h"
  64.  
  65. #include "eth.h"
  66. #include "eth_header.h"
  67.  
  68. #define ETH_PREFIX      ( sizeof( eth_header_t ) + sizeof( eth_header_lsap_t ) + sizeof( eth_header_snap_t ))
  69. #define ETH_SUFFIX      sizeof( eth_fcs_t )
  70. #define ETH_MAX_CONTENT 1500
  71. #define ETH_MIN_CONTENT 46
  72. #define ETH_MAX_TAGGED_CONTENT  ( ETH_MAX_CONTENT - sizeof( eth_header_lsap_t ) - sizeof( eth_header_snap_t ))
  73. #define ETH_MIN_TAGGED_CONTENT  ( ETH_MIN_CONTENT - sizeof( eth_header_lsap_t ) - sizeof( eth_header_snap_t ))
  74.  
  75. typedef enum eth_addr_type  eth_addr_type_t;
  76. typedef eth_addr_type_t *   eth_addr_type_ref;
  77.  
  78. enum eth_addr_type{
  79.     ETH_LOCAL_ADDR,
  80.     ETH_BROADCAST_ADDR
  81. };
  82.  
  83. /** Ethernet global data.
  84.  */
  85. eth_globals_t   eth_globals;
  86.  
  87. /** Processes IPC messages from the registered device driver modules in an infinite loop.
  88.  *  @param iid The message identifier. Input parameter.
  89.  *  @param icall The message parameters. Input/output parameter.
  90.  */
  91. void    eth_receiver( ipc_callid_t iid, ipc_call_t * icall );
  92.  
  93. DEVICE_MAP_IMPLEMENT( eth_devices, eth_device_t )
  94.  
  95. INT_MAP_IMPLEMENT( eth_protos, eth_proto_t )
  96.  
  97. int eth_device_message( device_id_t device_id, services_t service, size_t mtu );
  98. int eth_receive_message( device_id_t device_id, packet_t packet );
  99. int eth_packet_space_message( device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix );
  100. int eth_addr_message( device_id_t device_id, eth_addr_type_t type, measured_string_ref * address );
  101. int eth_send_message( device_id_t device_id, packet_t packet, services_t sender );
  102. eth_proto_ref   eth_process_packet( int dummy, packet_t packet );
  103. int eth_prepare_packet( int dummy, packet_t packet, uint8_t * src_addr, int ethertype );
  104.  
  105. void    nil_device_state_wrapper( device_id_t device_id, int state ){
  106.     int             index;
  107.     eth_proto_ref   proto;
  108.  
  109.     //TODO clear device if off?
  110.     rwlock_read_lock( & eth_globals.protos_lock );
  111.     for( index = eth_protos_count( & eth_globals.protos ) - 1; index >= 0; -- index ){
  112.         proto = eth_protos_get_index( & eth_globals.protos, index );
  113.         if( proto && proto->phone ) async_msg_2( proto->phone, NET_IL_DEVICE_STATE, device_id, state );
  114.     }
  115.     rwlock_read_unlock( & eth_globals.protos_lock );
  116. }
  117.  
  118. int nil_receive_wrapper( device_id_t device_id, packet_t packet ){
  119.     return eth_receive_message( device_id, packet );
  120. }
  121.  
  122. int nil_initialize( int networking_phone ){
  123.     ERROR_DECLARE;
  124.  
  125.     rwlock_initialize( & eth_globals.devices_lock );
  126.     rwlock_initialize( & eth_globals.protos_lock );
  127.     rwlock_write_lock( & eth_globals.devices_lock );
  128.     rwlock_write_lock( & eth_globals.protos_lock );
  129.     eth_globals.networking_phone = networking_phone;
  130.     eth_globals.broadcast_addr = measured_string_create_bulk( "\xFF\xFF\xFF\xFF\xFF\xFF", CONVERT_SIZE( uint8_t, char, ETH_ADDR ));
  131.     if( ! eth_globals.broadcast_addr ) return ENOMEM;
  132.     ERROR_PROPAGATE( eth_devices_initialize( & eth_globals.devices ));
  133.     if( ERROR_OCCURRED( eth_protos_initialize( & eth_globals.protos ))){
  134.         eth_devices_destroy( & eth_globals.devices );
  135.         return ERROR_CODE;
  136.     }
  137.     rwlock_write_unlock( & eth_globals.protos_lock );
  138.     rwlock_write_unlock( & eth_globals.devices_lock );
  139.     return EOK;
  140. }
  141.  
  142. int eth_device_message( device_id_t device_id, services_t service, size_t mtu ){
  143.     ERROR_DECLARE;
  144.  
  145.     eth_device_ref  device;
  146.     int             index;
  147.  
  148.     rwlock_write_lock( & eth_globals.devices_lock );
  149.     // an existing device?
  150.     device = eth_devices_find( & eth_globals.devices, device_id );
  151.     if( device ){
  152.         if( device->service != service ){
  153.             printf( "\nDevice %d already exists", device->device_id );
  154.             rwlock_write_unlock( & eth_globals.devices_lock );
  155.             return EEXIST;
  156.         }else{
  157.             // update mtu
  158.             device->mtu = mtu;
  159.             printf( "\nDevice %d already exists:\tMTU\t= %d", device->device_id, device->mtu );
  160.         }
  161.     }else{
  162.         // create a new device
  163.         device = ( eth_device_ref ) malloc( sizeof( eth_device_t ));
  164.         if( ! device ) return ENOMEM;
  165.         device->device_id = device_id;
  166.         device->service = service;
  167.         device->mtu = (( mtu > 0 ) && ( mtu <= ETH_MAX_TAGGED_CONTENT )) ? mtu : ETH_MAX_TAGGED_CONTENT;
  168.         // TODO get dummy setting
  169.         device->dummy = 0;
  170.         // bind the device driver
  171. #if ! NETIF_BUNDLE
  172.         device->phone = bind_service( device->service, device->device_id, SERVICE_ETHERNET, 0, eth_receiver );
  173.         if( device->phone < 0 ){
  174.             rwlock_write_unlock( & eth_globals.devices_lock );
  175.             free( device );
  176.             return device->phone;
  177.         }
  178. #endif
  179.         // get hardware address
  180.         if( ERROR_OCCURRED( netif_get_addr( device->phone, device->device_id, & device->addr, & device->addr_data ))){
  181.             rwlock_write_unlock( & eth_globals.devices_lock );
  182.             free( device );
  183.             return ERROR_CODE;
  184.         }
  185.         // add to the cache
  186.         index = eth_devices_add( & eth_globals.devices, device->device_id, device );
  187.         if( index < 0 ){
  188.             rwlock_write_unlock( & eth_globals.devices_lock );
  189.             free( device->addr );
  190.             free( device->addr_data );
  191.             free( device );
  192.             return index;
  193.         }
  194.         printf( "\nNew device registered:\n\tid\t= %d\n\tservice\t= %d\n\tMTU\t= %d\n\taddress\t= %X:%X:%X:%X:%X:%X", device->device_id, device->service, device->mtu, device->addr_data[ 0 ], device->addr_data[ 1 ], device->addr_data[ 2 ], device->addr_data[ 3 ], device->addr_data[ 4 ], device->addr_data[ 5 ] );
  195.     }
  196.     rwlock_write_unlock( & eth_globals.devices_lock );
  197.     return EOK;
  198. }
  199.  
  200. eth_proto_ref eth_process_packet( int dummy, packet_t packet ){
  201.     ERROR_DECLARE;
  202.  
  203.     eth_header_ex_ref   header;
  204.     size_t              length;
  205.     int                 type;
  206.     size_t              prefix;
  207.     size_t              suffix;
  208.     eth_fcs_ref         fcs;
  209.  
  210.     length = packet_get_data_length( packet );
  211.     if( dummy ){
  212.         packet_trim( packet, sizeof( eth_preamble_t ), 0 );
  213.     }
  214.     if( length <= sizeof( eth_header_t ) + ETH_MIN_CONTENT + ETH_SUFFIX ) return NULL;
  215.     header = ( eth_header_ex_ref ) packet_get_data( packet );
  216.     type = ntohs( header->header.ethertype );
  217.     if( type >= ETH_MIN_PROTO ){
  218.         // DIX Ethernet
  219.         prefix = sizeof( eth_header_t );
  220.         suffix = sizeof( eth_fcs_t );
  221.         fcs = (( void * ) header ) + length - suffix;
  222.     }else if( type <= ETH_MAX_CONTENT ){
  223.         // translate "LSAP" values
  224.         if(( header->lsap.dsap == ETH_LSAP_GLSAP ) && ( header->lsap.ssap == ETH_LSAP_GLSAP )){
  225.             // raw packet
  226.             // discard
  227.             return NULL;
  228.         }else if(( header->lsap.dsap == ETH_LSAP_SNAP ) && ( header->lsap.ssap == ETH_LSAP_SNAP )){
  229.             // IEEE 802.3 + 802.2 + LSAP + SNAP
  230.             // organization code not supported
  231.             type = ntohs( header->snap.ethertype );
  232.             prefix = sizeof( eth_header_t ) + sizeof( eth_header_lsap_t ) + sizeof( eth_header_snap_t );
  233.         }else{
  234.             // IEEE 802.3 + 802.2 LSAP
  235.             type = lsap_map( header->lsap.dsap );
  236.             prefix = sizeof( eth_header_t ) + sizeof( eth_header_lsap_t);
  237.         }
  238.         suffix = ( type < ETH_MIN_CONTENT ) ? ETH_MIN_CONTENT - type : 0;
  239.         fcs = (( void * ) header ) + prefix + type + suffix;
  240.         suffix += length - prefix - type;
  241.     }else{
  242.         // invalid length/type, should not occurr
  243.         return NULL;
  244.     }
  245.     if( dummy ){
  246.         if(( ~ compute_crc32( ~ 0, & header->header.dest, ((( void * ) fcs ) - (( void * ) & header->header.dest )) * 8 )) != ntohl( * fcs )){
  247.             return NULL;
  248.         }
  249.     }
  250.     if( ERROR_OCCURRED( packet_set_addr( packet, header->header.src, header->header.dest, ETH_ADDR ))
  251.     || ERROR_OCCURRED( packet_trim( packet, prefix, suffix ))){
  252.         return NULL;
  253.     }
  254.     return eth_protos_find( & eth_globals.protos, type );
  255. }
  256.  
  257. int eth_receive_message( device_id_t device_id, packet_t packet ){
  258.     eth_proto_ref   proto;
  259.     packet_t        next;
  260.     eth_device_ref  device;
  261.     int             dummy;
  262.  
  263.     rwlock_read_lock( & eth_globals.devices_lock );
  264.     device = eth_devices_find( & eth_globals.devices, device_id );
  265.     if( ! device ){
  266.         rwlock_read_unlock( & eth_globals.devices_lock );
  267.         return ENOENT;
  268.     }
  269.     dummy = device->dummy;
  270.     rwlock_read_unlock( & eth_globals.devices_lock );
  271.     rwlock_read_lock( & eth_globals.protos_lock );
  272.     do{
  273.         next = pq_detach( packet );
  274.         proto = eth_process_packet( dummy, packet );
  275.         if( proto ){
  276.             async_msg_3( proto->phone, NET_IL_RECEIVED, device_id, packet_get_id( packet ), proto->service );
  277.         }else{
  278.             // drop invalid/unknown
  279.             pq_release( eth_globals.networking_phone, packet_get_id( packet ));
  280.         }
  281.         packet = next;
  282.     }while( packet );
  283.     rwlock_read_unlock( & eth_globals.protos_lock );
  284.     return EOK;
  285. }
  286.  
  287. int eth_packet_space_message( device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix ){
  288.     eth_device_ref  device;
  289.  
  290.     if( !( addr_len && prefix && content && suffix )) return EINVAL;
  291.     rwlock_read_lock( & eth_globals.devices_lock );
  292.     device = eth_devices_find( & eth_globals.devices, device_id );
  293.     if( ! device ){
  294.         rwlock_read_unlock( & eth_globals.devices_lock );
  295.         return ENOENT;
  296.     }
  297.     * content = device->mtu;
  298.     rwlock_read_unlock( & eth_globals.devices_lock );
  299.     * addr_len = ETH_ADDR;
  300.     * prefix = ETH_PREFIX;
  301.     * suffix = ETH_MIN_CONTENT + ETH_SUFFIX;
  302.     return EOK;
  303. }
  304.  
  305. int eth_addr_message( device_id_t device_id, eth_addr_type_t type, measured_string_ref * address ){
  306.     eth_device_ref  device;
  307.  
  308.     if( ! address ) return EINVAL;
  309.     if( type == ETH_BROADCAST_ADDR ){
  310.         * address = eth_globals.broadcast_addr;
  311.     }else{
  312.         rwlock_read_lock( & eth_globals.devices_lock );
  313.         device = eth_devices_find( & eth_globals.devices, device_id );
  314.         if( ! device ){
  315.             rwlock_read_unlock( & eth_globals.devices_lock );
  316.             return ENOENT;
  317.         }
  318.         * address = device->addr;
  319.         rwlock_read_unlock( & eth_globals.devices_lock );
  320.     }
  321.     return ( * address ) ? EOK : ENOENT;
  322. }
  323.  
  324. int nil_register_message( services_t service, int phone ){
  325.     eth_proto_ref   proto;
  326.     int             protocol;
  327.     int             index;
  328.  
  329.     protocol = protocol_map( SERVICE_ETHERNET, service );
  330.     if( ! protocol ) return ENOENT;
  331.     rwlock_write_lock( & eth_globals.protos_lock );
  332.     proto = eth_protos_find( & eth_globals.protos, protocol );
  333.     if( proto ){
  334.         proto->phone = phone;
  335.         rwlock_write_unlock( & eth_globals.protos_lock );
  336.         return EOK;
  337.     }else{
  338.         proto = ( eth_proto_ref ) malloc( sizeof( eth_proto_t ));
  339.         if( ! proto ){
  340.             rwlock_write_unlock( & eth_globals.protos_lock );
  341.             return ENOMEM;
  342.         }
  343.         proto->service = service;
  344.         proto->protocol = protocol;
  345.         proto->phone = phone;
  346.         index = eth_protos_add( & eth_globals.protos, protocol, proto );
  347.         if( index < 0 ){
  348.             rwlock_write_unlock( & eth_globals.protos_lock );
  349.             free( proto );
  350.             return index;
  351.         }
  352.     }
  353.     printf( "\nNew protocol registered:\n\tprotocol\t= 0x%x\n\tservice\t= %d\n\tphone\t= %d", proto->protocol, proto->service, proto->phone );
  354.     rwlock_write_unlock( & eth_globals.protos_lock );
  355.     return EOK;
  356. }
  357.  
  358. int eth_prepare_packet( int dummy, packet_t packet, uint8_t * src_addr, int ethertype ){
  359.     eth_header_ex_ref   header;
  360.     eth_fcs_ref         fcs;
  361.     uint8_t *           src;
  362.     uint8_t *           dest;
  363.     int                 length;
  364.     int                 i;
  365.     void *              padding;
  366.     eth_preamble_ref    preamble;
  367.  
  368.     length = packet_get_data_length( packet );
  369.     if( length > ETH_MAX_TAGGED_CONTENT ) return EINVAL;
  370.     if( length < ETH_MIN_TAGGED_CONTENT ){
  371.         padding = packet_suffix( packet, ETH_MIN_TAGGED_CONTENT - length );
  372.         if( ! padding ) return ENOMEM;
  373.         bzero( padding, ETH_MIN_TAGGED_CONTENT - length );
  374.     }
  375.     if( dummy ){
  376.         preamble = PACKET_PREFIX( packet, eth_preamble_t );
  377.         if( ! preamble ) return ENOMEM;
  378.         for( i = 0; i < 7; ++ i ) preamble->preamble[ i ] = ETH_PREAMBLE;
  379.         preamble->sfd = ETH_SFD;
  380.     }
  381.     header = PACKET_PREFIX( packet, eth_header_ex_t );
  382.     if( ! header ) return ENOMEM;
  383.     header->header.ethertype = htons( length + sizeof( eth_header_lsap_t ) + sizeof( eth_header_snap_t ));
  384.     header->lsap.dsap = ( uint16_t ) ETH_LSAP_SNAP;
  385.     header->lsap.ssap = header->lsap.dsap;
  386.     header->lsap.ctrl = 0;
  387.     for( i = 0; i < 3; ++ i ) header->snap.proto[ i ] = 0;
  388.     header->snap.ethertype = ( uint16_t ) ethertype;
  389.     length = packet_get_addr( packet, & src, & dest );
  390.     if( length < 0 ) return length;
  391.     if( length < ETH_ADDR ) return EINVAL;
  392.     memcpy( header->header.src, src_addr, ETH_ADDR );
  393.     memcpy( header->header.dest, dest, ETH_ADDR );
  394.     if( dummy ){
  395.         fcs = PACKET_SUFFIX( packet, eth_fcs_t );
  396.         if( ! fcs ) return ENOMEM;
  397.         * fcs = htonl( ~ compute_crc32( ~ 0, & header->header.dest, ((( void * ) fcs ) - (( void * ) & header->header.dest )) * 8 ));
  398.     }
  399.     return EOK;
  400. }
  401.  
  402. int eth_send_message( device_id_t device_id, packet_t packet, services_t sender ){
  403.     ERROR_DECLARE;
  404.  
  405.     eth_device_ref      device;
  406.     packet_t            next;
  407.     packet_t            tmp;
  408.     int                 ethertype;
  409.  
  410.     ethertype = htons( protocol_map( SERVICE_ETHERNET, sender ));
  411.     if( ! ethertype ){
  412.         pq_release( eth_globals.networking_phone, packet_get_id( packet ));
  413.         return EINVAL;
  414.     }
  415.     rwlock_read_lock( & eth_globals.devices_lock );
  416.     device = eth_devices_find( & eth_globals.devices, device_id );
  417.     if( ! device ){
  418.         rwlock_read_unlock( & eth_globals.devices_lock );
  419.         return ENOENT;
  420.     }
  421.     // process packet queue
  422.     next = packet;
  423.     do{
  424.         if( ERROR_OCCURRED( eth_prepare_packet( device->dummy, next, ( uint8_t * ) device->addr->value, ethertype ))){
  425.             // release invalid packet
  426.             tmp = pq_detach( next );
  427.             pq_release( eth_globals.networking_phone, packet_get_id( next ));
  428.             next = tmp;
  429.         }else{
  430.             next = pq_next( next );
  431.         }
  432.     }while( next );
  433.     // send packet queue
  434.     netif_send_msg( device->phone, device_id, packet, SERVICE_ETHERNET );
  435.     rwlock_read_unlock( & eth_globals.devices_lock );
  436.     return EOK;
  437. }
  438.  
  439. int nil_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
  440.     ERROR_DECLARE;
  441.  
  442.     measured_string_ref address;
  443.     packet_t            packet;
  444.  
  445. //  printf( "\nmessage %d - %d", IPC_GET_METHOD( * call ), NET_NIL_FIRST );
  446.     * answer_count = 0;
  447.     switch( IPC_GET_METHOD( * call )){
  448.         case IPC_M_PHONE_HUNGUP:
  449.             return EOK;
  450.         case NET_NIL_DEVICE:
  451.             return eth_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), NIL_GET_MTU( call ));
  452.         case NET_NIL_SEND:
  453.             ERROR_PROPAGATE( packet_translate( eth_globals.networking_phone, & packet, IPC_GET_PACKET( call )));
  454.             return eth_send_message( IPC_GET_DEVICE( call ), packet, IPC_GET_SERVICE( call ));
  455.         case NET_NIL_PACKET_SPACE:
  456.             ERROR_PROPAGATE( eth_packet_space_message( IPC_GET_DEVICE( call ), IPC_SET_ADDR( answer ), IPC_SET_PREFIX( answer ), IPC_SET_CONTENT( answer ), IPC_SET_SUFFIX( answer )));
  457.             * answer_count = 3;
  458.             return EOK;
  459.         case NET_NIL_ADDR:
  460.             ERROR_PROPAGATE( eth_addr_message( IPC_GET_DEVICE( call ), ETH_LOCAL_ADDR, & address ));
  461.             return measured_strings_reply( address, 1 );
  462.         case NET_NIL_BROADCAST_ADDR:
  463.             ERROR_PROPAGATE( eth_addr_message( IPC_GET_DEVICE( call ), ETH_BROADCAST_ADDR, & address ));
  464.             return measured_strings_reply( address, 1 );
  465.         case IPC_M_CONNECT_TO_ME:
  466.             return nil_register_message( NIL_GET_PROTO( call ), IPC_GET_PHONE( call ));
  467.     }
  468.     return ENOTSUP;
  469. }
  470.  
  471. void eth_receiver( ipc_callid_t iid, ipc_call_t * icall ){
  472.     ERROR_DECLARE;
  473.  
  474.     packet_t        packet;
  475.  
  476.     while( true ){
  477.         switch( IPC_GET_METHOD( * icall )){
  478.             case NET_NIL_DEVICE_STATE:
  479.                 nil_device_state_wrapper( IPC_GET_DEVICE( icall ), IPC_GET_STATE( icall ));
  480.                 ipc_answer_0( iid, EOK );
  481.                 break;
  482.             case NET_NIL_RECEIVED:
  483.                 if( ! ERROR_OCCURRED( packet_translate( eth_globals.networking_phone, & packet, IPC_GET_PACKET( icall )))){
  484.                     ERROR_CODE = nil_receive_wrapper( IPC_GET_DEVICE( icall ), packet );
  485.                 }
  486.                 ipc_answer_0( iid, ERROR_CODE );
  487.                 break;
  488.             default:
  489.                 ipc_answer_0( iid, ENOTSUP );
  490.         }
  491.         iid = async_get_call( icall );
  492.     }
  493. }
  494.  
  495. /** @}
  496.  */
  497.