Libnet


Files

file  arp_remote.c
 ARP interface implementation for remote modules.
file  ethernet_lsap.h
 Link service access point identifiers.
file  ethernet_protocols.h
 Ethernet protocol numbers according to the on-line IANA - Ethernet numbers http://www.iana.org/assignments/ethernet-numbers cited January 17 2009.
file  generic.c
 Generic communication interfaces for networking.
file  generic.h
 Generic communication interfaces for networking.
file  icmp_client.c
 ICMP client interface implementation.
file  icmp_client.h
 ICMP client interface.
file  icmp_header.h
 ICMP header definition.
file  icmp_remote.c
 ICMP interface implementation for remote modules.
file  il_remote.c
 Internetwork layer module interface for the underlying network interface layer.
file  il_remote.h
 Internetwork layer module interface for the underlying network interface layer.
file  il_skel.c
 Internetworking layer module skeleton implementation.
file  il_skel.h
 Internetwork layer module skeleton.
file  ip_client.c
 IP client interface implementation.
file  ip_client.h
 IP client interface.
file  ip_header.h
 IP header and options definitions.
file  ip_remote.c
 IP interface implementation for remote modules.
file  module_map.c
 Character string to module map implementation.
file  module_map.h
 Character string to module map.
file  net_checksum.c
 General CRC and checksum computation implementation.
file  net_checksum.h
 General CRC and checksum computation.
file  net_hardware.h
 Hardware types according to the on-line IANA - Address Resolution Protocol (ARP) Parameters http://www.iana.org/assignments/arp-parameters/arp-parameters.xml, cited January 14 2009.
file  net_remote.c
 Networking interface implementation for remote modules.
file  netif_remote.c
 Network interface module interface implementation for remote modules.
file  netif_skel.c
 Network interface module skeleton implementation.
file  netif_skel.h
 Network interface module skeleton.
file  nil_remote.c
 Network interface layer interface implementation for remote modules.
file  nil_skel.c
 Network interface layer module skeleton implementation.
file  nil_skel.h
 Network interface layer modules common skeleton.
file  packet_client.c
 Packet client implementation.
file  packet_client.h
 Packet client.
file  packet_remote.c
 Packet client interface implementation for remote modules.
file  protocol_map.h
 Internetwork layer services - network interface layer service type translation.
file  socket_core.c
 Socket common core implementation.
file  socket_core.h
 Socket common core.
file  tl_common.c
 Transport layer common functions implementation.
file  tl_common.h
 Transport layer common functions.
file  tl_remote.h
 Transport layer module interface for the underlying internetwork layer.
file  tl_skel.c
 Transport layer module skeleton implementation.
file  tl_skel.h
 Transport layer module skeleton.

Data Structures

struct  icmp_echo
 Echo specific data. More...
struct  icmp_header
 Internet control message header. More...
struct  ip_header
 Internet header. More...
struct  ip_option
 Internet option header. More...
struct  ipv4_pseudo_header
 Internet version 4 pseudo header. More...
struct  netif_device_t
 Network interface device specific data. More...
struct  netif_globals_t
 Network interface module skeleton global data. More...
struct  socket_core
 Socket core. More...
struct  socket_port
 Bound port sockets. More...

Ethernet LSAP values definitions

#define ETH_LSAP_ARP   0x98
 ARPANET Address Resolution Protocol (ARP) LSAP identifier.
#define ETH_LSAP_GLSAP   0xFF
 Global LSAP LSAP identifier.
#define ETH_LSAP_IP   0x06
 ARPANET Internet Protocol (IP) LSAP identifier.
#define ETH_LSAP_NULL   0x00
 Null LSAP LSAP identifier.
#define ETH_LSAP_SNAP   0xAA
 SubNetwork Access Protocol (SNAP) LSAP identifier.

Ethernet protocols definitions

#define ETH_MIN_PROTO   0x0600
 Ethernet minimal protocol number.
#define ETH_P_ARP   0x0806
 ARP ethernet protocol type.
#define ETH_P_IP   0x0800
 Internet IP (IPv4) ethernet protocol type.

Network interface layer types definitions

#define HW_ETHER   1
 Ethernet (10Mb) hardware type.

IP flags definitions

#define IPFLAG_DONT_FRAGMENT   (0x1 << IPFLAG_FRAGMENT_SHIFT)
 Don't fragment flag value.
#define IPFLAG_FRAGMENT_SHIFT   1
 Fragment flag field shift.
#define IPFLAG_FRAGMENTED_SHIFT   0
 Fragmented flag field shift.
#define IPFLAG_LAST_FRAGMENT   (0x0 << IPFLAG_FRAGMENTED_SHIFT)
 Last fragment flag value.
#define IPFLAG_MAY_FRAGMENT   (0x0 << IPFLAG_FRAGMENT_SHIFT)
 May fragment flag value.
#define IPFLAG_MORE_FRAGMENTS   (0x1 << IPFLAG_FRAGMENTED_SHIFT)
 More fragments flag value.

Packet client interface

#define PACKET_PREFIX(packet, type)   (type *) packet_prefix((packet), sizeof(type))
 Allocates the specified type right before the actual packet content and returns its pointer.
#define PACKET_SUFFIX(packet, type)   (type *) packet_suffix((packet), sizeof(type))
 Allocates the specified type right after the actual packet content and returns its pointer.
#define PACKET_TRIM(packet, prefix, suffix)   packet_trim((packet), sizeof(prefix), sizeof(suffix))
 Trims the actual packet content by the specified prefix and suffix types.
int packet_copy_data (packet_t *packet, const void *data, size_t length)
 Copies the specified data to the beginning of the actual packet content.
int packet_get_addr (const packet_t *packet, uint8_t **src, uint8_t **dest)
 Returns the stored packet addresses and their length.
packet_tpacket_get_copy (int phone, packet_t *packet)
 Returns the packet copy.
void * packet_get_data (const packet_t *packet)
 Returns the pointer to the beginning of the packet content.
size_t packet_get_data_length (const packet_t *packet)
 Returns the packet content length.
packet_id_t packet_get_id (const packet_t *packet)
 Returns the packet identifier.
void * packet_prefix (packet_t *packet, size_t length)
 Allocates the specified space right before the actual packet content and returns its pointer.
int packet_set_addr (packet_t *packet, const uint8_t *src, const uint8_t *dest, size_t addr_len)
 Sets the packet addresses.
void * packet_suffix (packet_t *packet, size_t length)
 Allocates the specified space right after the actual packet content and returns its pointer.
int packet_trim (packet_t *packet, size_t prefix, size_t suffix)
 Trims the actual packet content by the specified prefix and suffix lengths.

IP module interface

This interface is used by other modules.

typedef int(*) tl_received_msg_t (device_id_t device_id, packet_t *packet, services_t receiver, services_t error)
 The transport layer notification function type definition.
int ip_bind_service (services_t service, int protocol, services_t me, async_client_conn_t receiver)
 Creates bidirectional connection with the ip module service and registers the message receiver.
int ip_connect_module (services_t service)
 Connects to the IP module.

ARP module interface

This interface is used by other modules.

int arp_clean_cache_req (int arp_phone)
 Cleans the cache.
int arp_clear_address_req (int arp_phone, device_id_t device_id, services_t protocol, measured_string_t *address)
 Clears the given protocol address from the cache.
int arp_clear_device_req (int arp_phone, device_id_t device_id)
 Clears the device cache.
int arp_connect_module (services_t service)
 Connects to the ARP module.
int arp_device_req (int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_t *address)
 Registers the new device and the requesting protocol service.
int arp_translate_req (int arp_phone, device_id_t device_id, services_t protocol, measured_string_t *address, measured_string_t **translation, uint8_t **data)
 Translates the given protocol address to the network interface address.

ICMP module interface

This interface is used by other modules.

int icmp_destination_unreachable_msg (int icmp_phone, icmp_code_t code, icmp_param_t mtu, packet_t *packet)
 Sends the Destination Unreachable error notification packet.
int icmp_parameter_problem_msg (int icmp_phone, icmp_code_t code, icmp_param_t pointer, packet_t *packet)
 Sends the Parameter Problem error notification packet.
int icmp_source_quench_msg (int icmp_phone, packet_t *packet)
 Sends the Source Quench error notification packet.
int icmp_time_exceeded_msg (int icmp_phone, icmp_code_t code, packet_t *packet)
 Sends the Time Exceeded error notification packet.

Internetwork layer module interface

This interface is used by other modules.

int il_device_state_msg (int il_phone, device_id_t device_id, device_state_t state, services_t target)
 Notify the internetwork layer modules about the device state change.
int il_mtu_changed_msg (int il_phone, device_id_t device_id, size_t mtu, services_t target)
 Notify the internetwork layer modules about the mtu change.
int il_received_msg (int il_phone, device_id_t device_id, packet_t *packet, services_t target)
 Notify the internetwork layer modules about the received packet/s.

Networking module interface

This interface is used by other modules.

int net_connect_module (void)
 Connects to the networking module.
void net_free_settings (measured_string_t *settings, uint8_t *data)
 Frees the received settings.
int net_get_conf_req (int net_phone, measured_string_t **configuration, size_t count, uint8_t **data)
 Returns the global configuration.
int net_get_device_conf_req (int net_phone, device_id_t device_id, measured_string_t **configuration, size_t count, uint8_t **data)
 Returns the device specific configuration.

Transport layer module interface

This interface is used by other modules.

int tl_received_msg (int tl_phone, device_id_t device_id, packet_t *packet, services_t target, services_t error)
 Notify the remote transport layer modules about the received packet/s.

Defines

#define compute_crc32(seed, data, length)   compute_crc32_le(seed, (uint8_t *) data, length)
#define CRC_DIVIDER_BE   0x04c11db7
 Big-endian encoding CRC divider.
#define CRC_DIVIDER_LE   0xedb88320
 Little-endian encoding CRC divider.
#define ICMP_HEADER_SIZE   sizeof(icmp_header_t)
 ICMP header size in bytes.
#define ip_add_route_req   ip_add_route_req_remote
#define IP_CHECKSUM_ZERO   0xffffU
 IP checksum value for computed zero checksum.
#define IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length)   ((((length) / 8U) & 0x1f00) >> 8)
 Returns the fragment offest high bits.
#define IP_COMPUTE_FRAGMENT_OFFSET_LOW(length)   (((length) / 8U) & 0xff)
 Returns the fragment offest low bits.
#define IP_COMPUTE_HEADER_LENGTH(length)   ((uint8_t) ((length) / 4U))
 Returns the IP header length.
#define ip_device_req   ip_device_req_remote
#define IP_FRAGMENT_OFFSET(header)
 Returns the fragment offest.
#define ip_get_route_req   ip_get_route_req_remote
#define IP_HEADER_CHECKSUM(header)   (htons(ip_checksum((uint8_t *) (header), IP_HEADER_LENGTH(header))))
 Returns the IP packet header checksum.
#define IP_HEADER_DATA_LENGTH(header)   (IP_TOTAL_LENGTH(header) - IP_HEADER_LENGTH(header))
 Returns the actual IP packet data length.
#define IP_HEADER_LENGTH(header)   (GET_IP_HEADER_LENGTH(header) * 4U)
 Returns the actual IP header length in bytes.
#define ip_packet_size_req   ip_packet_size_req_remote
#define ip_received_error_msg   ip_received_error_msg_remote
#define ip_send_msg   ip_send_msg_remote
#define ip_set_gateway_req   ip_set_gateway_req_remote
#define IP_TOTAL_LENGTH(header)   ntohs((header)->total_length)
 Returns the actual IP packet total length.
