125,7 → 125,8 |
* Responses to the ARP request if the packet is the ARP request and is targeted to my address. |
* @param device_id The source device identifier. Input parameter. |
* @param packet The received packet. Input/output parameter. |
* @returns EOK on success. |
* @returns EOK on success and the packet is no longer needed. |
* @returns 1 on success and the packet has been reused. |
* @returns EINVAL if the packet is too small to carry the ARP packet. |
* @returns EINVAL if the received address lengths differs from the registered values. |
* @returns ENOENT if the device is not found in the cache. |
370,6 → 371,10 |
packet = packet_get_4( arp_globals.net_phone, device->addr_len, device->prefix, length, device->suffix ); |
if( ! packet ) return NULL; |
header = ( arp_header_ref ) packet_suffix( packet, length ); |
if( ! header ){ |
pq_release( packet ); |
return NULL; |
} |
header->hardware = htons( device->hardware ); |
header->hardware_length = device->addr->length; |
header->protocol = htons( protocol_map( device->service, protocol )); |
383,7 → 388,10 |
bzero((( uint8_t * ) header ) + length, device->addr->length ); |
length += device->addr->length; |
memcpy((( uint8_t * ) header ) + length, target->value, target->length ); |
packet_set_addr( packet, ( uint8_t * ) device->addr->value, ( uint8_t * ) device->broadcast_addr->value, CONVERT_SIZE( char, uint8_t, device->addr->length )); |
if( packet_set_addr( packet, ( uint8_t * ) device->addr->value, ( uint8_t * ) device->broadcast_addr->value, CONVERT_SIZE( char, uint8_t, device->addr->length )) != EOK ){ |
pq_release( packet ); |
return NULL; |
} |
nil_send_msg( device->phone, device_id, packet, SERVICE_ARP ); |
return NULL; |
} |
441,10 → 449,9 |
memcpy( src_proto, proto->addr->value, header->protocol_length ); |
memcpy( src_hw, device->addr->value, device->addr_len ); |
memcpy( des_hw, hw_source->value, header->hardware_length ); |
packet_set_addr( packet, src_hw, des_hw, header->hardware_length ); |
ERROR_PROPAGATE( packet_set_addr( packet, src_hw, des_hw, header->hardware_length )); |
nil_send_msg( device->phone, device_id, packet, SERVICE_ARP ); |
}else{ |
pq_release( arp_globals.net_phone, packet_get_id( packet )); |
return 1; |
} |
} |
return EOK; |
476,6 → 483,7 |
measured_string_ref translation; |
char * data; |
packet_t packet; |
packet_t next; |
|
// printf( "message %d - %d\n", IPC_GET_METHOD( * call ), NET_ARP_FIRST ); |
* answer_count = 0; |
512,7 → 520,13 |
case NET_IL_RECEIVED: |
if( ! ERROR_OCCURRED( packet_translate( arp_globals.net_phone, & packet, IPC_GET_PACKET( call )))){ |
rwlock_read_lock( & arp_globals.lock ); |
ERROR_CODE = arp_receive_message( IPC_GET_DEVICE( call ), packet ); |
do{ |
next = pq_next( packet ); |
packet_detach( packet ); |
ERROR_CODE = arp_receive_message( IPC_GET_DEVICE( call ), packet ); |
if( ERROR_CODE != 1 ) pq_release( arp_globals.net_phone, packet_get_id( packet )); |
packet = next; |
}while( packet ); |
rwlock_read_unlock( & arp_globals.lock ); |
} |
return ERROR_CODE; |