Changes in / [b8da2a3:ca2d142] in mainline


Ignore:
Location:
uspace/srv/net
Files:
18 edited

Legend:

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

    rb8da2a3 rca2d142  
    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

    rb8da2a3 rca2d142  
    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

    rb8da2a3 rca2d142  
    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.
     
    380392 *  @returns ENOMEM if the packet is too short to contain the IP header.
    381393 *  @returns EAFNOSUPPORT if the address family is not supported.
     394 *  @returns EPERM if the protocol is not allowed to send ICMP notifications. The ICMP protocol itself.
    382395 *  @returns Other error codes as defined for the packet_set_addr().
    383396 */
     
    550563        }
    551564        // get packet dimensions
    552         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 ));
    553         if( ip_netif->content < IP_MIN_CONTENT ){
    554                 printf( "Maximum transmission unit %d bytes is too small, at least %d bytes are needed\n", ip_netif->content, IP_MIN_CONTENT );
    555                 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;
    556569        }
    557570        index = ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif );
     
    576589                return ENOENT;
    577590        }
    578         netif->content = mtu;
     591        netif->packet_dimension.content = mtu;
    579592        printf( "ip - device %d changed mtu to %d\n\n", device_id, mtu );
    580593        fibril_rwlock_write_unlock( & ip_globals.netifs_lock );
     
    767780                pq_release( ip_globals.net_phone, packet_get_id( packet ));
    768781        }else{
    769                 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 );
    770783                if( packet ){
    771784                        nil_send_msg( netif->phone, netif->device_id, packet, SERVICE_IP );
     
    890903                        return ERROR_CODE;
    891904                case NET_IL_PACKET_SPACE:
    892                         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 )));
    893906                        * answer_count = 3;
    894907                        return EOK;
     
    899912}
    900913
    901 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 ){
    902920        ip_netif_ref    netif;
    903921        int                             index;
     
    913931                        netif = ip_netifs_get_index( & ip_globals.netifs, index );
    914932                        if( netif ){
    915                                 if( netif->addr_len > * addr_len ) * addr_len = netif->addr_len;
    916                                 if( netif->prefix > * prefix ) * prefix = netif->prefix;
    917                                 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;
    918936                        }
    919937                }
     
    926944                        return ENOENT;
    927945                }
    928                 * addr_len = ( netif->addr_len > IP_ADDR ) ? netif->addr_len : IP_ADDR;
    929                 * prefix = netif->prefix + IP_PREFIX;
    930                 * 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;
    931949        }
    932950        fibril_rwlock_read_unlock( & ip_globals.netifs_lock );
     
    14151433        // only for the first fragment
    14161434        if( IP_FRAGMENT_OFFSET( header )) return EINVAL;
     1435        // not for the ICMP protocol
     1436        if( header->protocol == IPPROTO_ICMP ){
     1437                return EPERM;
     1438        }
    14171439        // set the destination address
    14181440        switch( header->version ){
  • uspace/srv/net/il/ip/ip.h

    rb8da2a3 rca2d142  
    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

    rb8da2a3 rca2d142  
    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

    rb8da2a3 rca2d142  
    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

    rb8da2a3 rca2d142  
    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

    rb8da2a3 rca2d142  
    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/netif/dp8390/dp8390.c

    rb8da2a3 rca2d142  
    350350                tmp = pq_next( tmp );
    351351        }
    352         if( ! pq_add( tmp, packet, 0, 0 )){
     352        if( pq_add( & tmp, packet, 0, 0 ) != EOK ){
    353353                return EINVAL;
    354354        }
     
    10061006        int last, count;
    10071007        packet_t        packet;
    1008         packet_t        queue;
    10091008
    10101009//      if (!(dep->de_flags & DEF_READING))
     
    10451044                return ELIMIT;
    10461045        }else{
    1047                 queue = pq_add( dep->received_queue, packet, 0, 0 );
    1048                 if( queue ){
    1049                         dep->received_queue = queue;
     1046                if( pq_add( & dep->received_queue, packet, 0, 0 ) == EOK ){
    10501047                        ++ dep->received_count;
    10511048                }else{
  • uspace/srv/net/structures/packet/packet.c

    rb8da2a3 rca2d142  
    184184}
    185185
    186 packet_t pq_add( packet_t first, packet_t packet, size_t order, size_t metric ){
     186int pq_add( packet_t * first, packet_t packet, size_t order, size_t metric ){
    187187        packet_t        item;
    188188
    189         if( ! packet_is_valid( packet )) return NULL;
     189        if(( ! first ) || ( ! packet_is_valid( packet ))) return EINVAL;
    190190        pq_set_order( packet, order, metric );
    191         if( packet_is_valid( first )){
    192                 item = first;
     191        if( packet_is_valid( * first )){
     192                item = * first;
    193193                do{
    194194                        if( item->order < order ){
     
    198198                                        item->next = packet->packet_id;
    199199                                        packet->previous = item->packet_id;
    200                                         return first;
     200                                        return EOK;
    201201                                }
    202202                        }else{
     
    205205                                item->previous = packet->packet_id;
    206206                                item = pm_find( packet->previous );
    207                                 if( item ) item->next = packet->packet_id;
    208                                 return item ? first : packet;
     207                                if( item ){
     208                                        item->next = packet->packet_id;
     209                                }else{
     210                                        * first = packet;
     211                                }
     212                                return EOK;
    209213                        }
    210214                }while( packet_is_valid( item ));
    211215        }
    212         return packet;
     216        * first = packet;
     217        return EOK;
    213218}
    214219
  • uspace/srv/net/structures/packet/packet.h

    rb8da2a3 rca2d142  
    5353typedef packet_t *              packet_ref;
    5454
     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};
     81
    5582/** @name Packet management system interface
    5683 */
     
    86113 *  The queue is sorted in the ascending order.
    87114 *  The packet is inserted right before the packets of the same order value.
    88  *  @param[in] first The first packet of the queue. May be NULL.
     115 *  @param[in,out] first The first packet of the queue. Sets the first packet of the queue. The original first packet may be shifted by the new packet.
    89116 *  @param[in] packet The packet to be added.
    90117 *  @param[in] order The packet order value.
    91118 *  @param[in] metric The metric value of the packet.
    92  *  @returns The first packet of the queue. The original first packet may be shifted by the new packet.
    93  *  @returns NULL if the packet is not valid.
     119 *  @returns EOK on success.
     120 *  @returns EINVAL if the first parameter is NULL.
     121 *  @returns EINVAL if the packet is not valid.
    94122 */
    95 packet_t        pq_add( packet_t first, packet_t packet, size_t order, size_t metric );
     123int     pq_add( packet_t * first, packet_t packet, size_t order, size_t metric );
    96124
    97125/** Finds the packet with the given order.
  • uspace/srv/net/structures/packet/packet_server.c

    rb8da2a3 rca2d142  
    229229void packet_release( packet_t packet ){
    230230        int index;
     231        int result;
    231232
    232233        // remove debug dump
    233234//      printf( "packet %d released\n", packet->packet_id );
    234235        for( index = 0; ( index < FREE_QUEUES_COUNT - 1 ) && ( packet->length > ps_globals.sizes[ index ] ); ++ index );
    235         ps_globals.free[ index ] = pq_add( ps_globals.free[ index ], packet, packet->length, packet->length );
    236         assert( ps_globals.free[ index ] );
     236        result = pq_add( & ps_globals.free[ index ], packet, packet->length, packet->length );
     237        assert( result == EOK );
    237238}
    238239
  • uspace/srv/net/tl/icmp/icmp.c

    rb8da2a3 rca2d142  
    115115#define ICMP_GET_REPLY_KEY( id, sequence )      ((( id ) << 16 ) | ( sequence & 0xFFFF ))
    116116
    117 /** Type definition of the ICMP reply timeout.
    118  *  @see icmp_reply_timeout
    119  */
    120 typedef struct icmp_reply_timeout       icmp_reply_timeout_t;
    121 
    122 /** Type definition of the ICMP reply timeout pointer.
    123  *  @see icmp_reply_timeout
    124  */
    125 typedef icmp_reply_timeout_t *  icmp_reply_timeout_ref;
    126 
    127 /** ICMP reply timeout data.
    128  *  Used as a timeouting fibril argument.
    129  *  @see icmp_timeout_for_reply()
    130  */
    131 struct icmp_reply_timeout{
    132         /** Reply data key.
    133          */
    134         int                     reply_key;
    135         /** Timeout in microseconds.
    136          */
    137         suseconds_t     timeout;
    138 };
    139 
    140117/** Processes the received ICMP packet.
    141118 *  Is used as an entry point from the underlying IP module.
     
    255232int     icmp_process_echo_reply( packet_t packet, icmp_header_ref header, icmp_type_t type, icmp_code_t code );
    256233
    257 /** Tries to set the pending reply result as timeouted.
    258  *  Sleeps the timeout period of time and then tries to obtain and set the pending reply result as timeouted and signals the reply result.
    259  *  If the reply data are still present, the reply timeouted and the parent fibril is awaken.
    260  *  The global lock is not released in this case to be reused by the parent fibril.
    261  *  Should run in a searate fibril.
    262  *  @param[in] data The icmp_reply_timeout structure.
    263  *  @returns EOK on success.
    264  *  @returns EINVAL if the data parameter is NULL.
    265  */
    266 int     icmp_timeout_for_reply( void * data );
    267 
    268234/** Assigns a new identifier for the connection.
    269235 *  Fills the echo data parameter with the assigned values.
     
    304270}
    305271
    306 int icmp_timeout_for_reply( void * data ){
    307         icmp_reply_ref                  reply;
    308         icmp_reply_timeout_ref  timeout = data;
    309 
    310         if( ! timeout ){
    311                 return EINVAL;
    312         }
    313         // sleep the given timeout
    314         async_usleep( timeout->timeout );
    315         // lock the globals
    316         fibril_rwlock_write_lock( & icmp_globals.lock );
    317         // find the pending reply
    318         reply = icmp_replies_find( & icmp_globals.replies, timeout->reply_key );
    319         if( reply ){
    320                 // set the timeout result
    321                 reply->result = ETIMEOUT;
    322                 // notify the main fibril
    323                 fibril_condvar_signal( & reply->condvar );
    324         }else{
    325                 // unlock only if no reply
    326                 fibril_rwlock_write_unlock( & icmp_globals.lock );
    327         }
    328         // release the timeout structure
    329         free( timeout );
    330         return EOK;
    331 }
    332 
    333272int icmp_echo( icmp_param_t id, icmp_param_t sequence, size_t size, mseconds_t timeout, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, const struct sockaddr * addr, socklen_t addrlen ){
    334273        ERROR_DECLARE;
     
    339278        uint8_t *               data;
    340279        icmp_reply_ref                  reply;
    341         icmp_reply_timeout_ref  reply_timeout;
     280        int                             reply_key;
    342281        int                             result;
    343282        int                             index;
    344         fid_t                   fibril;
    345283
    346284        if( addrlen <= 0 ){
     
    349287        length = ( size_t ) addrlen;
    350288        // TODO do not ask all the time
    351         ERROR_PROPAGATE( ip_packet_size_req( icmp_globals.ip_phone, -1, & icmp_globals.addr_len, & icmp_globals.prefix, & icmp_globals.content, & icmp_globals.suffix ));
    352         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 );
    353291        if( ! packet ) return ENOMEM;
    354292
     
    379317        header->un.echo.sequence_number = sequence;
    380318
    381         // prepare the reply and the reply timeout structures
    382         reply_timeout = malloc( sizeof( * reply_timeout ));
    383         if( ! reply_timeout ){
    384                 return icmp_release_and_return( packet, ENOMEM );
    385         }
     319        // prepare the reply structure
    386320        reply = malloc( sizeof( * reply ));
    387321        if( ! reply ){
    388                 free( reply_timeout );
    389322                return icmp_release_and_return( packet, ENOMEM );
    390323        }
    391         // prepare the timeouting thread
    392         fibril = fibril_create( icmp_timeout_for_reply, reply_timeout );
    393         if( ! fibril ){
    394                 free( reply );
    395                 free( reply_timeout );
    396                 return icmp_release_and_return( packet, EPARTY );
    397         }
    398         reply_timeout->reply_key = ICMP_GET_REPLY_KEY( header->un.echo.identifier, header->un.echo.sequence_number );
    399         // timeout in microseconds
    400         reply_timeout->timeout = timeout * 1000;
    401324        fibril_mutex_initialize( & reply->mutex );
    402325        fibril_mutex_lock( & reply->mutex );
    403326        fibril_condvar_initialize( & reply->condvar );
    404         // start the timeouting fibril
    405         fibril_add_ready( fibril );
    406         index = icmp_replies_add( & icmp_globals.replies, reply_timeout->reply_key, reply );
     327        reply_key = ICMP_GET_REPLY_KEY( header->un.echo.identifier, header->un.echo.sequence_number );
     328        index = icmp_replies_add( & icmp_globals.replies, reply_key, reply );
    407329        if( index < 0 ){
    408330                free( reply );
     
    417339
    418340        // wait for a reply
    419         fibril_condvar_wait( & reply->condvar, & reply->mutex );
    420 
    421         // read the result
    422         result = reply->result;
     341        // timeout in microseconds
     342        if( ERROR_OCCURRED( fibril_condvar_wait_timeout( & reply->condvar, & reply->mutex, timeout * 1000 ))){
     343                result = ERROR_CODE;
     344
     345                // lock the globals again and clean up
     346                fibril_rwlock_write_lock( & icmp_globals.lock );
     347        }else{
     348                // read the result
     349                result = reply->result;
     350
     351                // release the reply structure
     352                fibril_mutex_unlock( & reply->mutex );
     353        }
    423354
    424355        // destroy the reply structure
    425         fibril_mutex_unlock( & reply->mutex );
    426356        icmp_replies_exclude_index( & icmp_globals.replies, index );
    427357        return result;
     
    547477                return icmp_globals.ip_phone;
    548478        }
    549         ERROR_PROPAGATE( ip_packet_size_req( icmp_globals.ip_phone, -1, & icmp_globals.addr_len, & icmp_globals.prefix, & icmp_globals.content, & icmp_globals.suffix ));
    550         icmp_globals.prefix += ICMP_HEADER_SIZE;
    551         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;
    552482        // get configuration
    553483        icmp_globals.error_reporting = NET_DEFAULT_ICMP_ERROR_REPORTING;
  • uspace/srv/net/tl/icmp/icmp.h

    rb8da2a3 rca2d142  
    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/tcp/tcp.c

    rb8da2a3 rca2d142  
    613613                next_packet = pq_detach( packet );
    614614                length = packet_get_data_length( packet );
    615                 tmp_packet = pq_add( socket_data->incoming, packet, new_sequence_number, length );
    616                 if( ! tmp_packet ){
     615                if( ERROR_OCCURRED( pq_add( & socket_data->incoming, packet, new_sequence_number, length ))){
    617616                        // remove the corrupted packets
    618617                        pq_release( tcp_globals.net_phone, packet_get_id( packet ));
    619618                        pq_release( tcp_globals.net_phone, packet_get_id( next_packet ));
    620619                }else{
    621                         socket_data->incoming = tmp_packet;
    622620                        while( next_packet ){
    623621                                new_sequence_number += length;
     
    939937        packet_t        next;
    940938        packet_t        acknowledged = NULL;
    941         packet_t        first;
    942939        uint32_t        old;
    943940
     
    981978                                        }
    982979                                        // add to acknowledged or release
    983                                         first = pq_add( acknowledged, packet, 0, 0 );
    984                                         if( first ){
    985                                                 acknowledged = first;
    986                                         }else{
     980                                        if( pq_add( & acknowledged, packet, 0, 0 ) != EOK ){
    987981                                                pq_release( tcp_globals.net_phone, packet_get_id( packet ));
    988982                                        }
     
    15081502int     tcp_queue_packet( socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length ){
    15091503        ERROR_DECLARE;
    1510         packet_t                first;
    15111504
    15121505        assert( socket );
     
    15161509        ERROR_PROPAGATE( tcp_queue_prepare_packet( socket, socket_data, packet, data_length ));
    15171510
    1518         first = pq_add( socket_data->outgoing, packet, socket_data->next_outgoing, data_length );
    1519         if( ! first ){
    1520                 return tcp_release_and_return( packet, EINVAL );
    1521         }
    1522         socket_data->outgoing = first;
     1511        if( ERROR_OCCURRED( pq_add( & socket_data->outgoing, packet, socket_data->next_outgoing, data_length ))){
     1512                return tcp_release_and_return( packet, ERROR_CODE );
     1513        }
    15231514        socket_data->next_outgoing += data_length;
    15241515        return EOK;
  • uspace/srv/net/tl/tl_common.c

    rb8da2a3 rca2d142  
    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

    rb8da2a3 rca2d142  
    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

    rb8da2a3 rca2d142  
    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//      }
     
    604604                        return udp_release_and_return( packet, result );
    605605                }
    606                 packet = pq_add( packet, next_packet, index, 0 );
     606                if( ERROR_OCCURRED( pq_add( & packet, next_packet, index, 0 ))){
     607                        return udp_release_and_return( packet, ERROR_CODE );
     608                }
    607609                total_length += ( size_t ) result;
    608610                if( udp_globals.checksum_computing ){
Note: See TracChangeset for help on using the changeset viewer.