#define SOCKET_ID_TRIES   100
 Maximum number of random attempts to find a new socket identifier before switching to the sequence.
#define SOCKET_INITIAL_ACCEPTED_SIZE   1
 Initial size of the sockets for acceptance queue.
#define SOCKET_INITIAL_RECEIVED_SIZE   4
 Initial size of the received packet queue.
#define SOCKET_MAP_KEY_LISTENING   "L"
 Listening sockets' port map key.
#define SOCKET_MAX_ACCEPTEDED_SIZE   0
 Maximum size of the sockets for acceptance queue.
#define SOCKET_MAX_RECEIVED_SIZE   0
 Maximum size of the received packet queue.

Typedefs

typedef uint8_t eth_lsap_t
 Ethernet LSAP type definition.
typedef uint16_t eth_type_t
 Ethernet protocol type definition.
typedef uint8_t hw_type_t
 Network interface layer type type definition.
typedef icmp_echo icmp_echo_t
 Echo specific data.
typedef icmp_header icmp_header_t
 Internet control message header.
typedef ip_header ip_header_t
 Type definition of the internet header.
typedef ip_option ip_option_t
 Type definition of the internet option header.
typedef ipv4_pseudo_header ipv4_pseudo_header_t
 Type definition of the internet version 4 pseudo header.
typedef module_struct module_t
 Type definition of the module structure.
typedef socket_core socket_core_t
 Type definition of the socket core.
typedef socket_port socket_port_t
 Type definition of the socket port.

Functions

uint16_t compact_checksum (uint32_t sum)
 Compacts the computed checksum to the 16 bit number adding the carries.
uint32_t compute_checksum (uint32_t seed, uint8_t *data, size_t length)
 Computes sum of the 2 byte fields.
uint32_t compute_crc32_be (uint32_t seed, uint8_t *data, size_t length)
 Computes CRC32 value in the big-endian environment.
uint32_t compute_crc32_le (uint32_t seed, uint8_t *data, size_t length)
 Computes CRC32 value in the little-endian environment.
 DEVICE_MAP_DECLARE (packet_dimensions, packet_dimension_t)
 Device packet dimensions.
 DEVICE_MAP_DECLARE (netif_device_map, netif_device_t)
 Device map.
int find_device (device_id_t device_id, netif_device_t **device)
 Find the device specific data.
uint16_t flip_checksum (uint16_t checksum)
 Returns or flips the checksum if zero.
 GENERIC_CHAR_MAP_DECLARE (socket_port_map, socket_core_t *)
 Bount port sockets map.
 GENERIC_CHAR_MAP_DECLARE (modules, module_t) struct module_struct
 Module structure.
 GENERIC_CHAR_MAP_IMPLEMENT (modules, module_t)
int generic_device_req_remote (int phone, int message, device_id_t device_id, int arg2, services_t service)
 Notify a module about the device.
int generic_device_state_msg_remote (int phone, int message, device_id_t device_id, int state, services_t target)
 Notify the module about the device state change.
int generic_get_addr_req (int phone, int message, device_id_t device_id, measured_string_t **address, uint8_t **data)
 Returns the address.
int generic_packet_size_req_remote (int phone, int message, device_id_t device_id, packet_dimension_t *packet_dimension)
 Return the device packet dimension for sending.
int generic_received_msg_remote (int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t target, services_t error)
 Pass the packet queue to the module.
int generic_send_msg_remote (int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t sender, services_t error)
 Send the packet queue.
int generic_translate_req (int phone, int message, device_id_t device_id, services_t service, measured_string_t *configuration, size_t count, measured_string_t **translation, uint8_t **data)
 Translates the given strings.
module_tget_running_module (modules_t *modules, uint8_t *name)
 Searches and returns the specified module.
hw_type_t hardware_map (services_t nil)
 Maps the network interface layer services to the hardware types.
size_t icmp_client_header_length (packet_t *packet)
 Returns the ICMP header length.
int icmp_client_process_packet (packet_t *packet, icmp_type_t *type, icmp_code_t *code, icmp_param_t *pointer, icmp_param_t *mtu)
 Processes the received packet prefixed with an ICMP header.
static void il_client_connection (ipc_callid_t iid, ipc_call_t *icall)
 Default thread for new connections.
int il_initialize (int net_phone)
 Module initialization.
int il_module_message (ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, size_t *answer_count)
 Process the internetwork layer module message.
int il_module_start (int service)
 Start the internetworking layer module.
 INT_MAP_DECLARE (socket_ports, socket_port_t)
 Ports map.
 INT_MAP_DECLARE (socket_cores, socket_core_t)
 Sockets map.
int ip_add_route_req_remote (int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway)
 Add a route to the device routing table.
uint16_t ip_checksum (uint8_t *data, size_t length)
 Computes the ip header checksum.
int ip_client_get_pseudo_header (ip_protocol_t protocol, struct sockaddr *src, socklen_t srclen, struct sockaddr *dest, socklen_t destlen, size_t data_length, void **header, size_t *headerlen)
 Constructs the IPv4 pseudo header.
size_t ip_client_header_length (packet_t *packet)
 Returns the IP header length.
int ip_client_prepare_packet (packet_t *packet, ip_protocol_t protocol, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, size_t ipopt_length)
 Prepares the packet to be transfered via IP.
int ip_client_process_packet (packet_t *packet, ip_protocol_t *protocol, ip_ttl_t *ttl, ip_tos_t *tos, int *dont_fragment, size_t *ipopt_length)
 Processes the received IP packet.
int ip_client_set_pseudo_header_data_length (void *header, size_t headerlen, size_t data_length)
 Updates the IPv4 pseudo header data length field.
int ip_device_req_remote (int ip_phone, device_id_t device_id, services_t service)
 Register the new device.
int ip_get_route_req_remote (int ip_phone, ip_protocol_t protocol, const struct sockaddr *destination, socklen_t addrlen, device_id_t *device_id, void **header, size_t *headerlen)
 Return the device identifier and the IP pseudo header based on the destination address.
int ip_packet_size_req_remote (int ip_phone, device_id_t device_id, packet_dimension_t *packet_dimension)
 Return the device packet dimension for sending.
int ip_received_error_msg_remote (int ip_phone, device_id_t device_id, packet_t *packet, services_t target, services_t error)
 Notify the IP module about the received error notification packet.
int ip_send_msg_remote (int ip_phone, device_id_t device_id, packet_t *packet, services_t sender, services_t error)
 Send the packet queue.
int ip_set_gateway_req_remote (int ip_phone, device_id_t device_id, in_addr_t gateway)
 Set the default gateway.
eth_type_t lsap_map (eth_lsap_t lsap)
 Maps the link service access point identifier to the Ethernet protocol identifier.
eth_lsap_t lsap_unmap (eth_type_t ethertype)
 Maps the Ethernet protocol identifier to the link service access point identifier.
task_id_t net_spawn (const uint8_t *fname)
 Start the given module.
int netif_bind_service (services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver)
 Create bidirectional connection with the network interface module.
static void netif_client_connection (ipc_callid_t iid, ipc_call_t *icall)
 Default fibril for new module connections.
int netif_get_addr_message (device_id_t device_id, measured_string_t *address)
 Return the device local hardware address.
int netif_get_addr_req (int netif_phone, device_id_t device_id, measured_string_t **address, uint8_t **data)
 Return the device local hardware address.
int netif_get_device_stats (device_id_t device_id, device_stats_t *stats)
 Return the device usage statistics.
int netif_initialize (void)
 Initialize the specific module.
static int netif_module_message (ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, size_t *count)
 Process the netif module messages.
int netif_module_start (void)
 Start the network interface module.
packet_tnetif_packet_get_1 (size_t content)
 Allocate new packet to handle the given content size.
void netif_pq_release (packet_id_t packet_id)
 Release the given packet.
int netif_probe_message (device_id_t device_id, int irq, void *io)
 Probe the existence of the device.
int netif_probe_req (int netif_phone, device_id_t device_id, int irq, void *io)
 Probe the existence of the device.
static int netif_probe_req_local (int netif_phone, device_id_t device_id, int irq, void *io)
 Probe the existence of the device.
int netif_send_message (device_id_t device_id, packet_t *packet, services_t sender)
 Send the packet queue.
int netif_send_msg (int netif_phone, device_id_t device_id, packet_t *packet, services_t sender)
 Send the packet queue.
static int netif_send_msg_local (int netif_phone, device_id_t device_id, packet_t *packet, services_t sender)
 Send the packet queue.
int netif_specific_message (ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, size_t *count)
 Process the netif driver specific message.
int netif_start_message (netif_device_t *device)
 Start the device.
int netif_start_req (int netif_phone, device_id_t device_id)
 Start the device.
static int netif_start_req_local (int netif_phone, device_id_t device_id)
 Start the device.
int netif_stats_req (int netif_phone, device_id_t device_id, device_stats_t *stats)
 Return the device usage statistics.
int netif_stop_message (netif_device_t *device)
 Stop the device.
int netif_stop_req (int netif_phone, device_id_t device_id)
 Stop the device.
static int netif_stop_req_local (int netif_phone, device_id_t device_id)
 Stop the device.
static void nil_client_connection (ipc_callid_t iid, ipc_call_t *icall)
 Default thread for new connections.
int nil_device_state_msg (int nil_phone, device_id_t device_id, int state)
 Notify the network interface layer about the device state change.
int nil_device_state_msg_local (int, device_id_t, int)
 Notify the network interface layer about the device state change.
int nil_initialize (int net_phone)
 Module initialization.
int nil_module_message (ipc_callid_t, ipc_call_t *, ipc_call_t *, size_t *)
 Message processing function.
int nil_module_start (int service)
 Start the network interface layer module.
int nil_received_msg (int nil_phone, device_id_t device_id, packet_t *packet, services_t target)
 Pass the packet queue to the network interface layer.
int nil_received_msg_local (int, device_id_t, packet_t *, services_t)
 Pass the packet queue to the network interface layer.
void null_device_stats (device_stats_t *stats)
 Clear the usage statistics.
packet_tpacket_get_1_remote (int phone, size_t content)
 Obtains the packet of the given content size.
packet_tpacket_get_4_remote (int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix)
 Obtains the packet of the given dimensions.
static int packet_return (int phone, packet_t **packet, packet_id_t packet_id, size_t size)
 Obtain the packet from the packet server as the shared memory block.
int packet_translate_remote (int phone, packet_t **packet, packet_id_t packet_id)
 Translates the packet identifier to the packet reference.
void pq_release_remote (int phone, packet_id_t packet_id)
 Releases the packet queue.
eth_type_t protocol_map (services_t nil, services_t il)
 Maps the internetwork layer service to the network interface layer type.
services_t protocol_unmap (services_t nil, int protocol)
 Maps the network interface layer type to the internetwork layer service.
static int register_message (device_id_t device_id, int phone)
 Register the device notification receiver,.
int socket_bind (socket_cores_t *local_sockets, socket_ports_t *global_sockets, int socket_id, void *addr, size_t addrlen, int free_ports_start, int free_ports_end, int last_used_port)
 Binds the socket to the port.
int socket_bind_free_port (socket_ports_t *global_sockets, socket_core_t *socket, int free_ports_start, int free_ports_end, int last_used_port)
 Binds the socket to a free port.
static int socket_bind_insert (socket_ports_t *global_sockets, socket_core_t *socket, int port)
 Binds the socket to the port.
