Changeset ca2d142 in mainline for uspace/srv/net/il/ip/ip.c


Ignore:
Timestamp:
2010-02-18T10:00:30Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e326edc
Parents:
b8da2a3 (diff), 91478aa (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from the networking branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 ){
Note: See TracChangeset for help on using the changeset viewer.