Changeset f14291b in mainline for uspace/lib/net/include
- Timestamp:
- 2010-10-19T20:55:53Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a93d79a
- Parents:
- 1882525 (diff), a7a85d16 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/lib/net/include
- Files:
-
- 2 added
- 19 edited
- 1 moved
-
adt/module_map.h (modified) (1 diff)
-
arp_interface.h (modified) (1 diff)
-
generic.h (moved) (moved from uspace/lib/socket/generic/icmp_api.c ) (1 diff)
-
icmp_client.h (modified) (1 diff)
-
icmp_header.h (modified) (1 diff)
-
icmp_interface.h (modified) (1 diff)
-
il_interface.h (modified) (1 diff)
-
ip_client.h (modified) (1 diff)
-
ip_interface.h (modified) (3 diffs)
-
ip_remote.h (modified) (1 diff)
-
net_checksum.h (modified) (1 diff)
-
net_interface.h (modified) (1 diff)
-
netif_interface.h (modified) (2 diffs)
-
netif_local.h (modified) (2 diffs)
-
netif_remote.h (modified) (1 diff)
-
nil_interface.h (modified) (2 diffs)
-
nil_remote.h (modified) (1 diff)
-
packet_client.h (added)
-
packet_remote.h (modified) (1 diff)
-
socket_core.h (added)
-
tl_common.h (modified) (1 diff)
-
tl_interface.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/include/adt/module_map.h
r1882525 rf14291b 27 27 */ 28 28 29 /** @addtogroup net30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Character string to module map.34 * Character string to module map. 35 35 */ 36 36 37 #ifndef __NET_MODULES_MAP_H__38 #define __NET_MODULES_MAP_H__37 #ifndef LIBNET_MODULES_MAP_H_ 38 #define LIBNET_MODULES_MAP_H_ 39 39 40 40 #include <task.h> 41 42 41 #include <ipc/services.h> 43 44 #include <net_modules.h> 45 42 #include <net/modules.h> 46 43 #include <adt/generic_char_map.h> 47 44 48 45 /** Type definition of the module structure. 49 * @see module_struct46 * @see module_struct 50 47 */ 51 typedef struct module_struct module_t;48 typedef struct module_struct module_t; 52 49 53 50 /** Type definition of the module structure pointer. 54 * @see module_struct51 * @see module_struct 55 52 */ 56 typedef module_t * module_ref;53 typedef module_t *module_ref; 57 54 58 55 /** Module map. 59 * Sorted by module names.60 * @see generic_char_map.h56 * Sorted by module names. 57 * @see generic_char_map.h 61 58 */ 62 59 GENERIC_CHAR_MAP_DECLARE(modules, module_t) 63 60 64 /** Module structure. 65 */ 66 struct module_struct{ 67 /** Module task identifier if running. 68 */ 61 /** Module structure. */ 62 struct module_struct { 63 /** Module task identifier if running. */ 69 64 task_id_t task_id; 70 /** Module service identifier. 71 */ 65 /** Module service identifier. */ 72 66 services_t service; 73 /** Module phone if running and connected. 74 */ 67 /** Module phone if running and connected. */ 75 68 int phone; 76 /** Usage counter. 77 */ 69 /** Usage counter. */ 78 70 int usage; 79 /** Module name. 80 */ 81 const char * name; 82 /** Module full path filename. 83 */ 84 const char * filename; 85 /** Connecting function. 86 */ 87 connect_module_t * connect_module; 71 /** Module name. */ 72 const char *name; 73 /** Module full path filename. */ 74 const char *filename; 75 /** Connecting function. */ 76 connect_module_t *connect_module; 88 77 }; 89 78 90 /** Adds module to the module map. 91 * @param[out] module The module structure added. 92 * @param[in] modules The module map. 93 * @param[in] name The module name. 94 * @param[in] filename The full path filename. 95 * @param[in] service The module service. 96 * @param[in] task_id The module current task identifier. Zero (0) means not running. 97 * @param[in] connect_module The module connecting function. 98 * @returns EOK on success. 99 * @returns ENOMEM if there is not enough memory left. 100 */ 101 int add_module(module_ref * module, modules_ref modules, const char * name, const char * filename, services_t service, task_id_t task_id, connect_module_t * connect_module); 102 103 /** Searches and returns the specified module. 104 * If the module is not running, the module filaname is spawned. 105 * If the module is not connected, the connect_function is called. 106 * @param[in] modules The module map. 107 * @param[in] name The module name. 108 * @returns The running module found. It does not have to be connected. 109 * @returns NULL if there is no such module. 110 */ 111 module_ref get_running_module(modules_ref modules, char * name); 112 113 /** Starts the given module. 114 * @param[in] fname The module full or relative path filename. 115 * @returns The new module task identifier on success. 116 * @returns 0 if there is no such module. 117 */ 118 task_id_t spawn(const char * fname); 79 extern int add_module(module_ref *, modules_ref, const char *, const char *, 80 services_t, task_id_t, connect_module_t *); 81 extern module_ref get_running_module(modules_ref, char *); 82 extern task_id_t spawn(const char *); 119 83 120 84 #endif -
uspace/lib/net/include/arp_interface.h
r1882525 rf14291b 27 27 */ 28 28 29 /** @addtogroup arp30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 #ifndef __NET_ARP_INTERFACE_H__34 #define __NET_ARP_INTERFACE_H__33 #ifndef LIBNET_ARP_INTERFACE_H_ 34 #define LIBNET_ARP_INTERFACE_H_ 35 35 36 36 #include <adt/measured_strings.h> 37 #include <net_device.h> 37 #include <task.h> 38 39 #include <ipc/services.h> 40 41 #include <net/device.h> 42 #include <net/socket.h> 38 43 39 44 /** @name ARP module interface 40 * This interface is used by other modules.45 * This interface is used by other modules. 41 46 */ 42 47 /*@{*/ 43 48 44 /** Registers the new device and the requesting protocol service. 45 * Connects to the network interface layer service. 46 * Determines the device broadcast address, its address lengths and packet size. 47 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 48 * @param[in] device_id The new device identifier. 49 * @param[in] protocol The requesting protocol service. 50 * @param[in] netif The underlying device network interface layer service. 51 * @param[in] address The local requesting protocol address of the device. 52 * @returns EOK on success. 53 * @returns EEXIST if the device is already used. 54 * @returns ENOMEM if there is not enough memory left. 55 * @returns ENOENT if the network interface service is not known. 56 * @returns EREFUSED if the network interface service is not responding. 57 * @returns Other error codes as defined for the nil_packet_get_size() function. 58 * @returns Other error codes as defined for the nil_get_addr() function. 59 * @returns Other error codes as defined for the nil_get_broadcast_addr() function. 60 */ 61 extern int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address); 62 63 /** Translates the given protocol address to the network interface address. 64 * Broadcasts the ARP request if the mapping is not found. 65 * Allocates and returns the needed memory block as the data parameter. 66 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 67 * @param[in] device_id The device identifier. 68 * @param[in] protocol The requesting protocol service. 69 * @param[in] address The local requesting protocol address. 70 * @param[out] translation The translation of the local protocol address. 71 * @param[out] data The allocated raw translation data container. 72 * @returns EOK on success. 73 * @returns EINVAL if the address parameter is NULL. 74 * @returns EBADMEM if the translation or the data parameters are NULL. 75 * @returns ENOENT if the mapping is not found. 76 */ 77 extern int arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data); 78 79 /** Clears the device cache. 80 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 81 * @param[in] device_id The device identifier. 82 * @returns EOK on success. 83 * @returns ENOENT if the device is not found. 84 */ 85 extern int arp_clear_device_req(int arp_phone, device_id_t device_id); 86 87 /** Clears the given protocol address from the cache. 88 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 89 * @param[in] device_id The device identifier. 90 * @param[in] protocol The requesting protocol service. 91 * @param[in] address The protocol address to be cleared. 92 * @returns EOK on success. 93 * @returns ENOENT if the mapping is not found. 94 */ 95 extern int arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address); 96 97 /** Cleans the cache. 98 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 99 * @returns EOK on success. 100 */ 101 extern int arp_clean_cache_req(int arp_phone); 102 103 /** Connects to the ARP module. 104 * @param service The ARP module service. Ignored parameter. 105 * @returns The ARP module phone on success. 106 * @returns 0 if called by the bundle module. 107 */ 108 extern int arp_connect_module(services_t service); 109 110 /** Returns the ARP task identifier. 111 * @returns The current task identifier if called by the bundle module. 112 * @returns 0 if called by the remote module. 113 */ 114 extern task_id_t arp_task_get_id(void); 49 extern int arp_device_req(int, device_id_t, services_t, services_t, 50 measured_string_ref); 51 extern int arp_translate_req(int, device_id_t, services_t, measured_string_ref, 52 measured_string_ref *, char **); 53 extern int arp_clear_device_req(int, device_id_t); 54 extern int arp_clear_address_req(int, device_id_t, services_t, 55 measured_string_ref); 56 extern int arp_clean_cache_req(int); 57 extern int arp_connect_module(services_t); 115 58 116 59 /*@}*/ -
uspace/lib/net/include/generic.h
r1882525 rf14291b 27 27 */ 28 28 29 /** @addtogroup icmp30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * ICMP application interface implementation. 35 * @see icmp_api.h 34 * Generic communication interfaces for networking. 36 35 */ 37 36 37 #ifndef LIBNET_GENERIC_H_ 38 #define LIBNET_GENERIC_H_ 39 38 40 #include <async.h> 39 40 41 #include <ipc/ipc.h> 41 42 #include <ipc/services.h> 42 43 43 #include <sys/types.h> 44 #include <net/device.h> 45 #include <adt/measured_strings.h> 46 #include <net/packet.h> 44 47 45 #include <net_modules.h> 46 #include <icmp_api.h> 47 #include <inet.h> 48 #include <ip_codes.h> 49 #include <socket_codes.h> 50 #include <icmp_messages.h> 48 extern int generic_device_state_msg_remote(int, int, device_id_t, int, 49 services_t); 50 extern int generic_device_req_remote(int, int, device_id_t, int, services_t); 51 extern int generic_get_addr_req(int, int, device_id_t, measured_string_ref *, 52 char **); 53 extern int generic_packet_size_req_remote(int, int, device_id_t, 54 packet_dimension_ref); 55 extern int generic_received_msg_remote(int, int, device_id_t, packet_id_t, 56 services_t, services_t); 57 extern int generic_send_msg_remote(int, int, device_id_t, packet_id_t, 58 services_t, services_t); 59 extern int generic_translate_req(int, int, device_id_t, services_t, 60 measured_string_ref, size_t, measured_string_ref *, char **); 51 61 52 int icmp_echo_msg(int icmp_phone, size_t size, mseconds_t timeout, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, const struct sockaddr * addr, socklen_t addrlen){ 53 aid_t message_id; 54 ipcarg_t result; 55 56 if(addrlen <= 0){ 57 return EINVAL; 58 } 59 message_id = async_send_5(icmp_phone, NET_ICMP_ECHO, size, timeout, ttl, tos, (ipcarg_t) dont_fragment, NULL); 60 // send the address 61 async_data_write_start(icmp_phone, addr, (size_t) addrlen); 62 // timeout version may cause inconsistency - there is also an inner timer 63 // return async_wait_timeout(message_id, &result, timeout); 64 async_wait_for(message_id, &result); 65 return (int) result; 66 } 62 #endif 67 63 68 64 /** @} -
uspace/lib/net/include/icmp_client.h
r1882525 rf14291b 38 38 #define __NET_ICMP_CLIENT_H__ 39 39 40 #include < icmp_codes.h>41 #include < packet/packet.h>40 #include <net/icmp_codes.h> 41 #include <net/packet.h> 42 42 43 43 /** Processes the received packet prefixed with an ICMP header. -
uspace/lib/net/include/icmp_header.h
r1882525 rf14291b 41 41 #include <sys/types.h> 42 42 43 #include < in.h>44 #include < icmp_codes.h>43 #include <net/in.h> 44 #include <net/icmp_codes.h> 45 45 46 46 /** ICMP header size in bytes. -
uspace/lib/net/include/icmp_interface.h
r1882525 rf14291b 34 34 #define __NET_ICMP_INTERFACE_H__ 35 35 36 #include <net/socket_codes.h> 36 37 #include <sys/types.h> 37 38 38 #include <net _device.h>39 #include <net/device.h> 39 40 #include <adt/measured_strings.h> 40 #include <packet/packet.h> 41 #include <inet.h> 42 #include <ip_codes.h> 43 #include <socket_codes.h> 44 #include <icmp_codes.h> 45 #include <icmp_common.h> 41 #include <net/packet.h> 42 #include <net/inet.h> 43 #include <net/ip_codes.h> 44 #include <net/icmp_codes.h> 45 #include <net/icmp_common.h> 46 46 47 47 /** @name ICMP module interface -
uspace/lib/net/include/il_interface.h
r1882525 rf14291b 39 39 #define __NET_IL_INTERFACE_H__ 40 40 41 #include < async.h>41 #include <generic.h> 42 42 43 43 #include <ipc/services.h> 44 #include <ipc/il.h> 44 45 45 #include <net_messages.h> 46 #include <net_device.h> 47 #include <packet/packet.h> 48 #include <packet/packet_client.h> 49 #include <il_messages.h> 46 #include <net/device.h> 47 #include <net/packet.h> 48 49 #include <packet_client.h> 50 50 51 51 /** @name Internetwork layer module interface -
uspace/lib/net/include/ip_client.h
r1882525 rf14291b 27 27 */ 28 28 29 /** @addtogroup ip30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * IP client interface.34 * IP client interface. 35 35 */ 36 36 37 #ifndef __NET_IP_CLIENT_H__38 #define __NET_IP_CLIENT_H__37 #ifndef LIBNET_IP_CLIENT_H_ 38 #define LIBNET_IP_CLIENT_H_ 39 39 40 #include <net/socket_codes.h> 40 41 #include <sys/types.h> 41 42 42 #include < packet/packet.h>43 #include < ip_codes.h>43 #include <net/packet.h> 44 #include <net/ip_codes.h> 44 45 #include <ip_interface.h> 45 #include <socket_codes.h>46 46 47 /** Prepares the packet to be transfered via IP. 48 * The IP header is prefixed. 49 * @param[in,out] packet The packet to be prepared. 50 * @param[in] protocol The transport protocol. 51 * @param[in] ttl The time to live counter. The IPDEFTTL is set if zero (0). 52 * @param[in] tos The type of service. 53 * @param[in] dont_fragment The value indicating whether fragmentation is disabled. 54 * @param[in] ipopt_length The prefixed IP options length in bytes. 55 * @returns EOK on success. 56 * @returns ENOMEM if there is not enough memory left in the packet. 57 */ 58 extern 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); 59 60 /** Processes the received IP packet. 61 * Fills set header fields. 62 * Returns the prefixed IP header length. 63 * @param[in] packet The received packet. 64 * @param[out] protocol The transport protocol. May be NULL if not desired. 65 * @param[out] ttl The time to live counter. May be NULL if not desired. 66 * @param[out] tos The type of service. May be NULL if not desired. 67 * @param[out] dont_fragment The value indicating whether the fragmentation is disabled. May be NULL if not desired. 68 * @param[out] ipopt_length The IP options length in bytes. May be NULL if not desired. 69 * @returns The prefixed IP header length in bytes on success. 70 * @returns ENOMEM if the packet is too short to contain the IP header. 71 */ 72 extern 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); 73 74 /** Returns the IP header length. 75 * @param[in] packet The packet. 76 * @returns The IP header length in bytes. 77 * @returns Zero (0) if there is no IP header. 78 */ 79 extern size_t ip_client_header_length(packet_t packet); 80 81 /** Updates the IPv4 pseudo header data length field. 82 * @param[in,out] header The IPv4 pseudo header to be updated. 83 * @param[in] headerlen The length of the IP pseudo header in bytes. 84 * @param[in] data_length The data length to be set. 85 * @returns EOK on success. 86 * @returns EBADMEM if the header parameter is NULL. 87 * @returns EINVAL if the headerlen parameter is not IPv4 pseudo header length. 88 */ 89 extern int ip_client_set_pseudo_header_data_length(void *header, size_t headerlen, size_t data_length); 90 91 /** Constructs the IPv4 pseudo header. 92 * @param[in] protocol The transport protocol. 93 * @param[in] src The source address. 94 * @param[in] srclen The source address length. 95 * @param[in] dest The destination address. 96 * @param[in] destlen The destination address length. 97 * @param[in] data_length The data length to be set. 98 * @param[out] header The constructed IPv4 pseudo header. 99 * @param[out] headerlen The length of the IP pseudo header in bytes. 100 * @returns EOK on success. 101 * @returns EBADMEM if the header and/or the headerlen parameter is NULL. 102 * @returns EINVAL if the source address and/or the destination address parameter is NULL. 103 * @returns EINVAL if the source address length is less than struct sockaddr length. 104 * @returns EINVAL if the source address length differs from the destination address length. 105 * @returns EINVAL if the source address family differs from the destination family. 106 * @returns EAFNOSUPPORT if the address family is not supported. 107 * @returns ENOMEM if there is not enough memory left. 108 */ 109 extern 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); 47 extern int ip_client_prepare_packet(packet_t, ip_protocol_t, ip_ttl_t, ip_tos_t, 48 int, size_t); 49 extern int ip_client_process_packet(packet_t, ip_protocol_t *, ip_ttl_t *, 50 ip_tos_t *, int *, size_t *); 51 extern size_t ip_client_header_length(packet_t); 52 extern int ip_client_set_pseudo_header_data_length(void *, size_t, size_t); 53 extern int ip_client_get_pseudo_header(ip_protocol_t, struct sockaddr *, 54 socklen_t, struct sockaddr *, socklen_t, size_t, void **, size_t *); 110 55 111 56 // TODO ipopt manipulation -
uspace/lib/net/include/ip_interface.h
r1882525 rf14291b 34 34 #define __NET_IP_INTERFACE_H__ 35 35 36 #include <net/socket_codes.h> 36 37 #include <async.h> 37 38 #include <ipc/services.h> 38 39 39 #include <net _device.h>40 #include < packet/packet.h>40 #include <net/device.h> 41 #include <net/packet.h> 41 42 42 #include <in.h> 43 #include <ip_codes.h> 44 #include <socket_codes.h> 45 46 #ifdef CONFIG_IL_TL_BUNDLE 47 48 #include <ip_local.h> 49 50 #define ip_received_error_msg ip_received_error_msg_local 51 #define ip_set_gateway_req ip_set_gateway_req_local 52 #define ip_packet_size_req ip_packet_size_req_local 53 #define ip_device_req ip_device_req_local 54 #define ip_add_route_req ip_add_route_req_local 55 #define ip_send_msg ip_send_msg_local 56 #define ip_get_route_req ip_get_route_req_local 57 58 #else 43 #include <net/in.h> 44 #include <net/ip_codes.h> 59 45 60 46 #include <ip_remote.h> … … 67 53 #define ip_send_msg ip_send_msg_remote 68 54 #define ip_get_route_req ip_get_route_req_remote 69 70 #endif71 55 72 56 /** @name IP module interface … … 90 74 * @param[in] me The requesting module service. 91 75 * @param[in] receiver The message receiver. Used for remote connection. 92 * @param[in] tl_received_msg The message processing function. Used if bundled together.93 76 * @returns The phone of the needed service. 94 77 * @returns EOK on success. 95 78 * @returns Other error codes as defined for the bind_service() function. 96 79 */ 97 extern int ip_bind_service(services_t service, int protocol, services_t me, async_client_conn_t receiver , tl_received_msg_t tl_received_msg);80 extern int ip_bind_service(services_t service, int protocol, services_t me, async_client_conn_t receiver); 98 81 99 82 /** Connects to the IP module. 100 83 * @param service The IP module service. Ignored parameter. 101 84 * @returns The IP module phone on success. 102 * @returns 0 if called by the bundle module.103 85 */ 104 86 extern int ip_connect_module(services_t service); -
uspace/lib/net/include/ip_remote.h
r1882525 rf14291b 34 34 #define __NET_IP_REMOTE_H__ 35 35 36 #include <async.h>37 36 #include <ipc/services.h> 38 37 39 #include <ip_codes.h> 40 #include <inet.h> 41 #include <in.h> 42 #include <socket.h> 38 #include <net/ip_codes.h> 39 #include <net/inet.h> 40 #include <net/in.h> 41 #include <net/packet.h> 42 #include <net/device.h> 43 #include <net/socket.h> 43 44 44 45 extern int ip_set_gateway_req_remote(int, device_id_t, in_addr_t); -
uspace/lib/net/include/net_checksum.h
r1882525 rf14291b 27 27 */ 28 28 29 /** @addtogroup net30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * General CRC and checksum computation.34 * General CRC and checksum computation. 35 35 */ 36 36 37 #ifndef __NET_CHECKSUM_H__38 #define __NET_CHECKSUM_H__37 #ifndef LIBNET_CHECKSUM_H_ 38 #define LIBNET_CHECKSUM_H_ 39 39 40 40 #include <byteorder.h> 41 42 41 #include <sys/types.h> 43 42 44 43 /** IP checksum value for computed zero checksum. 45 * Zero is returned as 0xFFFF (not flipped)44 * Zero is returned as 0xFFFF (not flipped) 46 45 */ 47 #define IP_CHECKSUM_ZERO 0xFFFFu46 #define IP_CHECKSUM_ZERO 0xffffU 48 47 49 /** Computes CRC32 value.50 * @param[in] seed Initial value. Often used as 0 or ~0.51 * @param[in] data Pointer to the beginning of data to process.52 * @param[in] length Length of the data in bits.53 * @returns The computed CRC32 of the length bits of the data.54 */55 48 #ifdef ARCH_IS_BIG_ENDIAN 56 #define compute_crc32(seed, data, length) compute_crc32_be(seed, (uint8_t *) data, length) 49 #define compute_crc32(seed, data, length) \ 50 compute_crc32_be(seed, (uint8_t *) data, length) 57 51 #else 58 #define compute_crc32(seed, data, length) compute_crc32_le(seed, (uint8_t *) data, length) 52 #define compute_crc32(seed, data, length) \ 53 compute_crc32_le(seed, (uint8_t *) data, length) 59 54 #endif 60 55 61 /** Computes CRC32 value in the little-endian environment. 62 * @param[in] seed Initial value. Often used as 0 or ~0. 63 * @param[in] data Pointer to the beginning of data to process. 64 * @param[in] length Length of the data in bits. 65 * @returns The computed CRC32 of the length bits of the data. 66 */ 67 extern uint32_t compute_crc32_le(uint32_t seed, uint8_t * data, size_t length); 68 69 /** Computes CRC32 value in the big-endian environment. 70 * @param[in] seed Initial value. Often used as 0 or ~0. 71 * @param[in] data Pointer to the beginning of data to process. 72 * @param[in] length Length of the data in bits. 73 * @returns The computed CRC32 of the length bits of the data. 74 */ 75 extern uint32_t compute_crc32_be(uint32_t seed, uint8_t * data, size_t length); 76 77 /** Computes sum of the 2 byte fields. 78 * Padds one zero (0) byte if odd. 79 * @param[in] seed Initial value. Often used as 0 or ~0. 80 * @param[in] data Pointer to the beginning of data to process. 81 * @param[in] length Length of the data in bytes. 82 * @returns The computed checksum of the length bytes of the data. 83 */ 84 extern uint32_t compute_checksum(uint32_t seed, uint8_t * data, size_t length); 85 86 /** Compacts the computed checksum to the 16 bit number adding the carries. 87 * @param[in] sum Computed checksum. 88 * @returns Compacted computed checksum to the 16 bits. 89 */ 90 extern uint16_t compact_checksum(uint32_t sum); 91 92 /** Returns or flips the checksum if zero. 93 * @param[in] checksum The computed checksum. 94 * @returns The internet protocol header checksum. 95 * @returns 0xFFFF if the computed checksum is zero. 96 */ 97 extern uint16_t flip_checksum(uint16_t checksum); 98 99 /** Computes the ip header checksum. 100 * To compute the checksum of a new packet, the checksum header field must be zero. 101 * To check the checksum of a received packet, the checksum may be left set. 102 * The zero (0) value will be returned in this case if valid. 103 * @param[in] data The header data. 104 * @param[in] length The header length in bytes. 105 * @returns The internet protocol header checksum. 106 * @returns 0xFFFF if the computed checksum is zero. 107 */ 108 extern uint16_t ip_checksum(uint8_t * data, size_t length); 56 extern uint32_t compute_crc32_le(uint32_t, uint8_t *, size_t); 57 extern uint32_t compute_crc32_be(uint32_t, uint8_t *, size_t); 58 extern uint32_t compute_checksum(uint32_t, uint8_t *, size_t); 59 extern uint16_t compact_checksum(uint32_t); 60 extern uint16_t flip_checksum(uint16_t); 61 extern uint16_t ip_checksum(uint8_t *, size_t); 109 62 110 63 #endif -
uspace/lib/net/include/net_interface.h
r1882525 rf14291b 27 27 */ 28 28 29 /** @addtogroup net29 /** @addtogroup libnet 30 30 * @{ 31 31 */ 32 32 33 #ifndef __NET_NET_INTERFACE_H__34 #define __NET_NET_INTERFACE_H__33 #ifndef LIBNET_NET_INTERFACE_H_ 34 #define LIBNET_NET_INTERFACE_H_ 35 35 36 36 #include <ipc/services.h> 37 37 38 #include <net _device.h>38 #include <net/device.h> 39 39 #include <adt/measured_strings.h> 40 40 41 41 /** @name Networking module interface 42 * This interface is used by other modules.42 * This interface is used by other modules. 43 43 */ 44 44 /*@{*/ 45 45 46 /** Returns the device specific configuration. 47 * Returns the global configuration if the device specific is not found. 48 * The configuration names are read and the appropriate settings are set instead. 49 * Call net_free_settings() function to release the returned configuration. 50 * @param[in] net_phone The networking module phone. 51 * @param[in] device_id The device identifier. 52 * @param[in,out] configuration The requested device configuration. The names are read and the appropriate settings are set instead. 53 * @param[in] count The configuration entries count. 54 * @param[in,out] data The configuration and settings data. 55 * @returns EOK on success. 56 * @returns EINVAL if the configuration is NULL. 57 * @returns EINVAL if the count is zero (0). 58 * @returns Other error codes as defined for the generic_translate_req() function. 59 */ 60 extern int net_get_device_conf_req(int net_phone, device_id_t device_id, measured_string_ref * configuration, size_t count, char ** data); 61 62 /** Returns the global configuration. 63 * The configuration names are read and the appropriate settings are set instead. 64 * Call net_free_settings() function to release the returned configuration. 65 * @param[in] net_phone The networking module phone. 66 * @param[in,out] configuration The requested configuration. The names are read and the appropriate settings are set instead. 67 * @param[in] count The configuration entries count. 68 * @param[in,out] data The configuration and settings data. 69 * @returns EOK on success. 70 * @returns EINVAL if the configuration is NULL. 71 * @returns EINVAL if the count is zero (0). 72 * @returns Other error codes as defined for the generic_translate_req() function. 73 */ 74 extern int net_get_conf_req(int net_phone, measured_string_ref * configuration, size_t count, char ** data); 75 76 /** Frees the received settings. 77 * @param[in] settings The received settings. 78 * @param[in] data The received settings data. 79 * @see net_get_device_conf_req() 80 * @see net_get_conf_req() 81 */ 82 extern void net_free_settings(measured_string_ref settings, char * data); 83 84 /** Connects to the networking module. 85 * @param service The networking module service. Ignored parameter. 86 * @returns The networking module phone on success. 87 * @returns 0 if called by the bundle module. 88 */ 89 extern int net_connect_module(services_t service); 46 extern int net_get_device_conf_req(int, device_id_t, measured_string_ref *, 47 size_t, char **); 48 extern int net_get_conf_req(int, measured_string_ref *, size_t, char **); 49 extern void net_free_settings(measured_string_ref, char *); 50 extern int net_connect_module(void); 90 51 91 52 /*@}*/ -
uspace/lib/net/include/netif_interface.h
r1882525 rf14291b 34 34 #define __NET_NETIF_INTERFACE_H__ 35 35 36 #ifdef CONFIG_NETIF_NIL_BUNDLE37 38 #include <netif_local.h>39 #include <netif_nil_bundle.h>40 #include <packet/packet_server.h>41 42 #define netif_module_message netif_nil_module_message43 #define netif_module_start netif_nil_module_start44 #define netif_get_addr_req netif_get_addr_req_local45 #define netif_probe_req netif_probe_req_local46 #define netif_send_msg netif_send_msg_local47 #define netif_start_req netif_start_req_local48 #define netif_stop_req netif_stop_req_local49 #define netif_stats_req netif_stats_req_local50 #define netif_bind_service netif_bind_service_local51 52 #else /* CONFIG_NETIF_NIL_BUNDLE */53 54 36 #include <netif_remote.h> 55 #include <packet /packet_client.h>37 #include <packet_client.h> 56 38 57 39 #define netif_module_message netif_module_message_standalone … … 65 47 #define netif_bind_service netif_bind_service_remote 66 48 67 #endif /* CONFIG_NETIF_NIL_BUNDLE */68 69 49 #endif 70 50 -
uspace/lib/net/include/netif_local.h
r1882525 rf14291b 34 34 * Network interface module skeleton. 35 35 * The skeleton has to be part of each network interface module. 36 * The skeleton can be also part of the module bundled with the network interface layer.37 36 */ 38 37 … … 44 43 #include <ipc/ipc.h> 45 44 #include <ipc/services.h> 45 #include <err.h> 46 46 47 47 #include <adt/measured_strings.h> 48 #include <net_err.h> 49 #include <net_device.h> 50 #include <packet/packet.h> 48 #include <net/device.h> 49 #include <net/packet.h> 51 50 52 51 /** Network interface device specific data. -
uspace/lib/net/include/netif_remote.h
r1882525 rf14291b 34 34 #define __NET_NETIF_REMOTE_H__ 35 35 36 #include < async.h>37 #include < fibril_synch.h>38 #include < ipc/ipc.h>36 #include <ipc/services.h> 37 #include <adt/measured_strings.h> 38 #include <net/device.h> 39 39 40 40 extern int netif_get_addr_req_remote(int, device_id_t, measured_string_ref *, -
uspace/lib/net/include/nil_interface.h
r1882525 rf14291b 38 38 39 39 #include <ipc/ipc.h> 40 #include <ipc/nil.h> 40 41 41 #include <net_messages.h> 42 #include <adt/measured_strings.h> 43 #include <packet/packet.h> 44 #include <nil_messages.h> 45 #include <net_device.h> 42 #include <generic.h> 43 #include <nil_remote.h> 46 44 47 45 #define nil_bind_service(service, device_id, me, receiver) \ … … 67 65 netif_service) 68 66 69 70 #ifdef CONFIG_NETIF_NIL_BUNDLE71 72 #include <nil_local.h>73 #include <packet/packet_server.h>74 75 #define nil_device_state_msg nil_device_state_msg_local76 #define nil_received_msg nil_received_msg_local77 78 #else /* CONFIG_NETIF_NIL_BUNDLE */79 80 #include <nil_remote.h>81 #include <packet/packet_server.h>82 83 67 #define nil_device_state_msg nil_device_state_msg_remote 84 68 #define nil_received_msg nil_received_msg_remote 85 86 #endif /* CONFIG_NETIF_NIL_BUNDLE */87 69 88 70 #endif -
uspace/lib/net/include/nil_remote.h
r1882525 rf14291b 34 34 #define __NET_NIL_REMOTE_H__ 35 35 36 #include < async.h>37 #include < fibril_synch.h>38 #include < ipc/ipc.h>36 #include <ipc/services.h> 37 #include <net/device.h> 38 #include <net/packet.h> 39 39 40 40 extern int nil_device_state_msg_remote(int, device_id_t, int); -
uspace/lib/net/include/packet_remote.h
r1882525 rf14291b 27 27 */ 28 28 29 /** @addtogroup packet29 /** @addtogroup libnet 30 30 * @{ 31 31 */ 32 32 33 #ifndef __NET_PACKET_REMOTE_H__34 #define __NET_PACKET_REMOTE_H__33 #ifndef LIBNET_PACKET_REMOTE_H_ 34 #define LIBNET_PACKET_REMOTE_H_ 35 35 36 #include <packet/packet.h> 36 #include <net/packet.h> 37 #include <sys/types.h> 37 38 38 39 extern int packet_translate_remote(int, packet_ref, packet_id_t); -
uspace/lib/net/include/tl_common.h
r1882525 rf14291b 38 38 #define __NET_TL_COMMON_H__ 39 39 40 #include < packet/packet.h>41 #include <net _device.h>42 #include < inet.h>43 #include < socket_codes.h>40 #include <net/socket_codes.h> 41 #include <net/packet.h> 42 #include <net/device.h> 43 #include <net/inet.h> 44 44 45 45 /** Device packet dimensions. -
uspace/lib/net/include/tl_interface.h
r1882525 rf14291b 40 40 #include <async.h> 41 41 #include <ipc/services.h> 42 #include <ipc/tl.h> 42 43 43 #include <net_messages.h> 44 #include <net_device.h> 45 #include <packet/packet.h> 46 #include <packet/packet_client.h> 47 #include <tl_messages.h> 44 #include <generic.h> 45 #include <net/device.h> 46 #include <net/packet.h> 47 #include <packet_client.h> 48 48 49 49 /** @name Transport layer module interface
Note:
See TracChangeset
for help on using the changeset viewer.