void socket_cores_release (int packet_phone, socket_cores_t *local_sockets, socket_ports_t *global_sockets, void(*socket_release)(socket_core_t *socket))
 Destroys local sockets.
int socket_create (socket_cores_t *local_sockets, int app_phone, void *specific_data, int *socket_id)
 Creates a new socket.
int socket_destroy (int packet_phone, int socket_id, socket_cores_t *local_sockets, socket_ports_t *global_sockets, void(*socket_release)(socket_core_t *socket))
 Destroys the socket.
static void socket_destroy_core (int packet_phone, socket_core_t *socket, socket_cores_t *local_sockets, socket_ports_t *global_sockets, void(*socket_release)(socket_core_t *socket))
 Destroys the socket.
static int socket_generate_new_id (socket_cores_t *local_sockets, int positive)
 Tries to find a new free socket identifier.
int socket_port_add (socket_ports_t *global_sockets, int port, socket_core_t *socket, const uint8_t *key, size_t key_length)
 Adds the socket to an already bound port.
static int socket_port_add_core (socket_port_t *socket_port, socket_core_t *socket, const uint8_t *key, size_t key_length)
 Adds the socket to a socket port.
socket_core_tsocket_port_find (socket_ports_t *global_sockets, int port, const uint8_t *key, size_t key_length)
 Finds the bound port socket.
void socket_port_release (socket_ports_t *global_sockets, socket_core_t *socket)
 Releases the socket port.
int socket_reply_packets (packet_t *packet, size_t *length)
 Replies the packet or the packet queue data to the application via the socket.
static void tl_client_connection (ipc_callid_t iid, ipc_call_t *icall)
 Default thread for new connections.
void tl_connection (void)
 Per-connection module initialization.
int tl_get_address_port (const struct sockaddr *addr, int addrlen, uint16_t *port)
 Gets the address port.
int tl_get_ip_packet_dimension (int ip_phone, packet_dimensions_t *packet_dimensions, device_id_t device_id, packet_dimension_t **packet_dimension)
 Get IP packet dimensions.
int tl_initialize (int net_phone)
 Module initialization.
int tl_message (ipc_callid_t, ipc_call_t *, ipc_call_t *, size_t *)
 Process the transport layer module message.
int tl_module_start (int service)
 Start the trasport layer module.
int tl_prepare_icmp_packet (int packet_phone, int icmp_phone, packet_t *packet, services_t error)
 Prepares the packet for ICMP error notification.
int tl_set_address_port (struct sockaddr *addr, int addrlen, uint16_t port)
 Sets the address port.
int tl_socket_read_packet_data (int packet_phone, packet_t **packet, size_t prefix, const packet_dimension_t *dimension, const struct sockaddr *addr, socklen_t addrlen)
 Receives data from the socket into a packet.
int tl_update_ip_packet_dimension (packet_dimensions_t *packet_dimensions, device_id_t device_id, size_t content)
 Updates IP device packet dimensions cache.

Variables

netif_globals_t netif_globals
 Network interface global data.
netif_globals_t netif_globals
 Network interface global data.

Define Documentation

#define ETH_MIN_PROTO   0x0600

Ethernet minimal protocol number.

According to the IEEE 802.3 specification.

Definition at line 53 of file ethernet_protocols.h.

#define IP_CHECKSUM_ZERO   0xffffU

IP checksum value for computed zero checksum.

Zero is returned as 0xFFFF (not flipped)

Definition at line 46 of file net_checksum.h.

#define IP_COMPUTE_FRAGMENT_OFFSET_HIGH ( length   )     ((((length) / 8U) & 0x1f00) >> 8)

Returns the fragment offest high bits.

Parameters:
[in] length The prefixed data total length.

Definition at line 47 of file ip_header.h.

#define IP_COMPUTE_FRAGMENT_OFFSET_LOW ( length   )     (((length) / 8U) & 0xff)

Returns the fragment offest low bits.

Parameters:
[in] length The prefixed data total length.

Definition at line 53 of file ip_header.h.

#define IP_COMPUTE_HEADER_LENGTH ( length   )     ((uint8_t) ((length) / 4U))

Returns the IP header length.

Parameters:
[in] length The IP header length in bytes.

Definition at line 59 of file ip_header.h.

#define IP_FRAGMENT_OFFSET ( header   ) 

Value:

(((GET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header) << 8) + \
            (header)->fragment_offset_low) * 8U)
Returns the fragment offest.

Parameters:
[in] header The IP packet header.

Definition at line 65 of file ip_header.h.

#define IP_HEADER_CHECKSUM ( header   )     (htons(ip_checksum((uint8_t *) (header), IP_HEADER_LENGTH(header))))

Returns the IP packet header checksum.

Parameters:
[in] header The IP packet header.

Definition at line 72 of file ip_header.h.

#define IP_HEADER_DATA_LENGTH ( header   )     (IP_TOTAL_LENGTH(header) - IP_HEADER_LENGTH(header))

Returns the actual IP packet data length.

Parameters:
[in] header The IP packet header.

Definition at line 78 of file ip_header.h.

#define IP_HEADER_LENGTH ( header   )     (GET_IP_HEADER_LENGTH(header) * 4U)

Returns the actual IP header length in bytes.

Parameters:
[in] header The IP packet header.

Definition at line 84 of file ip_header.h.

#define IP_TOTAL_LENGTH ( header   )     ntohs((header)->total_length)

Returns the actual IP packet total length.

Parameters:
[in] header The IP packet header.

Definition at line 90 of file ip_header.h.

#define IPFLAG_DONT_FRAGMENT   (0x1 << IPFLAG_FRAGMENT_SHIFT)

Don't fragment flag value.

Permits the packet fragmentation.

Definition at line 105 of file ip_header.h.

#define IPFLAG_LAST_FRAGMENT   (0x0 << IPFLAG_FRAGMENTED_SHIFT)

Last fragment flag value.

Indicates the last packet fragment.

Definition at line 110 of file ip_header.h.

#define IPFLAG_MAY_FRAGMENT   (0x0 << IPFLAG_FRAGMENT_SHIFT)

May fragment flag value.

Allows the packet fragmentation.

Definition at line 115 of file ip_header.h.

#define IPFLAG_MORE_FRAGMENTS   (0x1 << IPFLAG_FRAGMENTED_SHIFT)

More fragments flag value.

Indicates that more packet fragments follow.

Definition at line 120 of file ip_header.h.

#define PACKET_PREFIX ( packet,
type   )     (type *) packet_prefix((packet), sizeof(type))

Allocates the specified type right before the actual packet content and returns its pointer.

The wrapper of the packet_prepend() function.

Parameters:
[in] packet The packet to be used.
[in] type The type to be allocated at the beginning of the packet content.
Returns:
The typed pointer to the allocated memory.

NULL if the packet is not valid.

NULL if there is not enough memory left.

Definition at line 67 of file packet_client.h.

#define PACKET_SUFFIX ( packet,
type   )     (type *) packet_suffix((packet), sizeof(type))

Allocates the specified type right after the actual packet content and returns its pointer.

The wrapper of the packet_append() function.

Parameters:
[in] packet The packet to be used.
[in] type The type to be allocated at the end of the packet content.
Returns:
The typed pointer to the allocated memory.

NULL if the packet is not valid.

NULL if there is not enough memory left.

Definition at line 82 of file packet_client.h.

#define PACKET_TRIM ( packet,
prefix,
suffix   )     packet_trim((packet), sizeof(prefix), sizeof(suffix))

Trims the actual packet content by the specified prefix and suffix types.

The wrapper of the packet_trim() function.

Parameters:
[in] packet The packet to be trimmed.
[in] prefix The type of the prefix to be removed from the beginning of the packet content.
[in] suffix The type of the suffix to be removed from the end of the packet content.
Returns:
EOK on success.

EINVAL if the packet is not valid.

ENOMEM if there is not enough memory left.

Definition at line 98 of file packet_client.h.


Typedef Documentation

typedef struct ip_header ip_header_t

Type definition of the internet header.

See also:
ip_header

Definition at line 127 of file ip_header.h.

typedef struct ip_option ip_option_t

Type definition of the internet option header.

See also:
ip_header

Definition at line 132 of file ip_header.h.

typedef struct ipv4_pseudo_header ipv4_pseudo_header_t

Type definition of the internet version 4 pseudo header.

See also:
ipv4_pseudo_header

Definition at line 137 of file ip_header.h.

typedef struct module_struct module_t

Type definition of the module structure.

See also:
module_struct

Definition at line 48 of file module_map.h.

typedef struct socket_core socket_core_t

Type definition of the socket core.

See also:
socket_core

Definition at line 66 of file socket_core.h.

typedef struct socket_port socket_port_t

Type definition of the socket port.

See also:
socket_port

Definition at line 71 of file socket_core.h.

typedef int(*) tl_received_msg_t(device_id_t device_id, packet_t *packet, services_t receiver, services_t error)

The transport layer notification function type definition.

Notifies the transport layer modules about the received packet/s.

Parameters:
[in] device_id The device identifier.
[in] packet The received packet or the received packet queue.
[in] receiver The receiving module service.
[in] error The packet error reporting service. Prefixes the received packet.
Returns:
EOK on success.

Definition at line 72 of file ip_interface.h.


Function Documentation

int arp_clean_cache_req ( int  arp_phone  ) 

Cleans the cache.

Parameters:
[in] arp_phone The ARP module phone used for (semi)remote calls.
Returns:
EOK on success.

Definition at line 68 of file arp_remote.c.

int arp_clear_address_req ( int  arp_phone,
device_id_t  device_id,
services_t  protocol,
measured_string_t address 
)

Clears the given protocol address from the cache.

Parameters:
[in] arp_phone The ARP module phone used for (semi)remote calls.
[in] device_id The device identifier.
[in] protocol The requesting protocol service.
[in] address The protocol address to be cleared.
Returns:
EOK on success.

ENOENT if the mapping is not found.

Definition at line 83 of file arp_remote.c.

int arp_clear_device_req ( int  arp_phone,
device_id_t  device_id 
)

Clears the device cache.

Parameters:
[in] arp_phone The ARP module phone used for (semi)remote calls.
[in] device_id The device identifier.
Returns:
EOK on success.

ENOENT if the device is not found.

Definition at line 104 of file arp_remote.c.

int arp_connect_module ( services_t  service  ) 

Connects to the ARP module.

Parameters:
service The ARP module service. Ignored parameter.
Returns:
The ARP module phone on success.

Definition at line 55 of file arp_remote.c.

int arp_device_req ( int  arp_phone,
device_id_t  device_id,
services_t  protocol,
services_t  netif,
measured_string_t address 
)

Registers the new device and the requesting protocol service.

Connects to the network interface layer service. Determines the device broadcast address, its address lengths and packet size.

Parameters:
[in] arp_phone The ARP module phone used for (semi)remote calls.
[in] device_id The new device identifier.
[in] protocol The requesting protocol service.
[in] netif The underlying device network interface layer service.
[in] address The local requesting protocol address of the device.
Returns:
EOK on success.

EEXIST if the device is already used.

ENOMEM if there is not enough memory left.

ENOENT if the network interface service is not known.

EREFUSED if the network interface service is not responding.

Other error codes as defined for the nil_packet_get_size() function.

Other error codes as defined for the nil_get_addr() function.

Other error codes as defined for the nil_get_broadcast_addr() function.

Definition at line 133 of file arp_remote.c.

