Changeset 91478aa in mainline
- Timestamp:
- 2010-02-17T23:20:41Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9b87284, ca2d142
- Parents:
- 536ded4
- Location:
- uspace/srv/net
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/il/arp/arp.c
r536ded4 r91478aa 337 337 } 338 338 // 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 ))){ 340 340 fibril_rwlock_write_unlock( & arp_globals.lock ); 341 341 arp_protos_destroy( & device->protos ); … … 392 392 // ARP packet content size = header + ( address + translation ) * 2 393 393 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 ); 396 396 if( ! packet ) return NULL; 397 397 header = ( arp_header_ref ) packet_suffix( packet, length ); … … 472 472 memcpy( des_proto, src_proto, header->protocol_length ); 473 473 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 ); 475 475 memcpy( des_hw, hw_source->value, header->hardware_length ); 476 476 ERROR_PROPAGATE( packet_set_addr( packet, src_hw, des_hw, header->hardware_length )); … … 511 511 return ENOENT; 512 512 } 513 device-> content = mtu;513 device->packet_dimension.content = mtu; 514 514 printf( "arp - device %d changed mtu to %d\n\n", device_id, mtu ); 515 515 fibril_rwlock_write_unlock( & arp_globals.lock ); -
uspace/srv/net/il/arp/arp.h
r536ded4 r91478aa 103 103 */ 104 104 hw_type_t hardware; 105 /** Reserved packet prefix length.105 /** Packet dimension. 106 106 */ 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; 118 108 /** Actual device hardware address. 119 109 */ -
uspace/srv/net/il/ip/ip.c
r536ded4 r91478aa 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. … … 551 563 } 552 564 // 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; 557 569 } 558 570 index = ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif ); … … 577 589 return ENOENT; 578 590 } 579 netif-> content = mtu;591 netif->packet_dimension.content = mtu; 580 592 printf( "ip - device %d changed mtu to %d\n\n", device_id, mtu ); 581 593 fibril_rwlock_write_unlock( & ip_globals.netifs_lock ); … … 768 780 pq_release( ip_globals.net_phone, packet_get_id( packet )); 769 781 }else{ 770 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 ); 771 783 if( packet ){ 772 784 nil_send_msg( netif->phone, netif->device_id, packet, SERVICE_IP ); … … 891 903 return ERROR_CODE; 892 904 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 ))); 894 906 * answer_count = 3; 895 907 return EOK; … … 900 912 } 901 913 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 ){ 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 ){ 903 920 ip_netif_ref netif; 904 921 int index; … … 914 931 netif = ip_netifs_get_index( & ip_globals.netifs, index ); 915 932 if( netif ){ 916 if( netif-> addr_len > * addr_len ) * addr_len = netif->addr_len;917 if( netif->p refix > * 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; 919 936 } 920 937 } … … 927 944 return ENOENT; 928 945 } 929 * addr_len = ( netif-> addr_len > IP_ADDR ) ? netif->addr_len : IP_ADDR;930 * prefix = netif->p refix + 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; 932 949 } 933 950 fibril_rwlock_read_unlock( & ip_globals.netifs_lock ); -
uspace/srv/net/il/ip/ip.h
r536ded4 r91478aa 137 137 */ 138 138 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; 152 142 }; 153 143 -
uspace/srv/net/il/ip/ip_remote.c
r536ded4 r91478aa 72 72 } 73 73 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);74 int 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 ); 76 76 } 77 77 -
uspace/srv/net/include/ip_interface.h
r536ded4 r91478aa 137 137 int ip_set_gateway_req( int ip_phone, device_id_t device_id, in_addr_t gateway ); 138 138 139 /** Returns the device packet dimension sfor sending.139 /** Returns the device packet dimension for sending. 140 140 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 141 141 * @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. 146 143 * @returns EOK on success. 147 * @returns EBADMEM if either one of the parameters is NULL.148 144 * @returns ENOENT if there is no such device. 149 145 * @returns Other error codes as defined for the generic_packet_size_req() function. 150 146 */ 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);147 int ip_packet_size_req( int ip_phone, device_id_t device_id, packet_dimension_ref packet_dimension ); 152 148 153 149 /** Notifies the IP module about the received error notification packet. -
uspace/srv/net/include/nil_interface.h
r536ded4 r91478aa 98 98 generic_send_msg( nil_phone, NET_NIL_SEND, device_id, packet_get_id( packet ), sender, 0 ) 99 99 100 /** Returns the device packet dimension sfor sending.100 /** Returns the device packet dimension for sending. 101 101 * @param[in] nil_phone The network interface layer phone. 102 102 * @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. 107 104 * @returns EOK on success. 108 * @returns EBADMEM if either one of the parameters is NULL.109 105 * @returns ENOENT if there is no such device. 110 106 * @returns Other error codes as defined for the generic_packet_size_req() function. 111 107 */ 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 ) 114 110 115 111 /** Registers new device or updates the MTU of an existing one. -
uspace/srv/net/messages.h
r536ded4 r91478aa 459 459 } 460 460 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. 470 468 * @returns Other error codes as defined for the specific service message. 471 469 */ 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 ); 470 static 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; 474 484 } 475 485 -
uspace/srv/net/structures/packet/packet.h
r536ded4 r91478aa 52 52 */ 53 53 typedef packet_t * packet_ref; 54 55 /** Type definition of the packet dimension. 56 * @see packet_dimension 57 */ 58 typedef struct packet_dimension packet_dimension_t; 59 60 /** Type definition of the packet dimension pointer. 61 * @see packet_dimension 62 */ 63 typedef packet_dimension_t * packet_dimension_ref; 64 65 /** Packet dimension. 66 */ 67 struct 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 }; 54 81 55 82 /** @name Packet management system interface -
uspace/srv/net/tl/icmp/icmp.c
r536ded4 r91478aa 287 287 length = ( size_t ) addrlen; 288 288 // 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 ); 291 291 if( ! packet ) return ENOMEM; 292 292 … … 477 477 return icmp_globals.ip_phone; 478 478 } 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.p refix += 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; 482 482 // get configuration 483 483 icmp_globals.error_reporting = NET_DEFAULT_ICMP_ERROR_REPORTING; -
uspace/srv/net/tl/icmp/icmp.h
r536ded4 r91478aa 94 94 */ 95 95 int ip_phone; 96 /** Reserved packet prefix length.96 /** Packet dimension. 97 97 */ 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; 108 99 /** Networking module phone. 109 100 */ -
uspace/srv/net/tl/tl_common.c
r536ded4 r91478aa 89 89 * packet_dimension = malloc( sizeof( ** packet_dimension )); 90 90 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 ))){ 92 92 free( * packet_dimension ); 93 93 return ERROR_CODE; -
uspace/srv/net/tl/tl_common.h
r536ded4 r91478aa 43 43 #include "../include/inet.h" 44 44 #include "../include/socket_codes.h" 45 46 /** Type definition of the packet dimension.47 * @see packet_dimension48 */49 typedef struct packet_dimension packet_dimension_t;50 51 /** Type definition of the packet dimension pointer.52 * @see packet_dimension53 */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 };72 45 73 46 /** Device packet dimensions. -
uspace/srv/net/tl/udp/udp.c
r536ded4 r91478aa 205 205 } 206 206 // 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 )); 208 208 ERROR_PROPAGATE( socket_ports_initialize( & udp_globals.sockets )); 209 209 if( ERROR_OCCURRED( packet_dimensions_initialize( & udp_globals.dimensions ))){ … … 579 579 // }else{ 580 580 // 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 )); 582 582 packet_dimension = & udp_globals.packet_dimension; 583 583 // }
Note:
See TracChangeset
for help on using the changeset viewer.