Changeset 14f1db0 in mainline for uspace/lib/net
- Timestamp:
- 2010-04-09T12:54:57Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a1caa3c2
- Parents:
- 24ab58b3
- Location:
- uspace/lib/net
- Files:
-
- 5 added
- 4 deleted
- 23 edited
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/Makefile
r24ab58b3 r14f1db0 37 37 generic/packet_remote.c \ 38 38 adt/module_map.c \ 39 netif/netif .c \40 netif/netif_ standalone.c \39 netif/netif_local.c \ 40 netif/netif_remote.c \ 41 41 netif/netif_nil_bundle.c \ 42 42 nil/nil_remote.c \ -
uspace/lib/net/generic/net_remote.c
r24ab58b3 r14f1db0 32 32 33 33 /** @file 34 * Networking interface implementation for standaloneremote modules.34 * Networking interface implementation for remote modules. 35 35 * @see net_interface.h 36 36 */ -
uspace/lib/net/generic/packet_remote.c
r24ab58b3 r14f1db0 32 32 33 33 /** @file 34 * Packet client interface implementation for standaloneremote modules.34 * Packet client interface implementation for remote modules. 35 35 * @see packet_client.h 36 36 */ … … 47 47 #include <packet/packet_header.h> 48 48 #include <packet/packet_messages.h> 49 #include <packet_remote.h> 49 50 50 /** Obtains the packet from the packet server as the shared memory block. 51 * Creates the local packet mapping as well. 52 * @param[in] phone The packet server module phone. 53 * @param[out] packet The packet reference pointer to store the received packet reference. 54 * @param[in] packet_id The packet identifier. 55 * @param[in] size The packet total size in bytes. 56 * @returns EOK on success. 57 * @returns Other error codes as defined for the pm_add() function. 58 * @returns Other error codes as defined for the async_share_in_start() function. 51 /** Obtain the packet from the packet server as the shared memory block. 52 * 53 * Create the local packet mapping as well. 54 * 55 * @param[in] phone The packet server module phone. 56 * @param[out] packet The packet reference pointer to store the received 57 * packet reference. 58 * @param[in] packet_id The packet identifier. 59 * @param[in] size The packet total size in bytes. 60 * 61 * @return EOK on success. 62 * @return Other error codes as defined for the pm_add() function. 63 * @return Other error codes as defined for the async_share_in_start() function. 64 * 59 65 */ 60 int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size); 61 62 int packet_translate(int phone, packet_ref packet, packet_id_t packet_id){ 66 static int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){ 63 67 ERROR_DECLARE; 64 65 ipcarg_t size; 66 packet_t next; 67 68 if(! packet){ 69 return EINVAL; 70 } 71 *packet = pm_find(packet_id); 72 if(!(*packet)){ 73 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, &size)); 74 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size)); 75 } 76 if((** packet).next){ 77 return packet_translate(phone, &next, (** packet).next); 78 }else return EOK; 79 } 80 81 int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){ 82 ERROR_DECLARE; 83 84 aid_t message; 68 85 69 ipc_call_t answer; 86 ipcarg_t result; 87 88 message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 70 aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 89 71 *packet = (packet_t) as_get_mappable_page(size); 90 if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size))91 || ERROR_OCCURRED(pm_add(*packet))){72 if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size)) 73 || ERROR_OCCURRED(pm_add(*packet))) { 92 74 munmap(*packet, size); 93 75 async_wait_for(message, NULL); 94 76 return ERROR_CODE; 95 77 } 78 79 ipcarg_t result; 96 80 async_wait_for(message, &result); 81 97 82 return result; 98 83 } 99 84 100 packet_t packet_get_4(int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix){ 85 int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id) 86 { 101 87 ERROR_DECLARE; 88 89 if (!packet) 90 return EINVAL; 91 92 *packet = pm_find(packet_id); 93 if (!(*packet)) { 94 ipcarg_t size; 95 96 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, &size)); 97 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size)); 98 } 99 if ((** packet).next) { 100 packet_t next; 101 102 return packet_translate_remote(phone, &next, (** packet).next); 103 } 104 105 return EOK; 106 } 102 107 108 packet_t packet_get_4_remote(int phone, size_t max_content, size_t addr_len, 109 size_t max_prefix, size_t max_suffix) 110 { 111 ERROR_DECLARE; 112 103 113 ipcarg_t packet_id; 104 114 ipcarg_t size; 105 packet_t packet;106 107 if(ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len, max_prefix, max_suffix, &packet_id, &size))){115 116 if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, 117 addr_len, max_prefix, max_suffix, &packet_id, &size))) 108 118 return NULL; 119 120 121 packet_t packet = pm_find(packet_id); 122 if (!packet) { 123 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))) 124 return NULL; 109 125 } 110 packet = pm_find(packet_id); 111 if(! packet){ 112 if(ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))){ 113 return NULL; 114 } 115 } 126 116 127 return packet; 117 128 } 118 129 119 packet_t packet_get_1(int phone, size_t content){ 130 packet_t packet_get_1_remote(int phone, size_t content) 131 { 120 132 ERROR_DECLARE; 121 133 122 134 ipcarg_t packet_id; 123 135 ipcarg_t size; 124 packet_t packet;125 126 if(ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, &size))){136 137 if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, 138 &packet_id, &size))) 127 139 return NULL; 140 141 packet_t packet = pm_find(packet_id); 142 if (!packet) { 143 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))) 144 return NULL; 128 145 } 129 packet = pm_find(packet_id); 130 if(! packet){ 131 if(ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))){ 132 return NULL; 133 } 134 } 146 135 147 return packet; 136 148 } 137 149 138 void pq_release(int phone, packet_id_t packet_id){ 150 void pq_release_remote(int phone, packet_id_t packet_id) 151 { 139 152 async_msg_1(phone, NET_PACKET_RELEASE, packet_id); 140 153 } -
uspace/lib/net/il/arp_remote.c
r24ab58b3 r14f1db0 32 32 33 33 /** @file 34 * ARP interface implementation for standaloneremote modules.34 * ARP interface implementation for remote modules. 35 35 * @see arp_interface.h 36 36 */ -
uspace/lib/net/il/ip_client.c
r24ab58b3 r14f1db0 56 56 } 57 57 58 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, ip_pseudo_header_ref *header, size_t * headerlen){58 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){ 59 59 ipv4_pseudo_header_ref header_in; 60 60 struct sockaddr_in * address_in; … … 84 84 header_in->protocol = protocol; 85 85 header_in->data_length = htons(data_length); 86 *header = (ip_pseudo_header_ref)header_in;86 *header = header_in; 87 87 return EOK; 88 88 // TODO IPv6 … … 164 164 } 165 165 166 int ip_client_set_pseudo_header_data_length( ip_pseudo_header_refheader, size_t headerlen, size_t data_length){166 int ip_client_set_pseudo_header_data_length(void *header, size_t headerlen, size_t data_length){ 167 167 ipv4_pseudo_header_ref header_in; 168 168 -
uspace/lib/net/il/ip_remote.c
r24ab58b3 r14f1db0 33 33 /** @file 34 34 * 35 * IP interface implementation for standaloneremote modules.35 * IP interface implementation for remote modules. 36 36 * 37 37 * @see ip_interface.h … … 50 50 #include <il_messages.h> 51 51 #include <ip_messages.h> 52 53 int ip_add_route_req(int ip_phone, device_id_t device_id, in_addr_t address, 54 in_addr_t netmask, in_addr_t gateway) 52 #include <ip_remote.h> 53 54 /** Add a route to the device routing table. 55 * 56 * The target network is routed using this device. 57 * 58 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 59 * @param[in] device_id The device identifier. 60 * @param[in] address The target network address. 61 * @param[in] netmask The target network mask. 62 * @param[in] gateway The target network gateway. Not used if zero. 63 * 64 */ 65 int ip_add_route_req_remote(int ip_phone, device_id_t device_id, 66 in_addr_t address, in_addr_t netmask, in_addr_t gateway) 55 67 { 56 68 return (int) async_req_4_0(ip_phone, NET_IP_ADD_ROUTE, … … 71 83 } 72 84 73 int ip_device_req(int ip_phone, device_id_t device_id, services_t service) 74 { 75 return generic_device_req(ip_phone, NET_IL_DEVICE, device_id, 0, service); 76 } 77 78 int ip_get_route_req(int ip_phone, ip_protocol_t protocol, 85 /** Register the new device. 86 * 87 * Register itself as the ip packet receiver. 88 * If the device uses ARP registers also the new ARP device. 89 * 90 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 91 * @param[in] device_id The new device identifier. 92 * @param[in] netif The underlying device network interface layer service. 93 * 94 * @return EOK on success. 95 * @return ENOMEM if there is not enough memory left. 96 * @return EINVAL if the device configuration is invalid. 97 * @return ENOTSUP if the device uses IPv6. 98 * @return ENOTSUP if the device uses DHCP. 99 * @return Other error codes as defined for the net_get_device_conf_req() 100 * function. 101 * @return Other error codes as defined for the arp_device_req() function. 102 * 103 */ 104 int ip_device_req_remote(int ip_phone, device_id_t device_id, 105 services_t service) 106 { 107 return generic_device_req_remote(ip_phone, NET_IL_DEVICE, device_id, 0, 108 service); 109 } 110 111 /** Return the device identifier and the IP pseudo header based on the destination address. 112 * 113 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 114 * @param[in] protocol The transport protocol. 115 * @param[in] destination The destination address. 116 * @param[in] addrlen The destination address length. 117 * @param[out] device_id The device identifier. 118 * @param[out] header The constructed IP pseudo header. 119 * @param[out] headerlen The IP pseudo header length. 120 * 121 */ 122 int ip_get_route_req_remote(int ip_phone, ip_protocol_t protocol, 79 123 const struct sockaddr *destination, socklen_t addrlen, 80 device_id_t *device_id, ip_pseudo_header_ref*header, size_t *headerlen)124 device_id_t *device_id, void **header, size_t *headerlen) 81 125 { 82 126 if ((!destination) || (addrlen == 0)) … … 95 139 && (async_data_read_start(ip_phone, headerlen, sizeof(*headerlen)) == EOK) 96 140 && (*headerlen > 0)) { 97 *header = (ip_pseudo_header_ref)malloc(*headerlen);141 *header = malloc(*headerlen); 98 142 if (*header) { 99 143 if (async_data_read_start(ip_phone, *header, *headerlen) != EOK) … … 113 157 } 114 158 115 int ip_packet_size_req(int ip_phone, device_id_t device_id, 159 /** Return the device packet dimension for sending. 160 * 161 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 162 * @param[in] device_id The device identifier. 163 * @param[out] packet_dimension The packet dimension. 164 * 165 * @return EOK on success. 166 * @return ENOENT if there is no such device. 167 * @return Other error codes as defined for the 168 * generic_packet_size_req_remote() function. 169 * 170 */ 171 int ip_packet_size_req_remote(int ip_phone, device_id_t device_id, 116 172 packet_dimension_ref packet_dimension) 117 173 { 118 return generic_packet_size_req (ip_phone, NET_IL_PACKET_SPACE, device_id,174 return generic_packet_size_req_remote(ip_phone, NET_IL_PACKET_SPACE, device_id, 119 175 packet_dimension); 120 176 } 121 177 122 int ip_received_error_msg(int ip_phone, device_id_t device_id, 178 /** Notify the IP module about the received error notification packet. 179 * 180 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 181 * @param[in] device_id The device identifier. 182 * @param[in] packet The received packet or the received packet queue. 183 * @param[in] target The target internetwork module service to be 184 * delivered to. 185 * @param[in] error The packet error reporting service. Prefixes the 186 * received packet. 187 * 188 * @return EOK on success. 189 * 190 */ 191 int ip_received_error_msg_remote(int ip_phone, device_id_t device_id, 123 192 packet_t packet, services_t target, services_t error) 124 193 { 125 return generic_received_msg(ip_phone, NET_IP_RECEIVED_ERROR, device_id, 126 packet_get_id(packet), target, error); 127 } 128 129 int ip_send_msg(int ip_phone, device_id_t device_id, packet_t packet, 194 return generic_received_msg_remote(ip_phone, NET_IP_RECEIVED_ERROR, 195 device_id, packet_get_id(packet), target, error); 196 } 197 198 /** Send the packet queue. 199 * 200 * The packets may get fragmented if needed. 201 * 202 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 203 * @param[in] device_id The device identifier. 204 * @param[in] packet The packet fragments as a packet queue. All the 205 * packets have to have the same destination address. 206 * @param[in] sender The sending module service. 207 * @param[in] error The packet error reporting service. Prefixes the 208 * received packet. 209 * 210 * @return EOK on success. 211 * @return Other error codes as defined for the generic_send_msg() function. 212 * 213 */ 214 int ip_send_msg_remote(int ip_phone, device_id_t device_id, packet_t packet, 130 215 services_t sender, services_t error) 131 216 { 132 return generic_send_msg (ip_phone, NET_IL_SEND, device_id,217 return generic_send_msg_remote(ip_phone, NET_IL_SEND, device_id, 133 218 packet_get_id(packet), sender, error); 134 219 } 135 220 136 int ip_set_gateway_req(int ip_phone, device_id_t device_id, in_addr_t gateway) 221 /** Set the default gateway. 222 * 223 * This gateway is used if no other route is found. 224 * 225 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 226 * @param[in] device_id The device identifier. 227 * @param[in] gateway The default gateway. 228 * 229 */ 230 int ip_set_gateway_req_remote(int ip_phone, device_id_t device_id, 231 in_addr_t gateway) 137 232 { 138 233 return (int) async_req_2_0(ip_phone, NET_IP_SET_GATEWAY, -
uspace/lib/net/include/arp_interface.h
r24ab58b3 r14f1db0 29 29 /** @addtogroup arp 30 30 * @{ 31 */32 33 /** @file34 * ARP module interface.35 * The same interface is used for standalone remote modules as well as for bundle modules.36 * The standalone remote modules have to be compiled with the arp_remote.c source file.37 * The bundle modules with the arp.c source file.38 31 */ 39 32 -
uspace/lib/net/include/icmp_interface.h
r24ab58b3 r14f1db0 29 29 /** @addtogroup icmp 30 30 * @{ 31 */32 33 /** @file34 * ICMP module interface.35 * The same interface is used for standalone remote modules as well as for bundle modules.36 * The standalone remote modules have to be compiled with the icmp_remote.c source file.37 * The bundle modules with the icmp.c source file.38 31 */ 39 32 -
uspace/lib/net/include/il_interface.h
r24ab58b3 r14f1db0 32 32 33 33 /** @file 34 * 35 * This interface is always called by the standalone remote modules.34 * Internetwork layer module interface for the underlying network interface layer. 35 * This interface is always called by the remote modules. 36 36 */ 37 37 … … 50 50 51 51 /** @name Internetwork layer module interface 52 * 52 * This interface is used by other modules. 53 53 */ 54 54 /*@{*/ 55 55 56 /** Notifies the internetwork layer modules about the device state change. 57 * @param[in] il_phone The internetwork layer module phone used for (semi)remote calls. 58 * @param[in] device_id The device identifier. 59 * @param[in] state The new device state. 60 * @param[in] target The target internetwork module service to be delivered to. 61 * @returns EOK on success. 56 /** Notify the internetwork layer modules about the device state change. 57 * 58 * @param[in] il_phone The internetwork layer module phone used for 59 * (semi)remote calls. 60 * @param[in] device_id The device identifier. 61 * @param[in] state The new device state. 62 * @param[in] target The target internetwork module service to be 63 * delivered to. 64 * 65 * @return EOK on success. 66 * 62 67 */ 63 static inline int il_device_state_msg(int il_phone, device_id_t device_id, device_state_t state, services_t target){ 64 return generic_device_state_msg(il_phone, NET_IL_DEVICE_STATE, device_id, state, target); 68 static inline int il_device_state_msg(int il_phone, device_id_t device_id, 69 device_state_t state, services_t target) 70 { 71 return generic_device_state_msg_remote(il_phone, NET_IL_DEVICE_STATE, 72 device_id, state, target); 65 73 } 66 74 67 /** Notifies the internetwork layer modules about the received packet/s. 68 * @param[in] il_phone The internetwork layer module phone used for (semi)remote calls. 69 * @param[in] device_id The device identifier. 70 * @param[in] packet The received packet or the received packet queue. 71 * @param[in] target The target internetwork module service to be delivered to. 72 * @returns EOK on success. 75 /** Notify the internetwork layer modules about the received packet/s. 76 * 77 * @param[in] il_phone The internetwork layer module phone used for 78 * (semi)remote calls. 79 * @param[in] device_id The device identifier. 80 * @param[in] packet The received packet or the received packet queue. 81 * @param[in] target The target internetwork module service to be 82 * delivered to. 83 * 84 * @return EOK on success. 85 * 73 86 */ 74 inline static int il_received_msg(int il_phone, device_id_t device_id, packet_t packet, services_t target){ 75 return generic_received_msg(il_phone, NET_IL_RECEIVED, device_id, packet_get_id(packet), target, 0); 87 inline static int il_received_msg(int il_phone, device_id_t device_id, 88 packet_t packet, services_t target) 89 { 90 return generic_received_msg_remote(il_phone, NET_IL_RECEIVED, device_id, 91 packet_get_id(packet), target, 0); 76 92 } 77 93 78 /** Notifies the internetwork layer modules about the mtu change. 79 * @param[in] il_phone The internetwork layer module phone used for (semi)remote calls. 80 * @param[in] device_id The device identifier. 81 * @param[in] mtu The new mtu value. 82 * @param[in] target The target internetwork module service to be delivered to. 83 * @returns EOK on success. 94 /** Notify the internetwork layer modules about the mtu change. 95 * 96 * @param[in] il_phone The internetwork layer module phone used for 97 * (semi)remote calls. 98 * @param[in] device_id The device identifier. 99 * @param[in] mtu The new mtu value. 100 * @param[in] target The target internetwork module service to be 101 * delivered to. 102 * 103 * @return EOK on success. 104 * 84 105 */ 85 inline static int il_mtu_changed_msg(int il_phone, device_id_t device_id, size_t mtu, services_t target){ 86 return generic_device_state_msg(il_phone, NET_IL_MTU_CHANGED, device_id, (int) mtu, target); 106 inline static int il_mtu_changed_msg(int il_phone, device_id_t device_id, 107 size_t mtu, services_t target) 108 { 109 return generic_device_state_msg_remote(il_phone, NET_IL_MTU_CHANGED, 110 device_id, (int) mtu, target); 87 111 } 88 112 -
uspace/lib/net/include/il_local.h
r24ab58b3 r14f1db0 27 27 */ 28 28 29 /** @addtogroup il_ standalone29 /** @addtogroup il_local 30 30 * @{ 31 31 */ 32 32 33 #ifndef __IL_ STANDALONE_H__34 #define __IL_ STANDALONE_H__33 #ifndef __IL_LOCAL_H__ 34 #define __IL_LOCAL_H__ 35 35 36 36 #include <ipc/ipc.h> 37 37 #include <async.h> 38 38 39 extern int il_module_message (ipc_callid_t callid, ipc_call_t *call,39 extern int il_module_message_standalone(ipc_callid_t callid, ipc_call_t *call, 40 40 ipc_call_t *answer, int *answer_count); 41 extern int il_module_start (async_client_conn_t client_connection);41 extern int il_module_start_standalone(async_client_conn_t client_connection); 42 42 43 43 #endif -
uspace/lib/net/include/il_messages.h
r24ab58b3 r14f1db0 28 28 29 29 /** @addtogroup net_il 30 * 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * 35 * 36 * 34 * Internetwork layer modules messages. 35 * @see il_interface.h 36 * @see ip_interface.h 37 37 */ 38 38 … … 72 72 73 73 /** @name Internetwork layer specific message parameters definitions 74 * 74 75 */ 75 76 /*@{*/ 76 77 77 /** Returns the protocol number message parameter. 78 * @param[in] call The message call structure. 78 /** Return the protocol number message parameter. 79 * @param[in] call The message call structure. 80 * 79 81 */ 80 #define IL_GET_PROTO(call) 82 #define IL_GET_PROTO(call) (int) IPC_GET_ARG1(*call) 81 83 82 /** Returns the registering service message parameter. 83 * @param[in] call The message call structure. 84 /** Return the registering service message parameter. 85 * @param[in] call The message call structure. 86 * 84 87 */ 85 #define IL_GET_SERVICE(call) 88 #define IL_GET_SERVICE(call) (services_t) IPC_GET_ARG2(*call) 86 89 87 90 /*@}*/ -
uspace/lib/net/include/ip_client.h
r24ab58b3 r14f1db0 87 87 * @returns EINVAL if the headerlen parameter is not IPv4 pseudo header length. 88 88 */ 89 extern int ip_client_set_pseudo_header_data_length( ip_pseudo_header_refheader, size_t headerlen, size_t data_length);89 extern int ip_client_set_pseudo_header_data_length(void *header, size_t headerlen, size_t data_length); 90 90 91 91 /** Constructs the IPv4 pseudo header. … … 107 107 * @returns ENOMEM if there is not enough memory left. 108 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, ip_pseudo_header_ref *header, size_t * headerlen);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); 110 110 111 111 // TODO ipopt manipulation -
uspace/lib/net/include/ip_interface.h
r24ab58b3 r14f1db0 31 31 */ 32 32 33 /** @file34 * IP module interface.35 * The same interface is used for standalone remote modules as well as for bundle modules.36 * The standalone remote modules have to be compiled with the ip_remote.c source file.37 * The bundle modules with the ip.c source file.38 */39 40 33 #ifndef __NET_IP_INTERFACE_H__ 41 34 #define __NET_IP_INTERFACE_H__ … … 51 44 #include <socket_codes.h> 52 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 59 60 #include <ip_remote.h> 61 62 #define ip_received_error_msg ip_received_error_msg_remote 63 #define ip_set_gateway_req ip_set_gateway_req_remote 64 #define ip_packet_size_req ip_packet_size_req_remote 65 #define ip_device_req ip_device_req_remote 66 #define ip_add_route_req ip_add_route_req_remote 67 #define ip_send_msg ip_send_msg_remote 68 #define ip_get_route_req ip_get_route_req_remote 69 70 #endif 71 53 72 /** @name IP module interface 54 73 * This interface is used by other modules. 55 74 */ 56 75 /*@{*/ 57 58 /** Type definition of the internet pseudo header pointer.59 */60 typedef void * ip_pseudo_header_ref;61 76 62 77 /** The transport layer notification function type definition. … … 82 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); 83 98 84 /** Registers the new device.85 * Registers itself as the ip packet receiver.86 * If the device uses ARP registers also the new ARP device.87 * @param[in] ip_phone The IP module phone used for (semi)remote calls.88 * @param[in] device_id The new device identifier.89 * @param[in] netif The underlying device network interface layer service.90 * @returns EOK on success.91 * @returns ENOMEM if there is not enough memory left.92 * @returns EINVAL if the device configuration is invalid.93 * @returns ENOTSUP if the device uses IPv6.94 * @returns ENOTSUP if the device uses DHCP.95 * @returns Other error codes as defined for the net_get_device_conf_req() function.96 * @returns Other error codes as defined for the arp_device_req() function.97 */98 extern int ip_device_req(int, device_id_t, services_t);99 100 /** Sends the packet queue.101 * The packets may get fragmented if needed.102 * @param[in] ip_phone The IP module phone used for (semi)remote calls.103 * @param[in] device_id The device identifier.104 * @param[in] packet The packet fragments as a~packet queue. All the packets have to have the same destination address.105 * @param[in] sender The sending module service.106 * @param[in] error The packet error reporting service. Prefixes the received packet.107 * @returns EOK on success.108 * @returns Other error codes as defined for the generic_send_msg() function.109 */110 extern int ip_send_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t sender, services_t error);111 112 99 /** Connects to the IP module. 113 100 * @param service The IP module service. Ignored parameter. … … 117 104 extern int ip_connect_module(services_t service); 118 105 119 /** Adds a route to the device routing table.120 * The target network is routed using this device.121 * @param[in] ip_phone The IP module phone used for (semi)remote calls.122 * @param[in] device_id The device identifier.123 * @param[in] address The target network address.124 * @param[in] netmask The target network mask.125 * @param[in] gateway The target network gateway. Not used if zero.126 */127 extern int ip_add_route_req(int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway);128 129 /** Sets the default gateway.130 * This gateway is used if no other route is found.131 * @param[in] ip_phone The IP module phone used for (semi)remote calls.132 * @param[in] device_id The device identifier.133 * @param[in] gateway The default gateway.134 */135 extern int ip_set_gateway_req(int ip_phone, device_id_t device_id, in_addr_t gateway);136 137 /** Returns the device packet dimension for sending.138 * @param[in] ip_phone The IP module phone used for (semi)remote calls.139 * @param[in] device_id The device identifier.140 * @param[out] packet_dimension The packet dimension.141 * @returns EOK on success.142 * @returns ENOENT if there is no such device.143 * @returns Other error codes as defined for the generic_packet_size_req() function.144 */145 extern int ip_packet_size_req(int ip_phone, device_id_t device_id, packet_dimension_ref packet_dimension);146 147 /** Notifies the IP module about the received error notification packet.148 * @param[in] ip_phone The IP module phone used for (semi)remote calls.149 * @param[in] device_id The device identifier.150 * @param[in] packet The received packet or the received packet queue.151 * @param[in] target The target internetwork module service to be delivered to.152 * @param[in] error The packet error reporting service. Prefixes the received packet.153 * @returns EOK on success.154 */155 extern int ip_received_error_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t target, services_t error);156 157 /** Returns the device identifier and the IP pseudo header based on the destination address.158 * @param[in] ip_phone The IP module phone used for (semi)remote calls.159 * @param[in] protocol The transport protocol.160 * @param[in] destination The destination address.161 * @param[in] addrlen The destination address length.162 * @param[out] device_id The device identifier.163 * @param[out] header The constructed IP pseudo header.164 * @param[out] headerlen The IP pseudo header length.165 */166 extern int ip_get_route_req(int ip_phone, ip_protocol_t protocol, const struct sockaddr * destination, socklen_t addrlen, device_id_t * device_id, ip_pseudo_header_ref * header, size_t * headerlen);167 168 106 /*@}*/ 169 107 -
uspace/lib/net/include/net_interface.h
r24ab58b3 r14f1db0 29 29 /** @addtogroup net 30 30 * @{ 31 */32 33 /** @file34 * Networking module interface.35 * The same interface is used for standalone remote modules as well as for bundle modules.36 * The standalone remote modules have to be compiled with the net_remote.c source file.37 * The bundle networking module is compiled with the net_bundle.c source file and the choosen bundle module implementation source files.38 31 */ 39 32 -
uspace/lib/net/include/netif_interface.h
r24ab58b3 r14f1db0 28 28 29 29 /** @addtogroup netif 30 * @{ 31 */ 32 33 /** @file 34 * Network interface module interface. 35 * The same interface is used for standalone remote modules as well as for bundle network interface layer modules. 36 * The standalone remote modules have to be compiled with the netif_remote.c source file. 37 * The bundle network interface layer modules are compiled with the netif_nil_bundle.c source file and the choosen network interface layer implementation source file. 30 * @{ 38 31 */ 39 32 … … 41 34 #define __NET_NETIF_INTERFACE_H__ 42 35 43 #i nclude <ipc/services.h>36 #ifdef CONFIG_NETIF_NIL_BUNDLE 44 37 45 #include <net_messages.h> 46 #include <adt/measured_strings.h> 47 #include <packet/packet.h> 48 #include <net_device.h> 38 #include <netif_local.h> 39 #include <netif_nil_bundle.h> 40 #include <packet/packet_server.h> 49 41 50 /** @name Network interface module interface 51 * This interface is used by other modules. 52 */ 53 /*@{*/ 42 #define netif_module_message netif_nil_module_message 43 #define netif_module_start netif_nil_module_start 44 #define netif_get_addr_req netif_get_addr_req_local 45 #define netif_probe_req netif_probe_req_local 46 #define netif_send_msg netif_send_msg_local 47 #define netif_start_req netif_start_req_local 48 #define netif_stop_req netif_stop_req_local 49 #define netif_stats_req netif_stats_req_local 50 #define netif_bind_service netif_bind_service_local 54 51 55 /** Returns the device local hardware address. 56 * @param[in] netif_phone The network interface phone. 57 * @param[in] device_id The device identifier. 58 * @param[out] address The device local hardware address. 59 * @param[out] data The address data. 60 * @returns EOK on success. 61 * @returns EBADMEM if the address parameter is NULL. 62 * @returns ENOENT if there no such device. 63 * @returns Other error codes as defined for the netif_get_addr_message() function. 64 */ 65 extern int netif_get_addr_req(int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data); 52 #else /* CONFIG_NETIF_NIL_BUNDLE */ 66 53 67 /** Probes the existence of the device. 68 * @param[in] netif_phone The network interface phone. 69 * @param[in] device_id The device identifier. 70 * @param[in] irq The device interrupt number. 71 * @param[in] io The device input/output address. 72 * @returns EOK on success. 73 * @returns Other errro codes as defined for the netif_probe_message(). 74 */ 75 extern int netif_probe_req(int netif_phone, device_id_t device_id, int irq, int io); 54 #include <netif_remote.h> 55 #include <packet/packet_client.h> 76 56 77 /** Sends the packet queue. 78 * @param[in] netif_phone The network interface phone. 79 * @param[in] device_id The device identifier. 80 * @param[in] packet The packet queue. 81 * @param[in] sender The sending module service. 82 * @returns EOK on success. 83 * @returns Other error codes as defined for the generic_send_msg() function. 84 */ 85 extern int netif_send_msg(int netif_phone, device_id_t device_id, packet_t packet, services_t sender); 57 #define netif_module_message netif_module_message_standalone 58 #define netif_module_start netif_module_start_standalone 59 #define netif_get_addr_req netif_get_addr_req_remote 60 #define netif_probe_req netif_probe_req_remote 61 #define netif_send_msg netif_send_msg_remote 62 #define netif_start_req netif_start_req_remote 63 #define netif_stop_req netif_stop_req_remote 64 #define netif_stats_req netif_stats_req_remote 65 #define netif_bind_service netif_bind_service_remote 86 66 87 /** Starts the device. 88 * @param[in] netif_phone The network interface phone. 89 * @param[in] device_id The device identifier. 90 * @returns EOK on success. 91 * @returns Other error codes as defined for the find_device() function. 92 * @returns Other error codes as defined for the netif_start_message() function. 93 */ 94 extern int netif_start_req(int netif_phone, device_id_t device_id); 95 96 /** Stops the device. 97 * @param[in] netif_phone The network interface phone. 98 * @param[in] device_id The device identifier. 99 * @returns EOK on success. 100 * @returns Other error codes as defined for the find_device() function. 101 * @returns Other error codes as defined for the netif_stop_message() function. 102 */ 103 extern int netif_stop_req(int netif_phone, device_id_t device_id); 104 105 /** Returns the device usage statistics. 106 * @param[in] netif_phone The network interface phone. 107 * @param[in] device_id The device identifier. 108 * @param[out] stats The device usage statistics. 109 * @returns EOK on success. 110 */ 111 extern int netif_stats_req(int netif_phone, device_id_t device_id, device_stats_ref stats); 112 113 /** Creates bidirectional connection with the network interface module and registers the message receiver. 114 * @param[in] service The network interface module service. 115 * @param[in] device_id The device identifier. 116 * @param[in] me The requesting module service. 117 * @param[in] receiver The message receiver. 118 * @returns The phone of the needed service. 119 * @returns EOK on success. 120 * @returns Other error codes as defined for the bind_service() function. 121 */ 122 extern int netif_bind_service(services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver); 123 124 /*@}*/ 67 #endif /* CONFIG_NETIF_NIL_BUNDLE */ 125 68 126 69 #endif -
uspace/lib/net/include/netif_messages.h
r24ab58b3 r14f1db0 28 28 29 29 /** @addtogroup netif 30 * 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Network interface common module messages. 35 * @see netif_interface.h 34 * Network interface common module messages. 36 35 */ 37 36 … … 76 75 /*@{*/ 77 76 78 /** Return sthe interrupt number message parameter.79 * 77 /** Return the interrupt number message parameter. 78 * @param[in] call The message call structure. 80 79 */ 81 80 #define NETIF_GET_IRQ(call) \ 82 81 ({int irq = (int) IPC_GET_ARG2(*call); irq;}) 83 82 84 /** Return sthe input/output address message parameter.85 * 83 /** Return the input/output address message parameter. 84 * @param[in] call The message call structure. 86 85 */ 87 86 #define NETIF_GET_IO(call) \ -
uspace/lib/net/include/nil_interface.h
r24ab58b3 r14f1db0 31 31 */ 32 32 33 /** @file34 * Network interface layer module interface.35 * The same interface is used for standalone remote device modules as well as for bundle device modules.36 * The standalone remote device modules have to be compiled with the nil_remote.c source file.37 * The bundle device modules with the appropriate network interface layer source file (eth.c etc.).38 * The upper layers cannot be bundled with the network interface layer.39 */40 41 33 #ifndef __NET_NIL_INTERFACE_H__ 42 34 #define __NET_NIL_INTERFACE_H__ … … 53 45 #include <net_device.h> 54 46 55 /** @name Network interface layer module interface 56 * This interface is used by other modules. 57 */ 58 /*@{*/ 47 #define nil_bind_service(service, device_id, me, receiver) \ 48 bind_service(service, device_id, me, 0, receiver) 59 49 60 /** Returns the device local hardware address. 61 * @param[in] nil_phone The network interface layer phone. 62 * @param[in] device_id The device identifier. 63 * @param[out] address The device local hardware address. 64 * @param[out] data The address data. 65 * @returns EOK on success. 66 * @returns EBADMEM if the address parameter and/or the data parameter is NULL. 67 * @returns ENOENT if there no such device. 68 * @returns Other error codes as defined for the generic_get_addr_req() function. 69 */ 70 #define nil_get_addr_req(nil_phone, device_id, address, data) \ 50 #define nil_packet_size_req(nil_phone, device_id, packet_dimension) \ 51 generic_packet_size_req_remote(nil_phone, NET_NIL_PACKET_SPACE, device_id, \ 52 packet_dimension) 53 54 #define nil_get_addr_req(nil_phone, device_id, address, data) \ 71 55 generic_get_addr_req(nil_phone, NET_NIL_ADDR, device_id, address, data) 72 56 73 /** Returns the device broadcast hardware address. 74 * @param[in] nil_phone The network interface layer phone. 75 * @param[in] device_id The device identifier. 76 * @param[out] address The device broadcast hardware address. 77 * @param[out] data The address data. 78 * @returns EOK on success. 79 * @returns EBADMEM if the address parameter is NULL. 80 * @returns ENOENT if there no such device. 81 * @returns Other error codes as defined for the generic_get_addr_req() function. 82 */ 83 #define nil_get_broadcast_addr_req(nil_phone, device_id, address, data) \ 84 generic_get_addr_req(nil_phone, NET_NIL_BROADCAST_ADDR, device_id, address, data) 57 #define nil_get_broadcast_addr_req(nil_phone, device_id, address, data) \ 58 generic_get_addr_req(nil_phone, NET_NIL_BROADCAST_ADDR, device_id, \ 59 address, data) 85 60 86 /** Sends the packet queue. 87 * @param[in] nil_phone The network interface layer phone. 88 * @param[in] device_id The device identifier. 89 * @param[in] packet The packet queue. 90 * @param[in] sender The sending module service. 91 * @returns EOK on success. 92 * @returns Other error codes as defined for the generic_send_msg() function. 93 */ 94 #define nil_send_msg(nil_phone, device_id, packet, sender) \ 95 generic_send_msg(nil_phone, NET_NIL_SEND, device_id, packet_get_id(packet), sender, 0) 61 #define nil_send_msg(nil_phone, device_id, packet, sender) \ 62 generic_send_msg_remote(nil_phone, NET_NIL_SEND, device_id, \ 63 packet_get_id(packet), sender, 0) 96 64 97 /** Returns the device packet dimension for sending. 98 * @param[in] nil_phone The network interface layer phone. 99 * @param[in] device_id The device identifier. 100 * @param[out] packet_dimension The packet dimensions. 101 * @returns EOK on success. 102 * @returns ENOENT if there is no such device. 103 * @returns Other error codes as defined for the generic_packet_size_req() function. 104 */ 105 #define nil_packet_size_req(nil_phone, device_id, packet_dimension) \ 106 generic_packet_size_req(nil_phone, NET_NIL_PACKET_SPACE, device_id, packet_dimension) 65 #define nil_device_req(nil_phone, device_id, mtu, netif_service) \ 66 generic_device_req_remote(nil_phone, NET_NIL_DEVICE, device_id, mtu, \ 67 netif_service) 107 68 108 /** Registers new device or updates the MTU of an existing one.109 * @param[in] nil_phone The network interface layer phone.110 * @param[in] device_id The new device identifier.111 * @param[in] mtu The device maximum transmission unit.112 * @param[in] netif_service The device driver service.113 * @returns EOK on success.114 * @returns EEXIST if the device with the different service exists.115 * @returns ENOMEM if there is not enough memory left.116 * @returns Other error codes as defined for the generic_device_req() function.117 */118 #define nil_device_req(nil_phone, device_id, mtu, netif_service) \119 generic_device_req(nil_phone, NET_NIL_DEVICE, device_id, mtu, netif_service)120 69 121 /** Notifies the network interface layer about the device state change. 122 * @param[in] nil_phone The network interface layer phone. 123 * @param[in] device_id The device identifier. 124 * @param[in] state The new device state. 125 * @returns EOK on success. 126 * @returns Other error codes as defined for each specific module device state function. 127 */ 128 extern int nil_device_state_msg(int nil_phone, device_id_t device_id, int state); 70 #ifdef CONFIG_NETIF_NIL_BUNDLE 129 71 130 /** Passes the packet queue to the network interface layer. 131 * Processes and redistributes the received packet queue to the registered upper layers. 132 * @param[in] nil_phone The network interface layer phone. 133 * @param[in] device_id The source device identifier. 134 * @param[in] packet The received packet or the received packet queue. 135 * @param target The target service. Ignored parameter. 136 * @returns EOK on success. 137 * @returns Other error codes as defined for each specific module received function. 138 */ 139 extern int nil_received_msg(int nil_phone, device_id_t device_id, packet_t packet, services_t target); 72 #include <nil_local.h> 73 #include <packet/packet_server.h> 140 74 141 /** Creates bidirectional connection with the network interface layer module and registers the message receiver. 142 * @param[in] service The network interface layer module service. 143 * @param[in] device_id The device identifier. 144 * @param[in] me The requesting module service. 145 * @param[in] receiver The message receiver. 146 * @returns The phone of the needed service. 147 * @returns EOK on success. 148 * @returns Other error codes as defined for the bind_service() function. 149 */ 150 #define nil_bind_service(service, device_id, me, receiver) \151 bind_service(service, device_id, me, 0, receiver); 152 /*@}*/75 #define nil_device_state_msg nil_device_state_msg_local 76 #define nil_received_msg nil_received_msg_local 77 78 #else /* CONFIG_NETIF_NIL_BUNDLE */ 79 80 #include <nil_remote.h> 81 #include <packet/packet_server.h> 82 83 #define nil_device_state_msg nil_device_state_msg_remote 84 #define nil_received_msg nil_received_msg_remote 85 86 #endif /* CONFIG_NETIF_NIL_BUNDLE */ 153 87 154 88 #endif -
uspace/lib/net/include/nil_local.h
r24ab58b3 r14f1db0 32 32 33 33 /** @file 34 * 35 * 34 * Network interface layer modules common skeleton. 35 * All network interface layer modules have to implement this interface. 36 36 */ 37 37 38 #ifndef __NET_NIL_ MODULE_H__39 #define __NET_NIL_ MODULE_H__38 #ifndef __NET_NIL_LOCAL_H__ 39 #define __NET_NIL_LOCAL_H__ 40 40 41 41 #include <ipc/ipc.h> … … 52 52 */ 53 53 extern int nil_initialize(int); 54 55 extern int nil_device_state_msg_local(int, device_id_t, int); 56 extern int nil_received_msg_local(int, device_id_t, packet_t, services_t); 54 57 55 58 /** Message processing function. … … 71 74 * 72 75 */ 73 extern int nil_message (const char *, ipc_callid_t, ipc_call_t *, ipc_call_t *,76 extern int nil_message_standalone(const char *, ipc_callid_t, ipc_call_t *, ipc_call_t *, 74 77 int *); 78 79 extern int nil_module_message_standalone(const char *, ipc_callid_t, 80 ipc_call_t *, ipc_call_t *, int *); 81 extern int nil_module_start_standalone(async_client_conn_t); 75 82 76 83 #endif -
uspace/lib/net/include/nil_messages.h
r24ab58b3 r14f1db0 28 28 29 29 /** @addtogroup net_nil 30 * 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Network interface layer module messages. 35 * @see nil_interface.h 34 * Network interface layer module messages. 36 35 */ 37 36 … … 43 42 #include <net_messages.h> 44 43 45 /** 44 /** Network interface layer module messages. 46 45 */ 47 46 typedef enum { … … 80 79 /*@{*/ 81 80 82 /** Return sthe protocol service message parameter.81 /** Return the protocol service message parameter. 83 82 */ 84 83 #define NIL_GET_PROTO(call) \ -
uspace/lib/net/include/nil_remote.h
r24ab58b3 r14f1db0 1 1 /* 2 * Copyright (c) 20 10 Martin Decky2 * Copyright (c) 2009 Lukas Mejdrech 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup netif _standalone30 * 29 /** @addtogroup netif 30 * @{ 31 31 */ 32 32 33 #ifndef __NET IF_STANDALONE_H__34 #define __NET IF_STANDALONE_H__33 #ifndef __NET_NIL_REMOTE_H__ 34 #define __NET_NIL_REMOTE_H__ 35 35 36 #include <async.h> 37 #include <fibril_synch.h> 36 38 #include <ipc/ipc.h> 37 #include <async.h>38 39 39 extern int netif_module_message(const char *, ipc_callid_t, ipc_call_t *, 40 ipc_call_t *, int *); 41 extern int netif_module_start(async_client_conn_t); 40 extern int nil_device_state_msg_remote(int, device_id_t, int); 41 extern int nil_received_msg_remote(int, device_id_t, packet_t, services_t); 42 42 43 43 #endif -
uspace/lib/net/include/packet_remote.h
r24ab58b3 r14f1db0 1 1 /* 2 * Copyright (c) 20 10 Martin Decky2 * Copyright (c) 2009 Lukas Mejdrech 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup tl_standalone30 * 29 /** @addtogroup packet 30 * @{ 31 31 */ 32 32 33 #ifndef __ TL_STANDALONE_H__34 #define __ TL_STANDALONE_H__33 #ifndef __NET_PACKET_REMOTE_H__ 34 #define __NET_PACKET_REMOTE_H__ 35 35 36 #include <ipc/ipc.h> 37 #include <async.h> 36 #include <packet/packet.h> 38 37 39 extern int tl_module_message(ipc_callid_t callid, ipc_call_t *call, 40 ipc_call_t *answer, int *answer_count); 41 extern int tl_module_start(async_client_conn_t client_connection); 38 extern int packet_translate_remote(int, packet_ref, packet_id_t); 39 extern packet_t packet_get_4_remote(int, size_t, size_t, size_t, size_t); 40 extern packet_t packet_get_1_remote(int, size_t); 41 extern void pq_release_remote(int, packet_id_t); 42 42 43 43 #endif -
uspace/lib/net/include/tl_common.h
r24ab58b3 r14f1db0 49 49 DEVICE_MAP_DECLARE(packet_dimensions, packet_dimension_t); 50 50 51 extern int tl_get_ip_packet_dimension(int, packet_dimensions_ref, 52 device_id_t, packet_dimension_ref *); 53 51 54 /** Gets the address port. 52 55 * Supports AF_INET and AF_INET6 address families. … … 59 62 */ 60 63 extern int tl_get_address_port(const struct sockaddr * addr, int addrlen, uint16_t * port); 61 62 /** Gets IP packet dimensions.63 * Tries to search a cache and queries the IP module if not found.64 * The reply is cached then.65 * @param[in] ip_phone The IP moduel phone for (semi)remote calls.66 * @param[in] packet_dimensions The packet dimensions cache.67 * @param[in] device_id The device identifier.68 * @param[out] packet_dimension The IP packet dimensions.69 * @returns EOK on success.70 * @returns EBADMEM if the packet_dimension parameter is NULL.71 * @return ENOMEM if there is not enough memory left.72 * @returns EINVAL if the packet_dimensions cache is not valid.73 * @returns Other codes as defined for the ip_packet_size_req() function.74 */75 extern int tl_get_ip_packet_dimension(int ip_phone, packet_dimensions_ref packet_dimensions, device_id_t device_id, packet_dimension_ref * packet_dimension);76 64 77 65 /** Updates IP device packet dimensions cache. -
uspace/lib/net/include/tl_interface.h
r24ab58b3 r14f1db0 32 32 33 33 /** @file 34 * 34 * Transport layer module interface for the underlying internetwork layer. 35 35 */ 36 36 … … 48 48 49 49 /** @name Transport layer module interface 50 * 50 * This interface is used by other modules. 51 51 */ 52 52 /*@{*/ 53 53 54 /** Notifies the remote transport layer modules about the received packet/s. 55 * @param[in] tl_phone The transport layer module phone used for remote calls. 56 * @param[in] device_id The device identifier. 57 * @param[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. 58 * @param[in] target The target transport layer module service to be delivered to. 59 * @param[in] error The packet error reporting service. Prefixes the received packet. 60 * @returns EOK on success. 54 /** Notify the remote transport layer modules about the received packet/s. 55 * 56 * @param[in] tl_phone The transport layer module phone used for remote calls. 57 * @param[in] device_id The device identifier. 58 * @param[in] packet The received packet or the received packet queue. 59 * The packet queue is used to carry a fragmented 60 * datagram. The first packet contains the headers, 61 * the others contain only data. 62 * @param[in] target The target transport layer module service to be 63 * delivered to. 64 * @param[in] error The packet error reporting service. Prefixes the 65 * received packet. 66 * 67 * @return EOK on success. 68 * 61 69 */ 62 inline static int tl_received_msg(int tl_phone, device_id_t device_id, packet_t packet, services_t target, services_t error){ 63 return generic_received_msg(tl_phone, NET_TL_RECEIVED, device_id, packet_get_id(packet), target, error); 70 inline static int tl_received_msg(int tl_phone, device_id_t device_id, 71 packet_t packet, services_t target, services_t error) 72 { 73 return generic_received_msg_remote(tl_phone, NET_TL_RECEIVED, device_id, 74 packet_get_id(packet), target, error); 64 75 } 65 76 -
uspace/lib/net/include/tl_local.h
r24ab58b3 r14f1db0 27 27 */ 28 28 29 /** @addtogroup nil_standalone29 /** @addtogroup tl_local 30 30 * @{ 31 31 */ 32 32 33 #ifndef __ NIL_STANDALONE_H__34 #define __ NIL_STANDALONE_H__33 #ifndef __TL_LOCAL_H__ 34 #define __TL_LOCAL_H__ 35 35 36 36 #include <ipc/ipc.h> 37 37 #include <async.h> 38 38 39 extern int nil_module_message(const char *,ipc_callid_t, ipc_call_t *,39 extern int tl_module_message_standalone(ipc_callid_t, ipc_call_t *, 40 40 ipc_call_t *, int *); 41 extern int nil_module_start(async_client_conn_t);41 extern int tl_module_start_standalone(async_client_conn_t); 42 42 43 43 #endif -
uspace/lib/net/netif/netif_nil_bundle.c
r24ab58b3 r14f1db0 41 41 #include <net_messages.h> 42 42 #include <packet/packet.h> 43 #include <nil_module.h>44 43 #include <netif_nil_bundle.h> 45 #include <netif.h> 44 #include <netif_local.h> 45 #include <nil_local.h> 46 46 47 47 /** Distribute the messages between the module parts. … … 62 62 ipc_call_t *call, ipc_call_t *answer, int *answer_count) 63 63 { 64 if ( IS_NET_NIL_MESSAGE(call)64 if ((IS_NET_NIL_MESSAGE(call)) 65 65 || (IPC_GET_METHOD(*call) == IPC_M_CONNECT_TO_ME)) 66 return nil_message(name, callid, call, answer, answer_count); 66 return nil_message_standalone(name, callid, call, answer, 67 answer_count); 67 68 else 68 return netif_message(name, callid, call, answer, answer_count); 69 return netif_module_message_standalone(name, callid, call, answer, 70 answer_count); 69 71 } 70 72 71 /** Starts the bundle network interface module. 72 * Initializes the client connection serving function, initializes both module parts, registers the module service and starts the async manager, processing IPC messages in an infinite loop. 73 * @param[in] client_connection The client connection processing function. The module skeleton propagates its own one. 74 * @returns EOK on success. 75 * @returns Other error codes as defined for each specific module message function. 73 /** Start the bundle network interface module. 74 * 75 * Initialize the client connection serving function, initialize 76 * both module parts, register the module service and start the 77 * async manager, processing IPC messages in an infinite loop. 78 * 79 * @param[in] client_connection The client connection processing 80 * function. The module skeleton propagates 81 * its own one. 82 * 83 * @return EOK on success. 84 * @return Other error codes as defined for each specific module message 85 * function. 86 * 76 87 */ 77 int netif_nil_module_start(async_client_conn_t client_connection){ 88 int netif_nil_module_start(async_client_conn_t client_connection) 89 { 78 90 ERROR_DECLARE; 79 91 80 92 ERROR_PROPAGATE(netif_init_module(client_connection)); 81 if (ERROR_OCCURRED(nil_initialize(netif_globals.net_phone))){93 if (ERROR_OCCURRED(nil_initialize(netif_globals.net_phone))) { 82 94 pm_destroy(); 83 95 return ERROR_CODE; 84 96 } 85 return netif_run_module(); 97 98 async_manager(); 99 100 pm_destroy(); 101 return EOK; 86 102 } 87 103 -
uspace/lib/net/netif/netif_remote.c
r24ab58b3 r14f1db0 28 28 29 29 /** @addtogroup netif 30 * 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Network interface module interface implementation for standalone remote modules. 35 * @see netif_interface.h 34 * Network interface module interface implementation for remote modules. 36 35 */ 37 36 … … 43 42 #include <packet/packet_client.h> 44 43 #include <net_device.h> 45 #include <netif_ interface.h>44 #include <netif_remote.h> 46 45 #include <netif_messages.h> 47 46 48 int netif_get_addr_req(int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data){ 49 return generic_get_addr_req(netif_phone, NET_NETIF_GET_ADDR, device_id, address, data); 47 int netif_get_addr_req_remote(int netif_phone, device_id_t device_id, 48 measured_string_ref *address, char **data) 49 { 50 return generic_get_addr_req(netif_phone, NET_NETIF_GET_ADDR, device_id, 51 address, data); 50 52 } 51 53 52 int netif_probe_req(int netif_phone, device_id_t device_id, int irq, int io){ 54 int netif_probe_req_remote(int netif_phone, device_id_t device_id, int irq, int io) 55 { 53 56 return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq, io); 54 57 } 55 58 56 int netif_send_msg(int netif_phone, device_id_t device_id, packet_t packet, services_t sender){ 57 return generic_send_msg(netif_phone, NET_NETIF_SEND, device_id, packet_get_id(packet), sender, 0); 59 int netif_send_msg_remote(int netif_phone, device_id_t device_id, packet_t packet, 60 services_t sender) 61 { 62 return generic_send_msg_remote(netif_phone, NET_NETIF_SEND, device_id, 63 packet_get_id(packet), sender, 0); 58 64 } 59 65 60 int netif_start_req(int netif_phone, device_id_t device_id){ 66 int netif_start_req_remote(int netif_phone, device_id_t device_id) 67 { 61 68 return async_req_1_0(netif_phone, NET_NETIF_START, device_id); 62 69 } 63 70 64 int netif_stop_req(int netif_phone, device_id_t device_id){ 71 int netif_stop_req_remote(int netif_phone, device_id_t device_id) 72 { 65 73 return async_req_1_0(netif_phone, NET_NETIF_STOP, device_id); 66 74 } 67 75 68 int netif_stats_req(int netif_phone, device_id_t device_id, device_stats_ref stats){ 69 aid_t message_id; 76 int netif_stats_req_remote(int netif_phone, device_id_t device_id, 77 device_stats_ref stats) 78 { 79 if (!stats) 80 return EBADMEM; 81 82 aid_t message_id = async_send_1(netif_phone, NET_NETIF_STATS, 83 (ipcarg_t) device_id, NULL); 84 async_data_read_start(netif_phone, stats, sizeof(*stats)); 85 70 86 ipcarg_t result; 71 72 if(! stats){73 return EBADMEM;74 }75 message_id = async_send_1(netif_phone, NET_NETIF_STATS, (ipcarg_t) device_id, NULL);76 async_data_read_start(netif_phone, stats, sizeof(*stats));77 87 async_wait_for(message_id, &result); 88 78 89 return (int) result; 79 90 } 80 91 81 int netif_bind_service(services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver){ 92 int netif_bind_service_remote(services_t service, device_id_t device_id, services_t me, 93 async_client_conn_t receiver) 94 { 82 95 return bind_service(service, device_id, me, 0, receiver); 83 96 } -
uspace/lib/net/nil/nil_remote.c
r24ab58b3 r14f1db0 28 28 29 29 /** @addtogroup net_nil 30 * 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Network interface layer interface implementation for standaloneremote modules.35 * 34 * Network interface layer interface implementation for remote modules. 35 * @see nil_interface.h 36 36 */ 37 37 … … 42 42 #include <packet/packet_client.h> 43 43 #include <nil_messages.h> 44 #include <nil_remote.h> 44 45 45 int nil_device_state_msg(int nil_phone, device_id_t device_id, int state){ 46 return generic_device_state_msg(nil_phone, NET_NIL_DEVICE_STATE, device_id, state, 0); 46 /** Notify the network interface layer about the device state change. 47 * 48 * @param[in] nil_phone The network interface layer phone. 49 * @param[in] device_id The device identifier. 50 * @param[in] state The new device state. 51 * 52 * @return EOK on success. 53 * @return Other error codes as defined for each specific module device 54 * state function. 55 * 56 */ 57 int nil_device_state_msg_remote(int nil_phone, device_id_t device_id, int state) 58 { 59 return generic_device_state_msg_remote(nil_phone, NET_NIL_DEVICE_STATE, 60 device_id, state, 0); 47 61 } 48 62 49 int nil_received_msg(int nil_phone, device_id_t device_id, packet_t packet, services_t target){ 50 return generic_received_msg(nil_phone, NET_NIL_RECEIVED, device_id, packet_get_id(packet), target, 0); 63 /** Pass the packet queue to the network interface layer. 64 * 65 * Process and redistribute the received packet queue to the registered 66 * upper layers. 67 * 68 * @param[in] nil_phone The network interface layer phone. 69 * @param[in] device_id The source device identifier. 70 * @param[in] packet The received packet or the received packet queue. 71 * @param target The target service. Ignored parameter. 72 * 73 * @return EOK on success. 74 * @return Other error codes as defined for each specific module 75 * received function. 76 * 77 */ 78 int nil_received_msg_remote(int nil_phone, device_id_t device_id, 79 packet_t packet, services_t target) 80 { 81 return generic_received_msg_remote(nil_phone, NET_NIL_RECEIVED, device_id, 82 packet_get_id(packet), target, 0); 51 83 } 52 84 -
uspace/lib/net/tl/icmp_remote.c
r24ab58b3 r14f1db0 32 32 33 33 /** @file 34 * ICMP interface implementation for standaloneremote modules.34 * ICMP interface implementation for remote modules. 35 35 * @see icmp_interface.h 36 36 */ -
uspace/lib/net/tl/tl_common.c
r24ab58b3 r14f1db0 42 42 #include <packet/packet.h> 43 43 #include <packet/packet_client.h> 44 #include <packet_remote.h> 44 45 #include <net_device.h> 45 46 #include <icmp_interface.h> … … 47 48 #include <in6.h> 48 49 #include <inet.h> 49 #include <ip_interface.h> 50 #include <ip_local.h> 51 #include <ip_remote.h> 50 52 #include <socket_codes.h> 51 53 #include <socket_errno.h> 54 #include <ip_interface.h> 55 #include <tl_interface.h> 52 56 #include <tl_common.h> 53 57 … … 82 86 } 83 87 84 int tl_get_ip_packet_dimension(int ip_phone, packet_dimensions_ref packet_dimensions, device_id_t device_id, packet_dimension_ref * packet_dimension){ 88 /** Get IP packet dimensions. 89 * 90 * Try to search a cache and query the IP module if not found. 91 * The reply is cached then. 92 * 93 * @param[in] ip_phone The IP moduel phone for (semi)remote calls. 94 * @param[in] packet_dimensions The packet dimensions cache. 95 * @param[in] device_id The device identifier. 96 * @param[out] packet_dimension The IP packet dimensions. 97 * 98 * @return EOK on success. 99 * @return EBADMEM if the packet_dimension parameter is NULL. 100 * @return ENOMEM if there is not enough memory left. 101 * @return EINVAL if the packet_dimensions cache is not valid. 102 * @return Other codes as defined for the ip_packet_size_req() function. 103 * 104 */ 105 int tl_get_ip_packet_dimension(int ip_phone, 106 packet_dimensions_ref packet_dimensions, device_id_t device_id, 107 packet_dimension_ref *packet_dimension) 108 { 85 109 ERROR_DECLARE; 86 87 if (! packet_dimension){110 111 if (!packet_dimension) 88 112 return EBADMEM; 89 } 90 113 91 114 *packet_dimension = packet_dimensions_find(packet_dimensions, device_id); 92 if (! * packet_dimension){93 / / ask for and remember them if not found94 *packet_dimension = malloc(sizeof(** 95 if(! * packet_dimension){115 if (!*packet_dimension) { 116 /* Ask for and remember them if not found */ 117 *packet_dimension = malloc(sizeof(**packet_dimension)); 118 if(!*packet_dimension) 96 119 return ENOMEM; 97 } 98 if(ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id, * packet_dimension))){ 120 121 if (ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id, 122 *packet_dimension))) { 99 123 free(*packet_dimension); 100 124 return ERROR_CODE; 101 125 } 102 ERROR_CODE = packet_dimensions_add(packet_dimensions, device_id, * packet_dimension); 103 if(ERROR_CODE < 0){ 126 127 ERROR_CODE = packet_dimensions_add(packet_dimensions, device_id, 128 *packet_dimension); 129 if (ERROR_CODE < 0) { 104 130 free(*packet_dimension); 105 131 return ERROR_CODE; 106 132 } 107 133 } 134 108 135 return EOK; 109 136 } … … 169 196 // detach the first packet and release the others 170 197 next = pq_detach(packet); 171 if (next){172 pq_release (packet_phone, packet_get_id(next));173 }198 if (next) 199 pq_release_remote(packet_phone, packet_get_id(next)); 200 174 201 length = packet_get_addr(packet, &src, NULL); 175 202 if((length > 0) … … 180 207 return EOK; 181 208 }else{ 182 pq_release (packet_phone, packet_get_id(packet));209 pq_release_remote(packet_phone, packet_get_id(packet)); 183 210 } 184 211 return ENOENT; … … 200 227 } 201 228 // get a new packet 202 *packet = packet_get_4 (packet_phone, length, dimension->addr_len, prefix + dimension->prefix, dimension->suffix);229 *packet = packet_get_4_remote(packet_phone, length, dimension->addr_len, prefix + dimension->prefix, dimension->suffix); 203 230 if(! packet){ 204 231 return ENOMEM; … … 207 234 data = packet_suffix(*packet, length); 208 235 if(! data){ 209 pq_release (packet_phone, packet_get_id(*packet));236 pq_release_remote(packet_phone, packet_get_id(*packet)); 210 237 return ENOMEM; 211 238 } … … 214 241 // set the packet destination address 215 242 || ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen))){ 216 pq_release (packet_phone, packet_get_id(*packet));243 pq_release_remote(packet_phone, packet_get_id(*packet)); 217 244 return ERROR_CODE; 218 245 }
Note:
See TracChangeset
for help on using the changeset viewer.