int arp_translate_req ( int  arp_phone,
device_id_t  device_id,
services_t  protocol,
measured_string_t address,
measured_string_t **  translation,
uint8_t **  data 
)

Translates the given protocol address to the network interface address.

Broadcasts the ARP request if the mapping is not found. Allocates and returns the needed memory block as the data parameter.

Parameters:
[in] arp_phone The ARP module phone used for (semi)remote calls.
[in] device_id The device identifier.
[in] protocol The requesting protocol service.
[in] address The local requesting protocol address.
[out] translation The translation of the local protocol address.
[out] data The allocated raw translation data container.
Returns:
EOK on success.

EINVAL if the address parameter is NULL.

EBADMEM if the translation or the data parameters are NULL.

ENOENT if the mapping is not found.

Definition at line 165 of file arp_remote.c.

uint16_t compact_checksum ( uint32_t  sum  ) 

Compacts the computed checksum to the 16 bit number adding the carries.

Parameters:
[in] sum Computed checksum.
Returns:
Compacted computed checksum to the 16 bits.

Definition at line 52 of file net_checksum.c.

uint32_t compute_checksum ( uint32_t  seed,
uint8_t *  data,
size_t  length 
)

Computes sum of the 2 byte fields.

Padds one zero (0) byte if odd.

Parameters:
[in] seed Initial value. Often used as 0 or ~0.
[in] data Pointer to the beginning of data to process.
[in] length Length of the data in bytes.
Returns:
The computed checksum of the length bytes of the data.

Definition at line 70 of file net_checksum.c.

uint32_t compute_crc32_be ( uint32_t  seed,
uint8_t *  data,
size_t  length 
)

Computes CRC32 value in the big-endian environment.

Parameters:
[in] seed Initial value. Often used as 0 or ~0.
[in] data Pointer to the beginning of data to process.
[in] length Length of the data in bits.
Returns:
The computed CRC32 of the length bits of the data.

Definition at line 92 of file net_checksum.c.

uint32_t compute_crc32_le ( uint32_t  seed,
uint8_t *  data,
size_t  length 
)

Computes CRC32 value in the little-endian environment.

Parameters:
[in] seed Initial value. Often used as 0 or ~0.
[in] data Pointer to the beginning of data to process.
[in] length Length of the data in bits.
Returns:
The computed CRC32 of the length bits of the data.

Definition at line 146 of file net_checksum.c.

DEVICE_MAP_DECLARE ( packet_dimensions  ,
packet_dimension_t   
)

Device packet dimensions.

Maps devices to the packet dimensions.

See also:
device.h

DEVICE_MAP_DECLARE ( netif_device_map  ,
netif_device_t   
)

Device map.

Maps device identifiers to the network interface device specific data.

See also:
device.h

int find_device ( device_id_t  device_id,
netif_device_t **  device 
)

Find the device specific data.

Parameters:
[in] device_id Device identifier.
[out] device Device specific data.
Returns:
EOK on success.

ENOENT if device is not found.

EPERM if the device is not initialized.

Definition at line 187 of file netif_skel.c.

uint16_t flip_checksum ( uint16_t  checksum  ) 

Returns or flips the checksum if zero.

Parameters:
[in] checksum The computed checksum.
Returns:
The internet protocol header checksum.

0xFFFF if the computed checksum is zero.

Definition at line 198 of file net_checksum.c.

GENERIC_CHAR_MAP_DECLARE ( socket_port_map  ,
socket_core_t  
)

Bount port sockets map.

The listening socket has the SOCKET_MAP_KEY_LISTENING key identifier whereas the other use the remote addresses.

GENERIC_CHAR_MAP_DECLARE ( modules  ,
module_t   
)

Module structure.

Module task identifier if running.

Module service identifier.

Module phone if running and connected.

Usage counter.

Module name.

Module full path filename.

Connecting function.

Definition at line 54 of file module_map.h.

int generic_device_req_remote ( int  phone,
int  message,
device_id_t  device_id,
int  arg2,
services_t  service 
)

Notify a module about the device.

Parameters:
[in] phone The service module phone.
[in] message The service specific message.
[in] device_id The device identifier.
[in] arg2 The second argument of the message.
[in] service The device module service.
Returns:
EOK on success.

Other error codes as defined for the specific service message.

Definition at line 77 of file generic.c.

int generic_device_state_msg_remote ( int  phone,
int  message,
device_id_t  device_id,
int  state,
services_t  target 
)

Notify the module about the device state change.

Parameters:
[in] phone The service module phone.
[in] message The service specific message.
[in] device_id The device identifier.
[in] state The new device state.
[in] target The target module service.
Returns:
EOK on success.

Definition at line 55 of file generic.c.

int generic_get_addr_req ( int  phone,
int  message,
device_id_t  device_id,
measured_string_t **  address,
uint8_t **  data 
)

Returns the address.

Parameters:
[in] phone The service module phone.
[in] message The service specific message.
[in] device_id The device identifier.
[out] address The desired address.
[out] data The address data container.
Returns:
EOK on success.

EBADMEM if the address parameter and/or the data parameter is NULL.

Other error codes as defined for the specific service message.

Definition at line 98 of file generic.c.

int generic_packet_size_req_remote ( int  phone,
int  message,
device_id_t  device_id,
packet_dimension_t packet_dimension 
)

Return the device packet dimension for sending.

Parameters:
[in] phone The service module phone.
[in] message The service specific message.
[in] device_id The device identifier.
[out] packet_dimension The packet dimension.
Returns:
EOK on success.

EBADMEM if the packet_dimension parameter is NULL.

Other error codes as defined for the specific service message.

Definition at line 136 of file generic.c.

int generic_received_msg_remote ( int  phone,
int  message,
device_id_t  device_id,
packet_id_t  packet_id,
services_t  target,
services_t  error 
)

Pass the packet queue to the module.

Parameters:
[in] phone The service module phone.
[in] message The service specific message.
[in] device_id The device identifier.
[in] packet_id The received packet or the received packet queue identifier.
[in] target The target module service.
[in] error The error module service.
Returns:
EOK on success.

Definition at line 170 of file generic.c.

int generic_send_msg_remote ( int  phone,
int  message,
device_id_t  device_id,
packet_id_t  packet_id,
services_t  sender,
services_t  error 
)

Send the packet queue.

Parameters:
[in] phone The service module phone.
[in] message The service specific message.
[in] device_id The device identifier.
[in] packet_id The packet or the packet queue identifier.
[in] sender The sending module service.
[in] error The error module service.
Returns:
EOK on success.

Definition at line 196 of file generic.c.

int generic_translate_req ( int  phone,
int  message,
device_id_t  device_id,
services_t  service,
measured_string_t configuration,
size_t  count,
measured_string_t **  translation,
uint8_t **  data 
)

Translates the given strings.

Allocates and returns the needed memory block as the data parameter.

Parameters:
[in] phone The service module phone.
[in] message The service specific message.
[in] device_id The device identifier.
[in] service The module service.
[in] configuration The key strings.
[in] count The number of configuration keys.
[out] translation The translated values.
[out] data The translation data container.
Returns:
EOK on success.

EINVAL if the configuration parameter is NULL.

EINVAL if the count parameter is zero.

EBADMEM if the translation or the data parameters are NULL.

Other error codes as defined for the specific service message.

Definition at line 231 of file generic.c.

module_t * get_running_module ( modules_t *  modules,
uint8_t *  name 
)

Searches and returns the specified module.

If the module is not running, the module filaname is spawned. If the module is not connected, the connect_function is called.

Parameters:
[in] modules The module map.
[in] name The module name.
Returns:
The running module found. It does not have to be connected.

NULL if there is no such module.

Definition at line 106 of file module_map.c.

hw_type_t hardware_map ( services_t  nil  ) 

Maps the network interface layer services to the hardware types.

Parameters:
[in] nil The network interface service.
Returns:
The hardware type of the network interface service.

Zero if mapping is not found.

Definition at line 137 of file protocol_map.c.

size_t icmp_client_header_length ( packet_t packet  ) 

Returns the ICMP header length.

Parameters:
[in] packet The packet.
Returns:
The ICMP header length in bytes.

Definition at line 96 of file icmp_client.c.

int icmp_client_process_packet ( packet_t packet,
icmp_type_t type,
icmp_code_t code,
icmp_param_t pointer,
icmp_param_t mtu 
)

Processes the received packet prefixed with an ICMP header.

Parameters:
[in] packet The received packet.
[out] type The ICMP header type.
[out] code The ICMP header code.
[out] pointer The ICMP header pointer.
[out] mtu The ICMP header MTU.
Returns:
The ICMP header length.

Zero if the packet contains no data.

Definition at line 63 of file icmp_client.c.

int icmp_destination_unreachable_msg ( int  icmp_phone,
icmp_code_t  code,
icmp_param_t  mtu,
packet_t packet 
)

Sends the Destination Unreachable error notification packet.

Beginning of the packet is sent as the notification packet data. The source and the destination addresses should be set in the original packet.

Parameters:
[in] icmp_phone The ICMP module phone used for (semi)remote calls.
[in] code The error specific code.
[in] mtu The error MTU value.
[in] packet The original packet.
Returns:
EOK on success.

EPERM if the ICMP error notifications are disabled.

ENOMEM if there is not enough memory left.

Definition at line 63 of file icmp_remote.c.

int icmp_parameter_problem_msg ( int  icmp_phone,
icmp_code_t  code,
icmp_param_t  pointer,
packet_t packet 
)

Sends the Parameter Problem error notification packet.

Beginning of the packet is sent as the notification packet data. The source and the destination addresses should be set in the original packet.

Parameters:
[in] icmp_phone The ICMP module phone used for (semi)remote calls.
[in] code The error specific code.
[in] pointer The problematic parameter offset.
[in] packet The original packet.
Returns:
EOK on success.

EPERM if the ICMP error notifications are disabled.

ENOMEM if there is not enough memory left.

Definition at line 124 of file icmp_remote.c.

int icmp_source_quench_msg ( int  icmp_phone,
packet_t packet 
)

Sends the Source Quench error notification packet.

Beginning of the packet is sent as the notification packet data. The source and the destination addresses should be set in the original packet.

Parameters:
[in] icmp_phone The ICMP module phone used for (semi)remote calls.
[in] packet The original packet.
Returns:
EOK on success.

EPERM if the ICMP error notifications are disabled.

ENOMEM if there is not enough memory left.

Definition at line 83 of file icmp_remote.c.

int icmp_time_exceeded_msg ( int  icmp_phone,
icmp_code_t  code,
packet_t packet 
)

Sends the Time Exceeded error notification packet.

Beginning of the packet is sent as the notification packet data. The source and the destination addresses should be set in the original packet.

Parameters:
[in] icmp_phone The ICMP module phone used for (semi)remote calls.
[in] code The error specific code.
[in] packet The original packet.
Returns:
EOK on success.

EPERM if the ICMP error notifications are disabled.

ENOMEM if there is not enough memory left.

Definition at line 103 of file icmp_remote.c.

static void il_client_connection ( ipc_callid_t  iid,
ipc_call_t icall 
) [static]

Default thread for new connections.

Parameters:
[in] iid The initial message identifier.
[in] icall The initial message call structure.

Definition at line 50 of file il_skel.c.

int il_device_state_msg ( int  il_phone,
device_id_t  device_id,
device_state_t  state,
services_t  target 
)

Notify the internetwork layer modules about the device state change.

