Changeset 91478aa in mainline


Ignore:
Timestamp:
2010-02-17T23:20:41Z (14 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9b87284, ca2d142
Parents:
536ded4
Message:
  • unify packet dimension interfaces
Location:
uspace/srv/net
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/il/arp/arp.c

    r536ded4 r91478aa  
    337337                }
    338338                // get packet dimensions
    339                 if( ERROR_OCCURRED( nil_packet_size_req( device->phone, device_id, & device->addr_len, & device->prefix, & device->content, & device->suffix ))){
     339                if( ERROR_OCCURRED( nil_packet_size_req( device->phone, device_id, & device->packet_dimension ))){
    340340                        fibril_rwlock_write_unlock( & arp_globals.lock );
    341341                        arp_protos_destroy( & device->protos );
     
    392392        // ARP packet content size = header + ( address + translation ) * 2
    393393        length = 8 + ( CONVERT_SIZE( char, uint8_t, proto->addr->length ) + CONVERT_SIZE( char, uint8_t, device->addr->length )) * 2;
    394         if( length > device->content ) return NULL;
    395         packet = packet_get_4( arp_globals.net_phone, device->addr_len, device->prefix, length, device->suffix );
     394        if( length > device->packet_dimension.content ) return NULL;
     395        packet = packet_get_4( arp_globals.net_phone, device->packet_dimension.addr_len, device->packet_dimension.prefix, length, device->packet_dimension.suffix );
    396396        if( ! packet ) return NULL;
    397397        header = ( arp_header_ref ) packet_suffix( packet, length );
     
    472472                        memcpy( des_proto, src_proto, header->protocol_length );
    473473                        memcpy( src_proto, proto->addr->value, header->protocol_length );
    474                         memcpy( src_hw, device->addr->value, device->addr_len );
     474                        memcpy( src_hw, device->addr->value, device->packet_dimension.addr_len );
    475475                        memcpy( des_hw, hw_source->value, header->hardware_length );
    476476                        ERROR_PROPAGATE( packet_set_addr( packet, src_hw, des_hw, header->hardware_length ));
     
    511511                return ENOENT;
    512512        }
    513         device->content = mtu;
     513        device->packet_dimension.content = mtu;
    514514        printf( "arp - device %d changed mtu to %d\n\n", device_id, mtu );
    515515        fibril_rwlock_write_unlock( & arp_globals.lock );
  • uspace/srv/net/il/arp/arp.h

    r536ded4 r91478aa  
    103103         */
    104104        hw_type_t                       hardware;
    105         /** Reserved packet prefix length.
     105        /** Packet dimension.
    106106         */
    107         size_t                          prefix;
    108         /** Maximal packet content length.
    109          */
    110         size_t                          content;
    111         /** Reserved packet suffix length.
    112          */
    113         size_t                          suffix;
    114         /** Packet address length.
    115          *  The hardware address length is used.
    116          */
    117         size_t                          addr_len;
     107        packet_dimension_t      packet_dimension;
    118108        /** Actual device hardware address.
    119109         */
  • uspace/srv/net/il/ip/ip.c

    r536ded4 r91478aa  
    152152int     ip_device_state_message( device_id_t device_id, device_state_t state );
    153153
     154/** Returns the device packet dimensions for sending.
     155 *  @param[in] phone The service module phone.
     156 *  @param[in] message The service specific message.
     157 *  @param[in] device_id The device identifier.
     158 *  @param[out] addr_len The minimum reserved address length.
     159 *  @param[out] prefix The minimum reserved prefix size.
     160 *  @param[out] content The maximum content size.
     161 *  @param[out] suffix The minimum reserved suffix size.
     162 *  @returns EOK on success.
     163 */
     164int     ip_packet_size_message( device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix );
     165
    154166/** Registers the transport layer protocol.
    155167 *  The traffic of this protocol will be supplied using either the receive function or IPC message.
     
    551563        }
    552564        // get packet dimensions
    553         ERROR_PROPAGATE( nil_packet_size_req( ip_netif->phone, ip_netif->device_id, & ip_netif->addr_len, & ip_netif->prefix, & ip_netif->content, & ip_netif->suffix ));
    554         if( ip_netif->content < IP_MIN_CONTENT ){
    555                 printf( "Maximum transmission unit %d bytes is too small, at least %d bytes are needed\n", ip_netif->content, IP_MIN_CONTENT );
    556                 ip_netif->content = IP_MIN_CONTENT;
     565        ERROR_PROPAGATE( nil_packet_size_req( ip_netif->phone, ip_netif->device_id, & ip_netif->packet_dimension ));
     566        if( ip_netif->packet_dimension.content < IP_MIN_CONTENT ){
     567                printf( "Maximum transmission unit %d bytes is too small, at least %d bytes are needed\n", ip_netif->packet_dimension.content, IP_MIN_CONTENT );
     568                ip_netif->packet_dimension.content = IP_MIN_CONTENT;
    557569        }
    558570        index = ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif );
     
    577589                return ENOENT;
    578590        }
    579         netif->content = mtu;
     591        netif->packet_dimension.content = mtu;
    580592        printf( "ip - device %d changed mtu to %d\n\n", device_id, mtu );
    581593        fibril_rwlock_write_unlock( & ip_globals.netifs_lock );
     
    768780                pq_release( ip_globals.net_phone, packet_get_id( packet ));
    769781        }else{
    770                 packet = ip_split_packet( packet, netif->prefix, netif->content, netif->suffix, netif->addr_len, error );
     782                packet = ip_split_packet( packet, netif->packet_dimension.prefix, netif->packet_dimension.content, netif->packet_dimension.suffix, netif->packet_dimension.addr_len, error );
    771783                if( packet ){
    772784                        nil_send_msg( netif->phone, netif->device_id, packet, SERVICE_IP );
     
    891903                        return ERROR_CODE;
    892904                case NET_IL_PACKET_SPACE:
    893                         ERROR_PROPAGATE( ip_packet_size_req( 0, IPC_GET_DEVICE( call ), IPC_SET_ADDR( answer ), IPC_SET_PREFIX( answer ), IPC_SET_CONTENT( answer ), IPC_SET_SUFFIX( answer )));
     905                        ERROR_PROPAGATE( ip_packet_size_message( IPC_GET_DEVICE( call ), IPC_SET_ADDR( answer ), IPC_SET_PREFIX( answer ), IPC_SET_CONTENT( answer ), IPC_SET_SUFFIX( answer )));
    894906                        * answer_count = 3;
    895907                        return EOK;
     
    900912}
    901913
    902 int ip_packet_size_req( int ip_phone, device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix ){
     914int ip_packet_size_req( int ip_phone, device_id_t device_id, packet_dimension_ref packet_dimension ){
     915        if( ! packet_dimension ) return EBADMEM;
     916        return ip_packet_size_message( device_id, & packet_dimension->addr_len, & packet_dimension->prefix, & packet_dimension->content, & packet_dimension->suffix );
     917}
     918
     919int ip_packet_size_message( device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix ){
    903920        ip_netif_ref    netif;
    904921        int                             index;
     
    914931                        netif = ip_netifs_get_index( & ip_globals.netifs, index );
    915932                        if( netif ){
    916                                 if( netif->addr_len > * addr_len ) * addr_len = netif->addr_len;
    917                                 if( netif->prefix > * prefix ) * prefix = netif->prefix;
    918                                 if( netif->suffix > * suffix ) * suffix = netif->suffix;
     933                                if( netif->packet_dimension.addr_len > * addr_len ) * addr_len = netif->packet_dimension.addr_len;
     934                                if( netif->packet_dimension.prefix > * prefix ) * prefix = netif->packet_dimension.prefix;
     935                                if( netif->packet_dimension.suffix > * suffix ) * suffix = netif->packet_dimension.suffix;
    919936                        }
    920937                }
     
    927944                        return ENOENT;
    928945                }
    929                 * addr_len = ( netif->addr_len > IP_ADDR ) ? netif->addr_len : IP_ADDR;
    930                 * prefix = netif->prefix + IP_PREFIX;
    931                 * suffix = netif->suffix + IP_SUFFIX;
     946                * addr_len = ( netif->packet_dimension.addr_len > IP_ADDR ) ? netif->packet_dimension.addr_len : IP_ADDR;
     947                * prefix = netif->packet_dimension.prefix + IP_PREFIX;
     948                * suffix = netif->packet_dimension.suffix + IP_SUFFIX;
    932949        }
    933950        fibril_rwlock_read_unlock( & ip_globals.netifs_lock );
  • uspace/srv/net/il/ip/ip.h

    r536ded4 r91478aa  
    137137         */
    138138        ip_routes_t     routes;
    139         /** Reserved packet prefix length.
    140          */
    141         size_t                          prefix;
    142         /** Maximal packet content length.
    143          */
    144         size_t                          content;
    145         /** Reserved packet suffix length.
    146          */
    147         size_t                          suffix;
    148         /** Packet address length.
    149          *  The hardware address length is used.
    150          */
    151         size_t                          addr_len;
     139        /** Packet dimension.
     140         */
     141        packet_dimension_t      packet_dimension;
    152142};
    153143
  • uspace/srv/net/il/ip/ip_remote.c

    r536ded4 r91478aa  
    7272}
    7373
    74 int ip_packet_size_req( int ip_phone, device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix ){
    75         return generic_packet_size_req( ip_phone, NET_IL_PACKET_SPACE, device_id, addr_len, prefix, content, suffix );
     74int ip_packet_size_req( int ip_phone, device_id_t device_id, packet_dimension_ref packet_dimension ){
     75        return generic_packet_size_req( ip_phone, NET_IL_PACKET_SPACE, device_id, packet_dimension );
    7676}
    7777
  • uspace/srv/net/include/ip_interface.h

    r536ded4 r91478aa  
    137137int     ip_set_gateway_req( int ip_phone, device_id_t device_id, in_addr_t gateway );
    138138
    139 /** Returns the device packet dimensions for sending.
     139/** Returns the device packet dimension for sending.
    140140 *  @param[in] ip_phone The IP module phone used for (semi)remote calls.
    141141 *  @param[in] device_id The device identifier.
    142  *  @param[out] addr_len The minimum reserved address length.
    143  *  @param[out] prefix The minimum reserved prefix size.
    144  *  @param[out] content The maximum content size.
    145  *  @param[out] suffix The minimum reserved suffix size.
     142 *  @param[out] packet_dimension The packet dimension.
    146143 *  @returns EOK on success.
    147  *  @returns EBADMEM if either one of the parameters is NULL.
    148144 *  @returns ENOENT if there is no such device.
    149145 *  @returns Other error codes as defined for the generic_packet_size_req() function.
    150146 */
    151 int     ip_packet_size_req( int ip_phone, device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix );
     147int     ip_packet_size_req( int ip_phone, device_id_t device_id, packet_dimension_ref packet_dimension );
    152148
    153149/** Notifies the IP module about the received error notification packet.
  • uspace/srv/net/include/nil_interface.h

    r536ded4 r91478aa  
    9898        generic_send_msg( nil_phone, NET_NIL_SEND, device_id, packet_get_id( packet ), sender, 0 )
    9999
    100 /** Returns the device packet dimensions for sending.
     100/** Returns the device packet dimension for sending.
    101101 *  @param[in] nil_phone The network interface layer phone.
    102102 *  @param[in] device_id The device identifier.
    103  *  @param[out] addr_len The minimum reserved address length.
    104  *  @param[out] prefix The minimum reserved prefix size.
    105  *  @param[out] content The maximum content size.
    106  *  @param[out] suffix The minimum reserved suffix size.
     103 *  @param[out] packet_dimension The packet dimensions.
    107104 *  @returns EOK on success.
    108  *  @returns EBADMEM if either one of the parameters is NULL.
    109105 *  @returns ENOENT if there is no such device.
    110106 *  @returns Other error codes as defined for the generic_packet_size_req() function.
    111107 */
    112 #define nil_packet_size_req( nil_phone, device_id, addr_len, prefix, content, suffix )  \
    113         generic_packet_size_req( nil_phone, NET_NIL_PACKET_SPACE, device_id, addr_len, prefix, content, suffix )
     108#define nil_packet_size_req( nil_phone, device_id, packet_dimension )   \
     109        generic_packet_size_req( nil_phone, NET_NIL_PACKET_SPACE, device_id, packet_dimension )
    114110
    115111/** Registers new device or updates the MTU of an existing one.
  • uspace/srv/net/messages.h

    r536ded4 r91478aa  
    459459}
    460460
    461 /** Returns the device packet dimensions for sending.
    462  *  @param[in] phone The service module phone.
    463  *  @param[in] message The service specific message.
    464  *  @param[in] device_id The device identifier.
    465  *  @param[out] addr_len The minimum reserved address length.
    466  *  @param[out] prefix The minimum reserved prefix size.
    467  *  @param[out] content The maximum content size.
    468  *  @param[out] suffix The minimum reserved suffix size.
    469  *  @returns EOK on success.
     461/** Returns the device packet dimension for sending.
     462 *  @param[in] phone The service module phone.
     463 *  @param[in] message The service specific message.
     464 *  @param[in] device_id The device identifier.
     465 *  @param[out] packet_dimension The packet dimension.
     466 *  @returns EOK on success.
     467 *  @returns EBADMEM if the packet_dimension parameter is NULL.
    470468 *  @returns Other error codes as defined for the specific service message.
    471469 */
    472 static inline int       generic_packet_size_req( int phone, int message, device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix ){
    473         return ( int ) async_req_1_4( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t * ) addr_len, ( ipcarg_t * ) prefix, ( ipcarg_t * ) content, ( ipcarg_t * ) suffix );
     470static inline int       generic_packet_size_req( int phone, int message, device_id_t device_id, packet_dimension_ref packet_dimension ){
     471        ipcarg_t        result;
     472        ipcarg_t        prefix;
     473        ipcarg_t        content;
     474        ipcarg_t        suffix;
     475        ipcarg_t        addr_len;
     476
     477        if( ! packet_dimension ) return EBADMEM;
     478        result = async_req_1_4( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, & addr_len, & prefix, & content, & suffix );
     479        packet_dimension->prefix = ( size_t ) prefix;
     480        packet_dimension->content = ( size_t ) content;
     481        packet_dimension->suffix = ( size_t ) suffix;
     482        packet_dimension->addr_len = ( size_t ) addr_len;
     483        return ( int ) result;
    474484}
    475485
  • uspace/srv/net/structures/packet/packet.h

    r536ded4 r91478aa  
    5252 */
    5353typedef packet_t *              packet_ref;
     54
     55/** Type definition of the packet dimension.
     56 *  @see packet_dimension
     57 */
     58typedef struct packet_dimension packet_dimension_t;
     59
     60/** Type definition of the packet dimension pointer.
     61 *  @see packet_dimension
     62 */
     63typedef packet_dimension_t *    packet_dimension_ref;
     64
     65/** Packet dimension.
     66 */
     67struct packet_dimension{
     68        /** Reserved packet prefix length.
     69         */
     70        size_t                  prefix;
     71        /** Maximal packet content length.
     72         */
     73        size_t                  content;
     74        /** Reserved packet suffix length.
     75         */
     76        size_t                  suffix;
     77        /** Maximal packet address length.
     78         */
     79        size_t                  addr_len;
     80};
    5481
    5582/** @name Packet management system interface
  • uspace/srv/net/tl/icmp/icmp.c

    r536ded4 r91478aa  
    287287        length = ( size_t ) addrlen;
    288288        // TODO do not ask all the time
    289         ERROR_PROPAGATE( ip_packet_size_req( icmp_globals.ip_phone, -1, & icmp_globals.addr_len, & icmp_globals.prefix, & icmp_globals.content, & icmp_globals.suffix ));
    290         packet = packet_get_4( icmp_globals.net_phone, size, icmp_globals.addr_len, ICMP_HEADER_SIZE + icmp_globals.prefix, icmp_globals.suffix );
     289        ERROR_PROPAGATE( ip_packet_size_req( icmp_globals.ip_phone, -1, & icmp_globals.packet_dimension ));
     290        packet = packet_get_4( icmp_globals.net_phone, size, icmp_globals.packet_dimension.addr_len, ICMP_HEADER_SIZE + icmp_globals.packet_dimension.prefix, icmp_globals.packet_dimension.suffix );
    291291        if( ! packet ) return ENOMEM;
    292292
     
    477477                return icmp_globals.ip_phone;
    478478        }
    479         ERROR_PROPAGATE( ip_packet_size_req( icmp_globals.ip_phone, -1, & icmp_globals.addr_len, & icmp_globals.prefix, & icmp_globals.content, & icmp_globals.suffix ));
    480         icmp_globals.prefix += ICMP_HEADER_SIZE;
    481         icmp_globals.content -= ICMP_HEADER_SIZE;
     479        ERROR_PROPAGATE( ip_packet_size_req( icmp_globals.ip_phone, -1, & icmp_globals.packet_dimension ));
     480        icmp_globals.packet_dimension.prefix += ICMP_HEADER_SIZE;
     481        icmp_globals.packet_dimension.content -= ICMP_HEADER_SIZE;
    482482        // get configuration
    483483        icmp_globals.error_reporting = NET_DEFAULT_ICMP_ERROR_REPORTING;
  • uspace/srv/net/tl/icmp/icmp.h

    r536ded4 r91478aa  
    9494         */
    9595        int                             ip_phone;
    96         /** Reserved packet prefix length.
     96        /** Packet dimension.
    9797         */
    98         size_t                  prefix;
    99         /** Maximal packet content length.
    100          */
    101         size_t                  content;
    102         /** Reserved packet suffix length.
    103          */
    104         size_t                  suffix;
    105         /** Packet address length.
    106          */
    107         size_t                  addr_len;
     98        packet_dimension_t      packet_dimension;
    10899        /** Networking module phone.
    109100         */
  • uspace/srv/net/tl/tl_common.c

    r536ded4 r91478aa  
    8989                * packet_dimension = malloc( sizeof( ** packet_dimension ));
    9090                if( ! * packet_dimension ) return ENOMEM;
    91                 if( ERROR_OCCURRED( ip_packet_size_req( ip_phone, device_id, & ( ** packet_dimension ).addr_len, & ( ** packet_dimension ).prefix, & ( ** packet_dimension ).content, & ( ** packet_dimension ).suffix ))){
     91                if( ERROR_OCCURRED( ip_packet_size_req( ip_phone, device_id, * packet_dimension ))){
    9292                        free( * packet_dimension );
    9393                        return ERROR_CODE;
  • uspace/srv/net/tl/tl_common.h

    r536ded4 r91478aa  
    4343#include "../include/inet.h"
    4444#include "../include/socket_codes.h"
    45 
    46 /** Type definition of the packet dimension.
    47  *  @see packet_dimension
    48  */
    49 typedef struct packet_dimension packet_dimension_t;
    50 
    51 /** Type definition of the packet dimension pointer.
    52  *  @see packet_dimension
    53  */
    54 typedef packet_dimension_t *    packet_dimension_ref;
    55 
    56 /** Packet dimension.
    57  */
    58 struct packet_dimension{
    59         /** Reserved packet prefix length.
    60          */
    61         size_t                  prefix;
    62         /** Maximal packet content length.
    63          */
    64         size_t                  content;
    65         /** Reserved packet suffix length.
    66          */
    67         size_t                  suffix;
    68         /** Maximal packet address length.
    69          */
    70         size_t                  addr_len;
    71 };
    7245
    7346/** Device packet dimensions.
  • uspace/srv/net/tl/udp/udp.c

    r536ded4 r91478aa  
    205205        }
    206206        // read default packet dimensions
    207         ERROR_PROPAGATE( ip_packet_size_req( udp_globals.ip_phone, -1, & udp_globals.packet_dimension.addr_len, & udp_globals.packet_dimension.prefix, & udp_globals.packet_dimension.content, & udp_globals.packet_dimension.suffix ));
     207        ERROR_PROPAGATE( ip_packet_size_req( udp_globals.ip_phone, -1, & udp_globals.packet_dimension ));
    208208        ERROR_PROPAGATE( socket_ports_initialize( & udp_globals.sockets ));
    209209        if( ERROR_OCCURRED( packet_dimensions_initialize( & udp_globals.dimensions ))){
     
    579579//      }else{
    580580                // do not ask all the time
    581                 ERROR_PROPAGATE( ip_packet_size_req( udp_globals.ip_phone, -1, & udp_globals.packet_dimension.addr_len, & udp_globals.packet_dimension.prefix, & udp_globals.packet_dimension.content, & udp_globals.packet_dimension.suffix ));
     581                ERROR_PROPAGATE( ip_packet_size_req( udp_globals.ip_phone, -1, & udp_globals.packet_dimension ));
    582582                packet_dimension = & udp_globals.packet_dimension;
    583583//      }
Note: See TracChangeset for help on using the changeset viewer.