Changeset ca2d142 in mainline for uspace/srv/net/il/ip/ip.c
- Timestamp:
- 2010-02-18T10:00:30Z (14 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/il/ip/ip.c
rb8da2a3 rca2d142 152 152 int ip_device_state_message( device_id_t device_id, device_state_t state ); 153 153 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 */ 164 int ip_packet_size_message( device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix ); 165 154 166 /** Registers the transport layer protocol. 155 167 * The traffic of this protocol will be supplied using either the receive function or IPC message. … … 380 392 * @returns ENOMEM if the packet is too short to contain the IP header. 381 393 * @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. 382 395 * @returns Other error codes as defined for the packet_set_addr(). 383 396 */ … … 550 563 } 551 564 // 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; 556 569 } 557 570 index = ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif ); … … 576 589 return ENOENT; 577 590 } 578 netif-> content = mtu;591 netif->packet_dimension.content = mtu; 579 592 printf( "ip - device %d changed mtu to %d\n\n", device_id, mtu ); 580 593 fibril_rwlock_write_unlock( & ip_globals.netifs_lock ); … … 767 780 pq_release( ip_globals.net_phone, packet_get_id( packet )); 768 781 }else{ 769 packet = ip_split_packet( packet, netif->p refix, 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 ); 770 783 if( packet ){ 771 784 nil_send_msg( netif->phone, netif->device_id, packet, SERVICE_IP ); … … 890 903 return ERROR_CODE; 891 904 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 ))); 893 906 * answer_count = 3; 894 907 return EOK; … … 899 912 } 900 913 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 ){ 914 int 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 919 int ip_packet_size_message( device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix ){ 902 920 ip_netif_ref netif; 903 921 int index; … … 913 931 netif = ip_netifs_get_index( & ip_globals.netifs, index ); 914 932 if( netif ){ 915 if( netif-> addr_len > * addr_len ) * addr_len = netif->addr_len;916 if( netif->p refix > * 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; 918 936 } 919 937 } … … 926 944 return ENOENT; 927 945 } 928 * addr_len = ( netif-> addr_len > IP_ADDR ) ? netif->addr_len : IP_ADDR;929 * prefix = netif->p refix + 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; 931 949 } 932 950 fibril_rwlock_read_unlock( & ip_globals.netifs_lock ); … … 1415 1433 // only for the first fragment 1416 1434 if( IP_FRAGMENT_OFFSET( header )) return EINVAL; 1435 // not for the ICMP protocol 1436 if( header->protocol == IPPROTO_ICMP ){ 1437 return EPERM; 1438 } 1417 1439 // set the destination address 1418 1440 switch( header->version ){
Note:
See TracChangeset
for help on using the changeset viewer.