Parameters:
[in] il_phone The internetwork layer module phone used for (semi)remote calls.
[in] device_id The device identifier.
[in] state The new device state.
[in] target The target internetwork module service to be delivered to.
Returns:
EOK on success.

Definition at line 60 of file il_remote.c.

int il_initialize ( int  net_phone  ) 

Module initialization.

This has to be implemented in user code.

Parameters:
[in] net_phone Networking module phone.
Returns:
EOK on success.

Other error codes as defined for each specific module initialize function.

Definition at line 629 of file arp.c.

int il_module_message ( ipc_callid_t  callid,
ipc_call_t call,
ipc_call_t answer,
size_t answer_count 
)

Process the internetwork layer module message.

Parameters:
[in] callid The message identifier.
[in] call The message parameters.
[out] answer The message answer parameters.
[out] answer_count The last parameter for the actual answer in the answer parameter.
Returns:
EOK on success.

ENOTSUP if the message is not known.

See also:
ip_interface.h

il_remote.h

IS_NET_IP_MESSAGE()

Definition at line 838 of file arp.c.

int il_module_start ( int  service  ) 

Start the internetworking layer module.

Initialize the client connection serving function, initialize the module, register the module service and start the async manager, processing IPC messages in an infinite loop.

Parameters:
[in] service Service identification.
Returns:
EOK on success.

Other error codes as defined for the pm_init() function.

Other error codes as defined for the il_initialize() function.

Other error codes as defined for the REGISTER_ME() macro function.

Definition at line 102 of file il_skel.c.

int il_mtu_changed_msg ( int  il_phone,
device_id_t  device_id,
size_t  mtu,
services_t  target 
)

Notify the internetwork layer modules about the mtu change.

Parameters:
[in] il_phone The internetwork layer module phone used for (semi)remote calls.
[in] device_id The device identifier.
[in] mtu The new mtu value.
[in] target The target internetwork module service to be delivered to.
Returns:
EOK on success.

Definition at line 98 of file il_remote.c.

int il_received_msg ( int  il_phone,
device_id_t  device_id,
packet_t packet,
services_t  target 
)

Notify the internetwork layer modules about the received packet/s.

Parameters:
[in] il_phone The internetwork layer module phone used for (semi)remote calls.
[in] device_id The device identifier.
[in] packet The received packet or the received packet queue.
[in] target The target internetwork module service to be delivered to.
Returns:
EOK on success.

Definition at line 79 of file il_remote.c.

INT_MAP_DECLARE ( socket_ports  ,
socket_port_t   
)

Ports map.

The key is the port number.

INT_MAP_DECLARE ( socket_cores  ,
socket_core_t   
)

Sockets map.

The key is the socket identifier.

int ip_add_route_req_remote ( int  ip_phone,
device_id_t  device_id,
in_addr_t  address,
in_addr_t  netmask,
in_addr_t  gateway 
)

Add a route to the device routing table.

The target network is routed using this device.

Parameters:
[in] ip_phone The IP module phone used for (semi)remote calls.
[in] device_id The device identifier.
[in] address The target network address.
[in] netmask The target network mask.
[in] gateway The target network gateway. Not used if zero.

Definition at line 65 of file ip_remote.c.

int ip_bind_service ( services_t  service,
int  protocol,
services_t  me,
async_client_conn_t  receiver 
)

Creates bidirectional connection with the ip module service and registers the message receiver.

Parameters:
[in] service The IP module service.
[in] protocol The transport layer protocol.
[in] me The requesting module service.
[in] receiver The message receiver. Used for remote connection.
Returns:
The phone of the needed service.

EOK on success.

Other error codes as defined for the bind_service() function.

Definition at line 85 of file ip_remote.c.

uint16_t ip_checksum ( uint8_t *  data,
size_t  length 
)

Computes the ip header checksum.

To compute the checksum of a new packet, the checksum header field must be zero. To check the checksum of a received packet, the checksum may be left set. Zero will be returned in this case if valid.

Parameters:
[in] data The header data.
[in] length The header length in bytes.
Returns:
The internet protocol header checksum.

0xFFFF if the computed checksum is zero.

Definition at line 216 of file net_checksum.c.

int ip_client_get_pseudo_header ( ip_protocol_t  protocol,
struct sockaddr src,
socklen_t  srclen,
struct sockaddr dest,
socklen_t  destlen,
size_t  data_length,
void **  header,
size_t headerlen 
)

Constructs the IPv4 pseudo header.

Parameters:
[in] protocol The transport protocol.
[in] src The source address.
[in] srclen The source address length.
[in] dest The destination address.
[in] destlen The destination address length.
[in] data_length The data length to be set.
[out] header The constructed IPv4 pseudo header.
[out] headerlen The length of the IP pseudo header in bytes.
Returns:
EOK on success.

EBADMEM if the header and/or the headerlen parameter is NULL.

EINVAL if the source address and/or the destination address parameter is NULL.

EINVAL if the source address length is less than struct sockaddr length.

EINVAL if the source address length differs from the destination address length.

EINVAL if the source address family differs from the destination family.

EAFNOSUPPORT if the address family is not supported.

ENOMEM if there is not enough memory left.

Definition at line 89 of file ip_client.c.

size_t ip_client_header_length ( packet_t packet  ) 

Returns the IP header length.

Parameters:
[in] packet The packet.
Returns:
The IP header length in bytes.

Zero if there is no IP header.

Definition at line 53 of file ip_client.c.

int ip_client_prepare_packet ( packet_t packet,
ip_protocol_t  protocol,
ip_ttl_t  ttl,
ip_tos_t  tos,
int  dont_fragment,
size_t  ipopt_length 
)

Prepares the packet to be transfered via IP.

The IP header is prefixed.

Parameters:
[in,out] packet The packet to be prepared.
[in] protocol The transport protocol.
[in] ttl The time to live counter. The IPDEFTTL is set if zero.
[in] tos The type of service.
[in] dont_fragment The value indicating whether fragmentation is disabled.
[in] ipopt_length The prefixed IP options length in bytes.
Returns:
EOK on success.

ENOMEM if there is not enough memory left in the packet.

Definition at line 155 of file ip_client.c.

int ip_client_process_packet ( packet_t packet,
ip_protocol_t protocol,
ip_ttl_t ttl,
ip_tos_t tos,
int *  dont_fragment,
size_t ipopt_length 
)

Processes the received IP packet.

Fills set header fields. Returns the prefixed IP header length.

Parameters:
[in] packet The received packet.
[out] protocol The transport protocol. May be NULL if not desired.
[out] ttl The time to live counter. May be NULL if not desired.
[out] tos The type of service. May be NULL if not desired.
[out] dont_fragment The value indicating whether the fragmentation is disabled. May be NULL if not desired.
[out] ipopt_length The IP options length in bytes. May be NULL if not desired.
Returns:
The prefixed IP header length in bytes on success.

ENOMEM if the packet is too short to contain the IP header.

Definition at line 213 of file ip_client.c.

int ip_client_set_pseudo_header_data_length ( void *  header,
size_t  headerlen,
size_t  data_length 
)

Updates the IPv4 pseudo header data length field.

Parameters:
[in,out] header The IPv4 pseudo header to be updated.
[in] headerlen The length of the IP pseudo header in bytes.
[in] data_length The data length to be set.
Returns:
EOK on success.

EBADMEM if the header parameter is NULL.

EINVAL if the headerlen parameter is not IPv4 pseudo header length.

Definition at line 249 of file ip_client.c.

int ip_connect_module ( services_t  service  ) 

Connects to the IP module.

Parameters:
service The IP module service. Ignored parameter.
Returns:
The IP module phone on success.

Definition at line 97 of file ip_remote.c.

int ip_device_req_remote ( int  ip_phone,
device_id_t  device_id,
services_t  service 
)

Register the new device.

Register itself as the ip packet receiver. If the device uses ARP registers also the new ARP device.

Parameters:
[in] ip_phone The IP module phone used for (semi)remote calls.
[in] device_id The new device identifier.
[in] netif The underlying device network interface layer service.
Returns:
EOK on success.

ENOMEM if there is not enough memory left.

EINVAL if the device configuration is invalid.

ENOTSUP if the device uses IPv6.

ENOTSUP if the device uses DHCP.

Other error codes as defined for the net_get_device_conf_req() function.

Other error codes as defined for the arp_device_req() function.

Definition at line 120 of file ip_remote.c.

int ip_get_route_req_remote ( int  ip_phone,
ip_protocol_t  protocol,
const struct sockaddr destination,
socklen_t  addrlen,
device_id_t device_id,
void **  header,
size_t headerlen 
)

Return the device identifier and the IP pseudo header based on the destination address.

Parameters:
[in] ip_phone The IP module phone used for (semi)remote calls.
[in] protocol The transport protocol.
[in] destination The destination address.
[in] addrlen The destination address length.
[out] device_id The device identifier.
[out] header The constructed IP pseudo header.
[out] headerlen The IP pseudo header length.

Definition at line 139 of file ip_remote.c.

int ip_packet_size_req_remote ( int  ip_phone,
device_id_t  device_id,
packet_dimension_t packet_dimension 
)

Return the device packet dimension for sending.

Parameters:
[in] ip_phone The IP module phone used for (semi)remote calls.
[in] device_id The device identifier.
[out] packet_dimension The packet dimension.
Returns:
EOK on success.

ENOENT if there is no such device.

Other error codes as defined for the generic_packet_size_req_remote() function.

Definition at line 187 of file ip_remote.c.

int ip_received_error_msg_remote ( int  ip_phone,
device_id_t  device_id,
packet_t packet,
services_t  target,
services_t  error 
)

Notify the IP module about the received error notification packet.

Parameters:
[in] ip_phone The IP module phone used for (semi)remote calls.
[in] device_id The device identifier.
[in] packet The received packet or the received packet queue.
[in] target The target internetwork module service to be delivered to.
[in] error The packet error reporting service. Prefixes the received packet.
Returns:
EOK on success.

Definition at line 205 of file ip_remote.c.

int ip_send_msg_remote ( int  ip_phone,
device_id_t  device_id,
packet_t packet,
services_t  sender,
services_t  error 
)

Send the packet queue.

The packets may get fragmented if needed.

Parameters:
[in] ip_phone The IP module phone used for (semi)remote calls.
[in] device_id The device identifier.
[in] packet The packet fragments as a packet queue. All the packets have to have the same destination address.
[in] sender The sending module service.
[in] error The packet error reporting service. Prefixes the received packet.
Returns:
EOK on success.

Other error codes as defined for the generic_send_msg() function.

Definition at line 227 of file ip_remote.c.

int ip_set_gateway_req_remote ( int  ip_phone,
device_id_t  device_id,
in_addr_t  gateway 
)

Set the default gateway.

This gateway is used if no other route is found.

Parameters:
[in] ip_phone The IP module phone used for (semi)remote calls.
[in] device_id The device identifier.
[in] gateway The default gateway.

Definition at line 242 of file ip_remote.c.

eth_type_t lsap_map ( eth_lsap_t  lsap  ) 

Maps the link service access point identifier to the Ethernet protocol identifier.

Parameters:
[in] lsap Link service access point identifier.
Returns:
Ethernet protocol identifier of the link service access point identifier.

ETH_LSAP_NULL if mapping is not found.

Definition at line 100 of file protocol_map.c.

eth_lsap_t lsap_unmap ( eth_type_t  ethertype  ) 

Maps the Ethernet protocol identifier to the link service access point identifier.

Parameters:
[in] ethertype Ethernet protocol identifier.
Returns:
Link service access point identifier.

