Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4701 → Rev 4702

/branches/network/uspace/srv/net/il/arp/arp.c
81,6 → 81,15
*/
int arp_proto_create( arp_proto_ref * proto, services_t service, measured_string_ref address );
 
/** Clears the device specific data.
* @param device The device specific data.
*/
void clear_device( arp_device_ref device );
 
/** @name Message processing functions
*/
/*@{*/
 
/** Registers the device.
* Creates new device entry in the cache or updates the protocol address if the device with the device identifier and the driver service exists.
* @param device_id The device identifier. Input parameter.
114,7 → 123,7
* @param packet The received packet. Input/output parameter.
* @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 packet is too small to carry an 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.
* @returns ENOENT if the protocol for the device is not found in the cache.
122,18 → 131,16
*/
int arp_receive_message( device_id_t device_id, packet_t packet );
 
/** Clears the device specific data.
* @param device The device specific data.
*/
void clear_device( arp_device_ref device );
 
/** Updates the device content length according to the new MTU value.
* @param device_id The device identifier. Input parameter.
* @param mtu The new mtu value. Input parameter.
* @returns ENOENT if device is not found.
* @returns EOK on success.
*/
int arp_mtu_changed_msg( device_id_t device_id, size_t mtu );
int arp_mtu_changed_message( device_id_t device_id, size_t mtu );
 
/*@}*/
 
DEVICE_MAP_IMPLEMENT( arp_cache, arp_device_t )
 
INT_MAP_IMPLEMENT( arp_protos, arp_proto_t )
492,7 → 499,7
return EOK;
}
 
int arp_mtu_changed_msg( device_id_t device_id, size_t mtu ){
int arp_mtu_changed_message( device_id_t device_id, size_t mtu ){
arp_device_ref device;
 
fibril_rwlock_write_lock( & arp_globals.lock );
567,7 → 574,7
}
return ERROR_CODE;
case NET_IL_MTU_CHANGED:
return arp_mtu_changed_msg( IPC_GET_DEVICE( call ), IPC_GET_MTU( call ));
return arp_mtu_changed_message( IPC_GET_DEVICE( call ), IPC_GET_MTU( call ));
}
return ENOTSUP;
}
/branches/network/uspace/srv/net/il/ip/ip.c
31,6 → 31,9
*/
 
/** @file
* IP module implementation.
* @see arp.h
* \todo
*/
 
#include <async.h>
73,24 → 76,65
#include "ip_messages.h"
#include "ip_module.h"
 
/** Default IP version.
*/
#define DEFAULT_IPV 4
 
/** Minimum IP packet content.
*/
#define IP_MIN_CONTENT 576
 
/** ARP module name.
*/
#define ARP_NAME "arp"
 
/** ARP module filename.
*/
#define ARP_FILENAME "/srv/arp"
 
/** IP packet address length.
*/
#define IP_ADDR sizeof( in_addr_t )
 
/** IP packet prefix length.
*/
#define IP_PREFIX sizeof( ip_header_t )
 
/** IP packet suffix length.
*/
#define IP_SUFFIX 0
 
/** IP packet maximum content length.
*/
#define IP_MAX_CONTENT 65535
 
/** Returns the actual IP header length.
* @param header The IP packet header. Input parameter.
*/
#define IP_HEADER_LENGTH( header ) (( header )->ihl * 4u )
 
/** Returns the actual IP packet total length.
* @param header The IP packet header. Input parameter.
*/
#define IP_TOTAL_LENGTH( header ) ntohs(( header )->total_length )
 
/** Returns the actual IP packet data length.
* @param header The IP packet header. Input parameter.
*/
#define IP_HEADER_DATA_LENGTH( header ) ( IP_TOTAL_LENGTH( header ) - IP_HEADER_LENGTH( header ))
 
/** Returns the IP packet header checksum.
* @param header The IP packet header. Input parameter.
*/
#define IP_HEADER_CHECKSUM( header ) ( htons( ip_checksum(( uint8_t * )( header ), IP_HEADER_LENGTH( header ))))
 
//zero is returned as 0xFFFF (not flipped)
/** IP header checksum value for computed zero checksum.
* Zero is returned as 0xFFFF (not flipped)
*/
#define IP_HEADER_CHECKSUM_ZERO 0xFFFFu
 
/** IP global data.
*/
ip_globals_t ip_globals;
 
DEVICE_MAP_IMPLEMENT( ip_netifs, ip_netif_t )
99,9 → 143,39
 
GENERIC_FIELD_IMPLEMENT( ip_routes, ip_route_t )
 
int ip_mtu_changed_msg( device_id_t device_id, size_t mtu );
int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state );
/** Updates the device content length according to the new MTU value.
* @param device_id The device identifier. Input parameter.
* @param mtu The new mtu value. Input parameter.
* @returns EOK on success.
* @returns ENOENT if device is not found.
*/
int ip_mtu_changed_message( device_id_t device_id, size_t mtu );
 