Zero if mapping is not found.

Definition at line 119 of file protocol_map.c.

int net_connect_module ( void   ) 

Connects to the networking module.

Returns:
The networking module phone on success.

Definition at line 53 of file net_remote.c.

void net_free_settings ( measured_string_t settings,
uint8_t *  data 
)

Frees the received settings.

Parameters:
[in] settings The received settings.
[in] data The received settings data.
See also:
net_get_device_conf_req()

net_get_conf_req()

Definition at line 65 of file net_remote.c.

int net_get_conf_req ( int  net_phone,
measured_string_t **  configuration,
size_t  count,
uint8_t **  data 
)

Returns the global configuration.

The configuration names are read and the appropriate settings are set instead. Call net_free_settings() function to release the returned configuration.

Parameters:
[in] net_phone The networking module phone.
[in,out] configuration The requested configuration. The names are read and the appropriate settings are set instead.
[in] count The configuration entries count.
[in,out] data The configuration and settings data.
Returns:
EOK on success.

EINVAL if the configuration is NULL.

EINVAL if the count is zero.

Other error codes as defined for the generic_translate_req() function.

Definition at line 92 of file net_remote.c.

int net_get_device_conf_req ( int  net_phone,
device_id_t  device_id,
measured_string_t **  configuration,
size_t  count,
uint8_t **  data 
)

Returns the device specific configuration.

Returns the global configuration if the device specific is not found. The configuration names are read and the appropriate settings are set instead. Call net_free_settings() function to release the returned configuration.

Parameters:
[in] net_phone The networking module phone.
[in] device_id The device identifier.
[in,out] configuration The requested device configuration. The names are read and the appropriate settings are set instead.
[in] count The configuration entries count.
[in,out] data The configuration and settings data.
Returns:
EOK on success.

EINVAL if the configuration is NULL.

EINVAL if the count is zero.

Other error codes as defined for the generic_translate_req() function.

Definition at line 119 of file net_remote.c.

task_id_t net_spawn ( const uint8_t *  fname  ) 

Start the given module.

Parameters:
[in] fname The module full or relative path filename.
Returns:
The new module task identifier on success.

Zero if there is no such module.

Definition at line 133 of file module_map.c.

int netif_bind_service ( services_t  service,
device_id_t  device_id,
services_t  me,
async_client_conn_t  receiver 
)

Create bidirectional connection with the network interface module.

Create bidirectional connection with the network interface module and register the message receiver.

Parameters:
[in] service The network interface module service.
[in] device_id The device identifier.
[in] me The requesting module service.
[in] receiver The message receiver.
Returns:
The phone of the needed service.

EOK on success.

Other error codes as defined for the bind_service() function.

Definition at line 182 of file netif_remote.c.

static void netif_client_connection ( ipc_callid_t  iid,
ipc_call_t icall 
) [static]

Default fibril for new module connections.

Parameters:
[in] iid Initial message identifier.
[in] icall Initial message call structure.

Definition at line 364 of file netif_skel.c.

int netif_get_addr_message ( device_id_t  device_id,
measured_string_t address 
)

Return the device local hardware address.

This has to be implemented in user code.

Parameters:
[in] device_id Device identifier.
[out] address Device local hardware address.
Returns:
EOK on success.

EBADMEM if the address parameter is NULL.

ENOENT if there no such device.

Other error codes as defined for the find_device() function.

Other error codes as defined for the specific module message implementation.

Definition at line 236 of file ne2000.c.

int netif_get_addr_req ( int  netif_phone,
device_id_t  device_id,
measured_string_t **  address,
uint8_t **  data 
)

Return the device local hardware address.

Parameters:
[in] netif_phone Network interface phone.
[in] device_id Device identifier.
[out] address Device local hardware address.
[out] data Address data.
Returns:
EOK on success.

EBADMEM if the address parameter is NULL.

ENOENT if there no such device.

Other error codes as defined for the netif_get_addr_message() function.

Definition at line 63 of file netif_remote.c.

int netif_get_device_stats ( device_id_t  device_id,
device_stats_t stats 
)

Return the device usage statistics.

This has to be implemented in user code.

Parameters:
[in] device_id Device identifier.
[out] stats Device usage statistics.
Returns:
EOK on success.

Other error codes as defined for the find_device() function.

Other error codes as defined for the specific module message implementation.

Definition at line 220 of file ne2000.c.

int netif_initialize ( void   ) 

Initialize the specific module.

This function has to be implemented in user code.

Definition at line 380 of file ne2000.c.

static int netif_module_message ( ipc_callid_t  callid,
ipc_call_t call,
ipc_call_t answer,
size_t count 
) [static]

Process the netif module messages.

Parameters:
[in] callid Mmessage identifier.
[in] call Message.
[out] answer Answer.
[out] count Number of arguments of the answer.
Returns:
EOK on success.

ENOTSUP if the message is unknown.

Other error codes as defined for each specific module message function.

See also:
IS_NET_NETIF_MESSAGE()

Definition at line 279 of file netif_skel.c.

int netif_module_start ( void   ) 

Start the network interface module.

Initialize the client connection serving function, initialize the module, registers the module service and start the async manager, processing IPC messages in an infinite loop.

Returns:
EOK on success.

Other error codes as defined for each specific module message function.

Definition at line 407 of file netif_skel.c.

packet_t * netif_packet_get_1 ( size_t  content  ) 

Allocate new packet to handle the given content size.

Parameters:
[in] content Minimum content size.
Returns:
The allocated packet.

NULL on error.

Definition at line 232 of file netif_skel.c.

void netif_pq_release ( packet_id_t  packet_id  ) 

Release the given packet.

Prepared for future optimization.

Parameters:
[in] packet_id The packet identifier.

Definition at line 219 of file netif_skel.c.

int netif_probe_message ( device_id_t  device_id,
int  irq,
void *  io 
)

Probe the existence of the device.

This has to be implemented in user code.

Parameters:
[in] device_id Device identifier.
[in] irq Device interrupt number.
[in] io Device input/output address.
Returns:
EOK on success.

Other error codes as defined for the find_device() function.

Other error codes as defined for the specific module message implementation.

Definition at line 253 of file ne2000.c.

int netif_probe_req ( int  netif_phone,
device_id_t  device_id,
int  irq,
void *  io 
)

Probe the existence of the device.

Parameters:
[in] netif_phone Network interface phone.
[in] device_id Device identifier.
[in] irq Device interrupt number.
[in] io Device input/output address.
Returns:
EOK on success.

Other error codes as defined for the netif_probe_message().

Definition at line 82 of file netif_remote.c.

static int netif_probe_req_local ( int  netif_phone,
device_id_t  device_id,
int  irq,
void *  io 
) [static]

Probe the existence of the device.

Parameters:
[in] netif_phone Network interface phone.
[in] device_id Device identifier.
[in] irq Device interrupt number.
[in] io Device input/output address.
Returns:
EOK on success.

Other error codes as defined for the netif_probe_message().

Definition at line 73 of file netif_skel.c.

int netif_send_message ( device_id_t  device_id,
packet_t packet,
services_t  sender 
)

Send the packet queue.

This has to be implemented in user code.

Parameters:
[in] device_id Device identifier.
[in] packet Packet queue.
[in] sender Sending module service.
Returns:
EOK on success.

EFORWARD if the device is not active (in the NETIF_ACTIVE state).

Other error codes as defined for the find_device() function.

Other error codes as defined for the specific module message implementation.

Definition at line 351 of file ne2000.c.

int netif_send_msg ( int  netif_phone,
device_id_t  device_id,
packet_t packet,
services_t  sender 
)

Send the packet queue.

Parameters:
[in] netif_phone Network interface phone.
[in] device_id Device identifier.
[in] packet Packet queue.
[in] sender Sending module service.
Returns:
EOK on success.

Other error codes as defined for the generic_send_msg() function.

Definition at line 100 of file netif_remote.c.

static int netif_send_msg_local ( int  netif_phone,
device_id_t  device_id,
packet_t packet,
services_t  sender 
) [static]

Send the packet queue.

Parameters:
[in] netif_phone Network interface phone.
[in] device_id Device identifier.
[in] packet Packet queue.
[in] sender Sending module service.
Returns:
EOK on success.

Other error codes as defined for the generic_send_msg() function.

Definition at line 95 of file netif_skel.c.

int netif_specific_message ( ipc_callid_t  callid,
ipc_call_t call,
ipc_call_t answer,
size_t count 
)

Process the netif driver specific message.

This function is called for uncommon messages received by the netif skeleton. This has to be implemented in user code.

Parameters:
[in] callid Message identifier.
[in] call Message.
[out] answer Answer.
[out] count Number of answer arguments.
Returns:
EOK on success.

ENOTSUP if the message is not known.

Other error codes as defined for the specific module message implementation.

Definition at line 214 of file ne2000.c.

int netif_start_message ( netif_device_t device  ) 

Start the device.

This has to be implemented in user code.

Parameters:
[in] device Device structure.
Returns:
New network interface state (non-negative values).

Other error codes as defined for the find_device() function.

Other error codes as defined for the specific module message implementation.

Definition at line 308 of file ne2000.c.

int netif_start_req ( int  netif_phone,
device_id_t  device_id 
)

Start the device.

Parameters:
[in] netif_phone Network interface phone.
[in] device_id Device identifier.
Returns:
EOK on success.

Other error codes as defined for the find_device() function.

Other error codes as defined for the netif_start_message() function.

Definition at line 119 of file netif_remote.c.

static int netif_start_req_local ( int  netif_phone,
device_id_t  device_id 
) [static]

Start the device.

Parameters:
[in] netif_phone Network interface phone.
[in] device_id Device identifier.
Returns:
EOK on success.

Other error codes as defined for the find_device() function.

Other error codes as defined for the netif_start_message() function.

Definition at line 117 of file netif_skel.c.

int netif_stats_req ( int  netif_phone,
device_id_t  device_id,
device_stats_t stats 
)

Return the device usage statistics.

Parameters:
[in] netif_phone Network interface phone.
[in] device_id Device identifier.
[out] stats Device usage statistics.
Returns:
EOK on success.

Definition at line 150 of file netif_remote.c.

int netif_stop_message ( netif_device_t device  ) 

Stop the device.

This has to be implemented in user code.

Parameters:
[in] device Device structure.
Returns:
EOK on success.

Other error codes as defined for the find_device() function.

Other error codes as defined for the specific module message implementation.

Definition at line 338 of file ne2000.c.

int netif_stop_req ( int  netif_phone,
device_id_t  device_id 
)

Stop the device.

Parameters:
[in] netif_phone Network interface phone.
[in] device_id Device identifier.
Returns:
EOK on success.

Other error codes as defined for the find_device() function.

Other error codes as defined for the netif_stop_message() function.

Definition at line 136 of file netif_remote.c.

static int netif_stop_req_local ( int  netif_phone,
device_id_t  device_id 
) [static]

Stop the device.

Parameters:
[in] netif_phone Network interface phone.
[in] device_id Device identifier.
Returns:
EOK on success.

Other error codes as defined for the find_device() function.

Other error codes as defined for the netif_stop_message() function.

Definition at line 153 of file netif_skel.c.

static void nil_client_connection ( ipc_callid_t  iid,
ipc_call_t icall 
) [static]

Default thread for new connections.

Parameters:
[in] iid The initial message identifier.
[in] icall The initial message call structure.

Definition at line 50 of file nil_skel.c.

int nil_device_state_msg ( int  nil_phone,
device_id_t  device_id,
int  state 
)

Notify the network interface layer about the device state change.

Parameters:
[in] nil_phone Network interface layer phone.
[in] device_id Device identifier.
[in] state New device state.
Returns:
EOK on success.

Other error codes as defined for each specific module device state function.

Definition at line 56 of file nil_remote.c.

int nil_device_state_msg_local ( int  ,
device_id_t  ,
int   
)

Notify the network interface layer about the device state change.

This has to be implemented in user code.

Parameters:
[in] nil_phone Network interface layer phone.
[in] device_id Device identifier.
[in] state New device state.
Returns:
EOK on success.

Other error codes as defined for each specific module device state function.

Definition at line 170 of file eth.c.

int nil_initialize ( int  net_phone  ) 

Module initialization.

This has to be implemented in user code.

Parameters:
[in] net_phone Networking module phone.
Returns:
EOK on success.

Other error codes as defined for each specific module initialize function.

Definition at line 189 of file eth.c.

int nil_module_message ( ipc_callid_t  ,
ipc_call_t ,
ipc_call_t ,
size_t  
)

Message processing function.

This has to be implemented in user code.

Parameters:
[in] name Module name.
[in] callid Message identifier.
[in] call Message parameters.
[out] answer Message answer parameters.
[out] count Message answer arguments.
Returns:
EOK on success.

ENOTSUP if the message is not known.

Other error codes as defined for each specific module message function.

See also:
IS_NET_NIL_MESSAGE()

Definition at line 836 of file eth.c.

int nil_module_start ( int  service  ) 

Start the network interface layer module.

Initialize the client connection serving function, initialize the module, register the module service and start the async manager, processing IPC messages in an infinite loop.

Parameters:
[in] service Service identification.
Returns:
EOK on success.

Other error codes as defined for the pm_init() function.

Other error codes as defined for the nil_initialize() function.

Other error codes as defined for the REGISTER_ME() macro function.

Definition at line 102 of file nil_skel.c.

int nil_received_msg ( int  nil_phone,
device_id_t  device_id,
packet_t packet,
services_t  target 
)

Pass the packet queue to the network interface layer.

Process and redistribute the received packet queue to the registered upper layers.

Parameters:
[in] nil_phone Network interface layer phone.
[in] device_id Source device identifier.
[in] packet Received packet or the received packet queue.
[in] target Target service. Ignored parameter.
Returns:
EOK on success.

Other error codes as defined for each specific module received function.

Definition at line 77 of file nil_remote.c.

int nil_received_msg_local ( int  ,
device_id_t  ,
packet_t ,
services_t   
)

Pass the packet queue to the network interface layer.

Process and redistribute the received packet queue to the registered upper layers.

This has to be implemented in user code.

Parameters:
[in] nil_phone Network interface layer phone.
[in] device_id Source device identifier.
[in] packet Received packet or the received packet queue.
[in] target Target service. Ignored parameter.
Returns:
EOK on success.

Other error codes as defined for each specific module received function.

Definition at line 507 of file eth.c.

void null_device_stats ( device_stats_t stats  ) 

Clear the usage statistics.

Parameters:
[in] stats The usage statistics.

Definition at line 207 of file netif_skel.c.

int packet_copy_data ( packet_t packet,
const void *  data,
size_t  length 
)

Copies the specified data to the beginning of the actual packet content.

Pushes the content end if needed.

Parameters:
[in] packet The packet to be filled.
[in] data The data to be copied.
[in] length The length of the copied data.
Returns:
EOK on success.

EINVAL if the packet is not valid.

ENOMEM if there is not enough memory left.

Definition at line 59 of file packet_client.c.

packet_t * packet_get_1_remote ( int  phone,
size_t  content 
)

Obtains the packet of the given content size.

Contacts the packet server to return the appropriate packet.

Parameters:
[in] phone The packet server module phone.
[in] content The maximal content length in bytes.
Returns:
The packet reference.

NULL on error.

Definition at line 181 of file packet_remote.c.

packet_t * packet_get_4_remote ( int  phone,
size_t  max_content,
size_t  addr_len,
size_t  max_prefix,
size_t  max_suffix 
)

Obtains the packet of the given dimensions.

Contacts the packet server to return the appropriate packet.

Parameters:
[in] phone The packet server module phone.
[in] addr_len The source and destination addresses maximal length in bytes.
[in] max_prefix The maximal prefix length in bytes.
[in] max_content The maximal content length in bytes.
[in] max_suffix The maximal suffix length in bytes.
Returns:
The packet reference.

NULL on error.

Definition at line 149 of file packet_remote.c.

int packet_get_addr ( const packet_t packet,
uint8_t **  src,
uint8_t **  dest 
)

Returns the stored packet addresses and their length.

Parameters:
[in] packet The packet.
[out] src The source address. May be NULL if not desired.
[out] dest The destination address. May be NULL if not desired.
Returns:
The stored addresses length.

Zero if the addresses are not present.

EINVAL if the packet is not valid.

Definition at line 159 of file packet_client.c.

packet_t * packet_get_copy ( int  phone,
packet_t packet 
)

Returns the packet copy.

Copies the addresses, data, order and metric values. Does not copy the queue placement.

Parameters:
[in] phone The packet server module phone.
[in] packet The original packet.
Returns:
The packet copy.

NULL on error.

Definition at line 259 of file packet_client.c.

void * packet_get_data ( const packet_t packet  ) 

Returns the pointer to the beginning of the packet content.

Parameters:
[in] packet The packet.
Returns:
The pointer to the beginning of the packet content.

NULL if the packet is not valid.

Definition at line 193 of file packet_client.c.

size_t packet_get_data_length ( const packet_t packet  ) 

Returns the packet content length.

Parameters:
[in] packet The packet.
Returns:
The packet content length in bytes.

Zero if the packet is not valid.

Definition at line 179 of file packet_client.c.

packet_id_t packet_get_id ( const packet_t packet  ) 

Returns the packet identifier.

Parameters:
[in] packet The packet.
Returns:
The packet identifier.

Zero if the packet is not valid.

Definition at line 145 of file packet_client.c.

void * packet_prefix ( packet_t packet,
size_t  length 
)

Allocates the specified space right before the actual packet content and returns its pointer.

Parameters:
[in] packet The packet to be used.
[in] length The space length to be allocated at the beginning of the packet content.
Returns:
The pointer to the allocated memory.

NULL if there is not enough memory left.

Definition at line 83 of file packet_client.c.

static int packet_return ( int  phone,
packet_t **  packet,
packet_id_t  packet_id,
size_t  size 
) [static]

Obtain the packet from the packet server as the shared memory block.

Create the local packet mapping as well.

Parameters:
[in] phone The packet server module phone.
[out] packet The packet reference pointer to store the received packet reference.
[in] packet_id The packet identifier.
[in] size The packet total size in bytes.
Returns:
EOK on success.

Other error codes as defined for the pm_add() function.

Other error codes as defined for the async_share_in_start() function.

Definition at line 65 of file packet_remote.c.

int packet_set_addr ( packet_t packet,
const uint8_t *  src,
const uint8_t *  dest,
size_t  addr_len 
)

Sets the packet addresses.

Parameters:
[in] packet The packet.
[in] src The new source address. May be NULL.
[in] dest The new destination address. May be NULL.
[in] addr_len The addresses length.
Returns:
EOK on success.

EINVAL if the packet is not valid.

ENOMEM if there is not enough memory left.

Definition at line 212 of file packet_client.c.

void * packet_suffix ( packet_t packet,
size_t  length 
)

Allocates the specified space right after the actual packet content and returns its pointer.

Parameters:
[in] packet The packet to be used.
[in] length The space length to be allocated at the end of the packet content.
Returns:
The pointer to the allocated memory.

NULL if there is not enough memory left.

Definition at line 104 of file packet_client.c.

int packet_translate_remote ( int  phone,
packet_t **  packet,
packet_id_t  packet_id 
)

Translates the packet identifier to the packet reference.

Tries to find mapping first. Contacts the packet server to share the packet if the mapping is not present.

Parameters:
[in] phone The packet server module phone.
[out] packet The packet reference.
[in] packet_id The packet identifier.
Returns:
EOK on success.

EINVAL if the packet parameter is NULL.

Other error codes as defined for the NET_PACKET_GET_SIZE message.

Other error codes as defined for the packet_return() function.

Definition at line 108 of file packet_remote.c.

int packet_trim ( packet_t packet,
size_t  prefix,
size_t  suffix 
)

Trims the actual packet content by the specified prefix and suffix lengths.

Parameters:
[in] packet The packet to be trimmed.
[in] prefix The prefix length to be removed from the beginning of the packet content.
[in] suffix The suffix length to be removed from the end of the packet content.
Returns:
EOK on success.

EINVAL if the packet is not valid.

ENOMEM if there is not enough memory left.

Definition at line 126 of file packet_client.c.

void pq_release_remote ( int  phone,
packet_id_t  packet_id 
)

Releases the packet queue.

All packets in the queue are marked as free for use. The packet queue may be one packet only. The module should not use the packets after this point until they are received or obtained again.

Parameters:
[in] phone The packet server module phone.
[in] packet_id The packet identifier.

Definition at line 212 of file packet_remote.c.

eth_type_t protocol_map ( services_t  nil,
services_t  il 
)

Maps the internetwork layer service to the network interface layer type.

Parameters:
[in] nil Network interface layer service.
[in] il Internetwork layer service.
Returns:
Network interface layer type of the internetworking layer service.

Zero if mapping is not found.

Definition at line 48 of file protocol_map.c.

services_t protocol_unmap ( services_t  nil,
int  protocol 
)

Maps the network interface layer type to the internetwork layer service.

Parameters:
[in] nil Network interface layer service.
[in] protocol Network interface layer type.
Returns:
Internetwork layer service of the network interface layer type.

Zero if mapping is not found.

Definition at line 74 of file protocol_map.c.

static int register_message ( device_id_t  device_id,
int  phone 
) [static]

Register the device notification receiver,.

Register a network interface layer module as the device notification receiver.

Parameters:
[in] device_id Device identifier.
[in] phone Network interface layer module phone.
Returns:
EOK on success.

ENOENT if there is no such device.

ELIMIT if there is another module registered.

Definition at line 250 of file netif_skel.c.

int socket_bind ( socket_cores_t *  local_sockets,
socket_ports_t *  global_sockets,
int  socket_id,
void *  addr,
size_t  addrlen,
int  free_ports_start,
int  free_ports_end,
int  last_used_port 
)

Binds the socket to the port.

The address port is used if set, a free port is used if not.

Parameters:
[in] local_sockets The local sockets to be searched.
[in,out] global_sockets The global sockets to be updated.
[in] socket_id The new socket identifier.
[in] addr The address to be bound to.
[in] addrlen The address length.
[in] free_ports_start The minimum free port.
[in] free_ports_end The maximum free port.
[in] last_used_port The last used free port.
Returns:
EOK on success.

ENOTSOCK if the socket was not found.

EAFNOSUPPORT if the address family is not supported.

EADDRINUSE if the port is already in use.

Other error codes as defined for the socket_bind_free_port() function.

Other error codes as defined for the socket_bind_insert() function.

Definition at line 260 of file socket_core.c.

int socket_bind_free_port ( socket_ports_t *  global_sockets,
socket_core_t socket,
int  free_ports_start,
int  free_ports_end,
int  last_used_port 
)

Binds the socket to a free port.

The first free port is used.