/** Updates the device state.
* @param device_id The device identifier. Input parameter.
* @param state The new state value. Input parameter.
* @returns EOK on success.
* @returns ENOENT if device is not found.
*/
int ip_device_state_message( device_id_t device_id, device_state_t state );
 
int ip_register( int protocol, services_t service, int phone, tl_received_msg_t tl_received_msg );
 
/** Initializes a new network interface specific data.
* Connects to the network interface layer module, reads the netif configuration, starts an ARP module if needed and sets the netif routing table.
* The device identifier and the nil service has to be set.
* @param ip_netif Network interface specific data. Input/output parameter.
* @returns EOK on success.
* @returns ENOTSUP if DHCP is configured.
* @returns ENOTSUP if IPv6 is configured.
* @returns EINVAL if any of the addresses is invalid.
* @returns EINVAL if the used ARP module is not known.
* @returns ENOMEM if there is not enough memory left.
* @returns Other error codes as defined for the net_get_device_conf_req() function.
* @returns Other error codes as defined for the bind_service() function.
* @returns Other error codes as defined for the specific arp_device_req() function.
* @returns Other error codes as defined for the nil_packet_size_req() function.
*/
int ip_netif_initialize( ip_netif_ref ip_netif );
 
int ip_send_route( packet_t packet, ip_netif_ref netif, ip_route_ref route, in_addr_t * src, in_addr_t dest );
117,7 → 191,18
ip_route_ref ip_find_route( in_addr_t destination );
ip_route_ref ip_netif_find_route( ip_netif_ref netif, in_addr_t destination );
 
int ip_received_msg( device_id_t device_id, packet_t packet );
/** Processes the received IP packet.
* @param device_id The source device identifier. Input parameter.
* @param packet The received packet. Input/output parameter.
* @returns EOK on success and the packet is no longer needed.
* @returns EINVAL if the packet is too small to carry the IP packet.
* @returns EINVAL if the received address lengths differs from the registered values.
* @returns ENOENT if the device is not found in the cache.
* @returns ENOENT if the protocol for the device is not found in the cache.
* @returns ENOMEM if there is not enough memory left.
*/
int ip_receive_message( device_id_t device_id, packet_t packet );
 
int ip_process_packet( device_id_t device_id, packet_t packet );
in_addr_t ip_get_destination( ip_header_ref header );
int ip_deliver_local( device_id_t device_id, packet_t packet, ip_header_ref header );
142,8 → 227,6
return ( ~ checksum ) ? ~ checksum : IP_HEADER_CHECKSUM_ZERO;
}
 
/** Initializes the module.
*/
int ip_initialize( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
231,7 → 314,7
ip_route_ref route;
in_addr_t gateway;
 
ip_netif->arp = 0;
ip_netif->arp = NULL;
route = NULL;
configuration = & names[ 0 ];
// get configuration
323,7 → 406,7
return EOK;
}
 
int ip_mtu_changed_msg( device_id_t device_id, size_t mtu ){
int ip_mtu_changed_message( device_id_t device_id, size_t mtu ){
ip_netif_ref netif;
 
fibril_rwlock_write_lock( & ip_globals.netifs_lock );
338,7 → 421,7
return EOK;
}
 
int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state ){
int ip_device_state_message( device_id_t device_id, device_state_t state ){
// ERROR_DECLARE;
 
/* measured_string_t address;
618,10 → 701,10
ERROR_PROPAGATE( packet_translate( ip_globals.net_phone, & packet, IPC_GET_PACKET( call )));
return ip_send_msg( 0, IPC_GET_DEVICE( call ), packet, 0 );
case NET_IL_DEVICE_STATE:
return ip_device_state_msg( 0, IPC_GET_DEVICE( call ), IPC_GET_STATE( call ));
return ip_device_state_message( IPC_GET_DEVICE( call ), IPC_GET_STATE( call ));
case NET_IL_RECEIVED:
ERROR_PROPAGATE( packet_translate( ip_globals.net_phone, & packet, IPC_GET_PACKET( call )));
return ip_received_msg( IPC_GET_DEVICE( call ), packet );
return ip_receive_message( IPC_GET_DEVICE( call ), packet );
case NET_IP_ADD_ROUTE:
return ip_add_route_req( 0, IPC_GET_DEVICE( call ), IP_GET_ADDRESS( call ), IP_GET_NETMASK( call ), IP_GET_GATEWAY( call ));
case NET_IP_SET_GATEWAY:
631,7 → 714,7
* answer_count = 3;
return EOK;
case NET_IL_MTU_CHANGED:
return ip_mtu_changed_msg( IPC_GET_DEVICE( call ), IPC_GET_MTU( call ));
return ip_mtu_changed_message( IPC_GET_DEVICE( call ), IPC_GET_MTU( call ));
}
return ENOTSUP;
}
902,7 → 985,7
last->header_checksum = 0;
}
 
int ip_received_msg( device_id_t device_id, packet_t packet ){
int ip_receive_message( device_id_t device_id, packet_t packet ){
packet_t next;
 
do{