Parameters:
[in,out] global_sockets The global sockets to be updated.
[in,out] socket The socket to be bound.
[in] free_ports_start The minimum free port.
[in] free_ports_end The maximum free port.
[in] last_used_port The last used free port.
Returns:
EOK on success.

ENOTCONN if no free port was found.

Other error codes as defined for the socket_bind_insert() function.

Definition at line 330 of file socket_core.c.

static int socket_bind_insert ( socket_ports_t *  global_sockets,
socket_core_t socket,
int  port 
) [static]

Binds the socket to the port.

The SOCKET_MAP_KEY_LISTENING key identifier is used.

Parameters:
[in] global_sockets The global sockets to be updated.
[in] socket The socket to be added.
[in] port The port number to be bound to.
Returns:
EOK on success.

ENOMEM if there is not enough memory left.

Other error codes as defined for the socket_ports_add() function.

Definition at line 202 of file socket_core.c.

void socket_cores_release ( int  packet_phone,
socket_cores_t *  local_sockets,
socket_ports_t *  global_sockets,
void(*)(socket_core_t *socket socket_release 
)

Destroys local sockets.

Releases all buffered packets and calls the release function for each of the sockets.

Parameters:
[in] packet_phone The packet server phone to release buffered packets.
[in] local_sockets The local sockets to be destroyed.
[in,out] global_sockets The global sockets to be updated.
[in] socket_release The client release callback function.

Definition at line 123 of file socket_core.c.

int socket_create ( socket_cores_t *  local_sockets,
int  app_phone,
void *  specific_data,
int *  socket_id 
)

Creates a new socket.

Parameters:
[in,out] local_sockets The local sockets to be updated.
[in] app_phone The application phone.
[in] specific_data The socket specific data.
[in,out] socket_id The new socket identifier. A new identifier is chosen if set to zero or negative. A negative identifier is chosen if set to negative.
Returns:
EOK on success.

EINVAL if the socket_id parameter is NULL.

ENOMEM if there is not enough memory left.

Definition at line 421 of file socket_core.c.

int socket_destroy ( int  packet_phone,
int  socket_id,
socket_cores_t *  local_sockets,
socket_ports_t *  global_sockets,
void(*)(socket_core_t *socket socket_release 
)

Destroys the socket.

If the socket is bound, the port is released. Releases all buffered packets, calls the release function and removes the socket from the local sockets.

Parameters:
[in] packet_phone The packet server phone to release buffered packets.
[in] socket_id The socket identifier.
[in,out] local_sockets The local sockets to be updated.
[in,out] global_sockets The global sockets to be updated.
[in] socket_release The client release callback function.
Returns:
EOK on success.

ENOTSOCK if the socket is not found.

Definition at line 492 of file socket_core.c.

static void socket_destroy_core ( int  packet_phone,
socket_core_t socket,
socket_cores_t *  local_sockets,
socket_ports_t *  global_sockets,
void(*)(socket_core_t *socket socket_release 
) [static]

Destroys the socket.

If the socket is bound, the port is released. Releases all buffered packets, calls the release function and removes the socket from the local sockets.

Parameters:
[in] packet_phone The packet server phone to release buffered packets.
[in] socket The socket to be destroyed.
[in,out] local_sockets The local sockets to be updated.
[in,out] global_sockets The global sockets to be updated.
[in] socket_release The client release callback function.

Definition at line 87 of file socket_core.c.

static int socket_generate_new_id ( socket_cores_t *  local_sockets,
int  positive 
) [static]

Tries to find a new free socket identifier.

Parameters:
[in] local_sockets The local sockets to be searched.
[in] positive A value indicating whether a positive identifier is requested. A negative identifier is requested if set to false.
Returns:
The new socket identifier.

ELIMIT if there is no socket identifier available.

Definition at line 372 of file socket_core.c.

int socket_port_add ( socket_ports_t *  global_sockets,
int  port,
socket_core_t socket,
const uint8_t *  key,
size_t  key_length 
)

Adds the socket to an already bound port.

Parameters:
[in] global_sockets The global sockets to be updated.
[in] port The port number to be bound to.
[in] socket The socket to be added.
[in] key The socket key identifier.
[in] key_length The socket key length.
Returns:
EOK on success.

ENOENT if the port is not already used.

Other error codes as defined for the socket_port_add_core() function.

Definition at line 685 of file socket_core.c.

static int socket_port_add_core ( socket_port_t socket_port,
socket_core_t socket,
const uint8_t *  key,
size_t  key_length 
) [static]

Adds the socket to a socket port.

Parameters:
[in,out] socket_port The socket port structure.
[in] socket The socket to be added.
[in] key The socket key identifier.
[in] key_length The socket key length.
Returns:
EOK on success.

ENOMEM if there is not enough memory left.

Definition at line 162 of file socket_core.c.

socket_core_t * socket_port_find ( socket_ports_t *  global_sockets,
int  port,
const uint8_t *  key,
size_t  key_length 
)

Finds the bound port socket.

Parameters:
[in] global_sockets The global sockets to be searched.
[in] port The port number.
[in] key The socket key identifier.
[in] key_length The socket key length.
Returns:
The found socket.

NULL if no socket was found.

Definition at line 608 of file socket_core.c.

void socket_port_release ( socket_ports_t *  global_sockets,
socket_core_t socket 
)

Releases the socket port.

If the socket is bound the port entry is released. If there are no more port entries the port is release.

Parameters:
[in] global_sockets The global sockets to be updated.
[in] socket The socket to be unbound.

Definition at line 634 of file socket_core.c.

int socket_reply_packets ( packet_t packet,
size_t length 
)

Replies the packet or the packet queue data to the application via the socket.

Uses the current message processing fibril.

Parameters:
[in] packet The packet to be transfered.
[out] length The total data length.
Returns:
EOK on success.

EBADMEM if the length parameter is NULL.

ENOMEM if there is not enough memory left.

Other error codes as defined for the data_reply() function.

Definition at line 528 of file socket_core.c.

static void tl_client_connection ( ipc_callid_t  iid,
ipc_call_t icall 
) [static]

Default thread for new connections.

Parameters:
[in] iid The initial message identifier.
[in] icall The initial message call structure.

Definition at line 50 of file tl_skel.c.

void tl_connection ( void   ) 

Per-connection module initialization.

Initialize client-specific global variables.

Definition at line 709 of file icmp.c.

int tl_get_address_port ( const struct sockaddr addr,
int  addrlen,
uint16_t *  port 
)

Gets the address port.

Supports AF_INET and AF_INET6 address families.

Parameters:
[in,out] addr The address to be updated.
[in] addrlen The address length.
[out] port The set port.
Returns:
EOK on success.

EINVAL if the address length does not match the address family.

EAFNOSUPPORT if the address family is not supported.

Definition at line 72 of file tl_common.c.

int tl_get_ip_packet_dimension ( int  ip_phone,
packet_dimensions_t *  packet_dimensions,
device_id_t  device_id,
packet_dimension_t **  packet_dimension 
)

Get IP packet dimensions.

Try to search a cache and query the IP module if not found. The reply is cached then.

Parameters:
[in] ip_phone The IP moduel phone for (semi)remote calls.
[in] packet_dimensions The packet dimensions cache.
[in] device_id The device identifier.
[out] packet_dimension The IP packet dimensions.
Returns:
EOK on success.

EBADMEM if the packet_dimension parameter is NULL.

ENOMEM if there is not enough memory left.

EINVAL if the packet_dimensions cache is not valid.

Other codes as defined for the ip_packet_size_req() function.

Definition at line 121 of file tl_common.c.

int tl_initialize ( int  net_phone  ) 

Module initialization.

Parameters:
[in] net_phone Network module phone.
Returns:
EOK on success.

ENOMEM if there is not enough memory left.

Definition at line 650 of file icmp.c.

int tl_message ( ipc_callid_t  callid,
ipc_call_t call,
ipc_call_t answer,
size_t answer_count 
)

Process the transport layer module message.

Parameters:
[in] callid The message identifier.
[in] call The message parameters.
[out] answer The message answer parameters.
[out] answer_count The last parameter for the actual answer in the answer parameter.
Returns:
EOK on success.

ENOTSUP if the message is not known.

See also:
udp_interface.h

IS_NET_UDP_MESSAGE()

Definition at line 739 of file icmp.c.

int tl_module_start ( int  service  ) 

Start the trasport layer module.

Initialize the client connection serving function, initialize the module, register the module service and start the async manager, processing IPC messages in an infinite loop.

Parameters:
[in] service Service identification.
Returns:
EOK on success.

Other error codes as defined for the pm_init() function.

Other error codes as defined for the il_initialize() function.

Other error codes as defined for the REGISTER_ME() macro function.

Definition at line 104 of file tl_skel.c.

int tl_prepare_icmp_packet ( int  packet_phone,
int  icmp_phone,
packet_t packet,
services_t  error 
)

Prepares the packet for ICMP error notification.

Keeps the first packet and releases all the others. Releases all the packets on error.

Parameters:
[in] packet_phone The packet server module phone.
[in] icmp_phone The ICMP module phone.
[in] packet The packet to be send.
[in] error The packet error reporting service. Prefixes the received packet.
Returns:
EOK on success.

ENOENT if no packet may be sent.

Definition at line 250 of file tl_common.c.

int tl_received_msg ( int  tl_phone,
device_id_t  device_id,
packet_t packet,
services_t  target,
services_t  error 
)

Notify the remote transport layer modules about the received packet/s.

Parameters:
[in] tl_phone The transport layer module phone used for remote calls.
[in] device_id The device identifier.
[in] packet The received packet or the received packet queue. The packet queue is used to carry a fragmented datagram. The first packet contains the headers, the others contain only data.
[in] target The target transport layer module service to be delivered to.
[in] error The packet error reporting service. Prefixes the received packet.
Returns:
EOK on success.

Definition at line 59 of file tl_remote.c.

int tl_set_address_port ( struct sockaddr addr,
int  addrlen,
uint16_t  port 
)

Sets the address port.

Supports AF_INET and AF_INET6 address families.

Parameters:
[in,out] addr The address to be updated.
[in] addrlen The address length.
[in] port The port to be set.
Returns:
EOK on success.

EINVAL if the address length does not match the address family.

EAFNOSUPPORT if the address family is not supported.

Definition at line 203 of file tl_common.c.

int tl_socket_read_packet_data ( int  packet_phone,
packet_t **  packet,
size_t  prefix,
const packet_dimension_t dimension,
const struct sockaddr addr,
socklen_t  addrlen 
)

Receives data from the socket into a packet.

Parameters:
[in] packet_phone The packet server module phone.
[out] packet The new created packet.
[in] prefix Reserved packet data prefix length.
[in] dimension The packet dimension.
[in] addr The destination address.
[in] addrlen The address length.
Returns:
Number of bytes received.

EINVAL if the client does not send data.

ENOMEM if there is not enough memory left.

Other error codes as defined for the async_data_read_finalize() function.

Definition at line 291 of file tl_common.c.

int tl_update_ip_packet_dimension ( packet_dimensions_t *  packet_dimensions,
device_id_t  device_id,
size_t  content 
)

Updates IP device packet dimensions cache.

Parameters:
[in,out] packet_dimensions The packet dimensions cache.
[in] device_id The device identifier.
[in] content The new maximum content size.
Returns:
EOK on success.

ENOENT if the packet dimension is not cached.

Definition at line 164 of file tl_common.c.


Generated on Thu Jun 2 07:45:57 2011 for HelenOS/USB by  doxygen 1.4.7