Changeset 774e6d1a in mainline
- Timestamp:
- 2011-01-09T23:24:53Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4b86dac
- Parents:
- 3c106e88
- Location:
- uspace
- Files:
-
- 1 deleted
- 44 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/net/modules.c
r3c106e88 r774e6d1a 32 32 33 33 /** @file 34 * Generic module functions implementation. 34 * Generic module functions implementation. 35 35 * 36 36 * @todo MAKE IT POSSIBLE TO REMOVE THIS FILE VIA EITHER REPLACING PART OF ITS … … 52 52 #define MODULE_WAIT_TIME (10 * 1000) 53 53 54 /** Answer s thecall.55 * 56 * @param[in] callid The call identifier.57 * @param[in] result The message processing result.58 * @param[in] answer The message processing answer.59 * @param[in] answer_count The number of answer parameters.60 * /61 void 62 answer_call(ipc_callid_t callid, int result, ipc_call_t *answer,63 int answer_count)64 { 65 /* Choose the most efficient answerfunction */66 if ( answer || (!answer_count)) {67 switch ( answer_count) {54 /** Answer a call. 55 * 56 * @param[in] callid Call identifier. 57 * @param[in] result Message processing result. 58 * @param[in] answer Message processing answer. 59 * @param[in] count Number of answer parameters. 60 * 61 */ 62 void answer_call(ipc_callid_t callid, int result, ipc_call_t *answer, 63 size_t count) 64 { 65 /* Choose the most efficient function */ 66 if ((answer != NULL) || (count == 0)) { 67 switch (count) { 68 68 case 0: 69 69 ipc_answer_0(callid, (sysarg_t) result); … … 228 228 } 229 229 230 /** Refreshes answer structure and parameters count. 231 * 232 * Erases all attributes. 233 * 234 * @param[in,out] answer The message processing answer structure. 235 * @param[in,out] answer_count The number of answer parameters. 236 */ 237 void refresh_answer(ipc_call_t *answer, int *answer_count) 238 { 239 if (answer_count) 240 *answer_count = 0; 241 242 if (answer) { 230 /** Refresh answer structure and argument count. 231 * 232 * Erase all arguments. 233 * 234 * @param[in,out] answer Message processing answer structure. 235 * @param[in,out] count Number of answer arguments. 236 * 237 */ 238 void refresh_answer(ipc_call_t *answer, size_t *count) 239 { 240 if (count != NULL) 241 *count = 0; 242 243 if (answer != NULL) { 243 244 IPC_SET_RETVAL(*answer, 0); 244 /* Just to be precise */245 245 IPC_SET_IMETHOD(*answer, 0); 246 246 IPC_SET_ARG1(*answer, 0); -
uspace/lib/c/include/ipc/arp.h
r3c106e88 r774e6d1a 69 69 /*@{*/ 70 70 71 /** Returns the protocol service message parameter. 72 * @param[in] call The message call structure. 71 /** Return the protocol service message parameter. 72 * 73 * @param[in] call Message call structure. 74 * 73 75 */ 74 #define ARP_GET_NETIF(call) \ 75 ({ \ 76 services_t service = (services_t) IPC_GET_ARG2(*call); \ 77 service; \ 78 }) 76 #define ARP_GET_NETIF(call) ((services_t) IPC_GET_ARG2(call)) 79 77 80 78 /*@}*/ -
uspace/lib/c/include/ipc/icmp.h
r3c106e88 r774e6d1a 82 82 /*@{*/ 83 83 84 /** Return sthe ICMP code message parameter.84 /** Return the ICMP code message parameter. 85 85 * 86 * @param[in] call The message call structure. 86 * @param[in] call Message call structure. 87 * 87 88 */ 88 #define ICMP_GET_CODE(call) \ 89 ({ \ 90 icmp_code_t code = (icmp_code_t) IPC_GET_ARG1(*call); \ 91 code; \ 92 }) 89 #define ICMP_GET_CODE(call) ((icmp_code_t) IPC_GET_ARG1(call)) 93 90 94 /** Return sthe ICMP link MTU message parameter.91 /** Return the ICMP link MTU message parameter. 95 92 * 96 * @param[in] call The message call structure. 93 * @param[in] call Message call structure. 94 * 97 95 */ 98 #define ICMP_GET_MTU(call) \ 99 ({ \ 100 icmp_param_t mtu = (icmp_param_t) IPC_GET_ARG3(*call); \ 101 mtu; \ 102 }) 96 #define ICMP_GET_MTU(call) ((icmp_param_t) IPC_GET_ARG3(call)) 103 97 104 /** Return sthe pointer message parameter.98 /** Return the pointer message parameter. 105 99 * 106 * @param[in] call The message call structure. 100 * @param[in] call Message call structure. 101 * 107 102 */ 108 #define ICMP_GET_POINTER(call) \ 109 ({ \ 110 icmp_param_t pointer = (icmp_param_t) IPC_GET_ARG3(*call); \ 111 pointer; \ 112 }) 103 #define ICMP_GET_POINTER(call) ((icmp_param_t) IPC_GET_ARG3(call)) 113 104 114 /** Return sthe size message parameter.105 /** Return the size message parameter. 115 106 * 116 * @param[in] call The message call structure. 107 * @param[in] call Message call structure. 108 * 117 109 */ 118 #define ICMP_GET_SIZE(call) \ 119 ({ \ 120 size_t size = (size_t) IPC_GET_ARG1(call); \ 121 size; \ 122 }) 110 #define ICMP_GET_SIZE(call) ((size_t) IPC_GET_ARG1(call)) 123 111 124 /** Return sthe timeout message parameter.112 /** Return the timeout message parameter. 125 113 * 126 * @param[in] call The message call structure. 114 * @param[in] call Message call structure. 115 * 127 116 */ 128 #define ICMP_GET_TIMEOUT(call) \ 129 ({ \ 130 suseconds_t timeout = (suseconds_t) IPC_GET_ARG2(call); \ 131 timeout; \ 132 }) 117 #define ICMP_GET_TIMEOUT(call) ((suseconds_t) IPC_GET_ARG2(call)) 133 118 134 /** Return sthe time to live message parameter.119 /** Return the time to live message parameter. 135 120 * 136 * @param[in] call The message call structure. 121 * @param[in] call Message call structure. 122 * 137 123 */ 138 #define ICMP_GET_TTL(call) \ 139 ({ \ 140 ip_ttl_t ttl = (ip_ttl_t) IPC_GET_ARG3(call); \ 141 ttl; \ 142 }) 124 #define ICMP_GET_TTL(call) ((ip_ttl_t) IPC_GET_ARG3(call)) 143 125 144 /** Return sthe type of service message parameter.126 /** Return the type of service message parameter. 145 127 * 146 * @param[in] call The message call structure. 128 * @param[in] call Message call structure. 129 * 147 130 */ 148 #define ICMP_GET_TOS(call) \ 149 ({ \ 150 ip_tos_t tos = (ip_tos_t) IPC_GET_ARG4(call); \ 151 tos; \ 152 }) 131 #define ICMP_GET_TOS(call) ((ip_tos_t) IPC_GET_ARG4(call)) 153 132 154 /** Return sthe dont fragment message parameter.133 /** Return the dont fragment message parameter. 155 134 * 156 * @param[in] call The message call structure.135 * @param[in] call Message call structure. 157 136 */ 158 #define ICMP_GET_DONT_FRAGMENT(call) \ 159 ({ \ 160 int dont_fragment = (int) IPC_GET_ARG5(call); \ 161 dont_fragment; \ 162 }) 137 #define ICMP_GET_DONT_FRAGMENT(call) ((int) IPC_GET_ARG5(call)) 163 138 164 139 /*@}*/ -
uspace/lib/c/include/ipc/il.h
r3c106e88 r774e6d1a 75 75 76 76 /** Return the protocol number message parameter. 77 * @param[in] call The message call structure. 77 * 78 * @param[in] call Message call structure. 79 * 78 80 */ 79 #define IL_GET_PROTO(call) (int) IPC_GET_ARG1(*call)81 #define IL_GET_PROTO(call) ((int) IPC_GET_ARG1(call)) 80 82 81 83 /** Return the registering service message parameter. 82 * @param[in] call The message call structure. 84 * 85 * @param[in] call Message call structure. 86 * 83 87 */ 84 #define IL_GET_SERVICE(call) (services_t) IPC_GET_ARG2(*call)88 #define IL_GET_SERVICE(call) ((services_t) IPC_GET_ARG2(call)) 85 89 86 90 /*@}*/ -
uspace/lib/c/include/ipc/ip.h
r3c106e88 r774e6d1a 51 51 */ 52 52 NET_IP_ADD_ROUTE = NET_IP_FIRST, 53 53 54 /** Gets the actual route information. 54 55 * @see ip_get_route() 55 56 */ 56 57 NET_IP_GET_ROUTE, 58 57 59 /** Processes the received error notification. 58 60 * @see ip_received_error_msg() 59 61 */ 60 62 NET_IP_RECEIVED_ERROR, 63 61 64 /** Sets the default gateway. 62 65 * @see ip_set_default_gateway() … … 68 71 /*@{*/ 69 72 70 /** Returns the address message parameter. 71 * @param[in] call The message call structure. 73 /** Return the address message parameter. 74 * 75 * @param[in] call Message call structure. 76 * 72 77 */ 73 78 #define IP_GET_ADDRESS(call) \ 74 79 ({ \ 75 80 in_addr_t addr; \ 76 addr.s_addr = IPC_GET_ARG3( *call); \81 addr.s_addr = IPC_GET_ARG3(call); \ 77 82 addr; \ 78 83 }) 79 84 80 /** Returns the gateway message parameter. 81 * @param[in] call The message call structure. 85 /** Return the gateway message parameter. 86 * 87 * @param[in] call Message call structure. 88 * 82 89 */ 83 90 #define IP_GET_GATEWAY(call) \ 84 91 ({ \ 85 92 in_addr_t addr; \ 86 addr.s_addr = IPC_GET_ARG2( *call); \93 addr.s_addr = IPC_GET_ARG2(call); \ 87 94 addr; \ 88 95 }) 89 96 90 /** Sets the header length in the message answer. 91 * @param[out] answer The message answer structure. 97 /** Set the header length in the message answer. 98 * 99 * @param[out] answer Message answer structure. 100 * 92 101 */ 93 #define IP_SET_HEADERLEN(answer, value) \ 94 do { \ 95 sysarg_t argument = (sysarg_t) (value); \ 96 IPC_SET_ARG2(*answer, argument); \ 97 } while (0) 102 #define IP_SET_HEADERLEN(answer, value) IPC_SET_ARG2(answer, (sysarg_t) (value)) 98 103 99 /** Returns the network mask message parameter. 100 * @param[in] call The message call structure. 104 /** Return the network mask message parameter. 105 * 106 * @param[in] call Message call structure. 107 * 101 108 */ 102 109 #define IP_GET_NETMASK(call) \ 103 110 ({ \ 104 111 in_addr_t addr; \ 105 addr.s_addr = IPC_GET_ARG4( *call); \112 addr.s_addr = IPC_GET_ARG4(call); \ 106 113 addr; \ 107 114 }) 108 115 109 /** Returns the protocol message parameter. 110 * @param[in] call The message call structure. 116 /** Return the protocol message parameter. 117 * 118 * @param[in] call Message call structure. 119 * 111 120 */ 112 #define IP_GET_PROTOCOL(call) \ 113 ({ \ 114 ip_protocol_t protocol = (ip_protocol_t) IPC_GET_ARG1(*call); \ 115 protocol; \ 116 }) 121 #define IP_GET_PROTOCOL(call) ((ip_protocol_t) IPC_GET_ARG1(call)) 117 122 118 123 /*@}*/ -
uspace/lib/c/include/ipc/net.h
r3c106e88 r774e6d1a 44 44 #include <net/packet.h> 45 45 46 /** Returns a value indicating whether the value is in the interval. 47 * @param[in] item The value to be checked. 48 * @param[in] first_inclusive The first value in the interval inclusive. 49 * @param[in] last_exclusive The first value after the interval. 46 /** Return a value indicating whether the value is in the interval. 47 * 48 * @param[in] item Value to be checked. 49 * @param[in] first_inclusive First value in the interval inclusive. 50 * @param[in] last_exclusive First value after the interval. 51 * 50 52 */ 51 53 #define IS_IN_INTERVAL(item, first_inclusive, last_exclusive) \ … … 55 57 /*@{*/ 56 58 57 /** The number of ARP messages. */ 58 #define NET_ARP_COUNT 5 59 60 /** The number of Ethernet messages. */ 61 #define NET_ETH_COUNT 0 62 63 /** The number of ICMP messages. */ 64 #define NET_ICMP_COUNT 6 65 66 /** The number of inter-network messages. */ 67 #define NET_IL_COUNT 6 68 69 /** The number of IP messages. */ 70 #define NET_IP_COUNT 4 71 72 /** The number of general networking messages. */ 73 #define NET_NET_COUNT 3 74 75 /** The number of network interface driver messages. */ 76 #define NET_NETIF_COUNT 6 77 78 /** The number of network interface layer messages. */ 79 #define NET_NIL_COUNT 7 80 81 /** The number of packet management system messages. */ 82 #define NET_PACKET_COUNT 5 83 84 /** The number of socket messages. */ 85 #define NET_SOCKET_COUNT 14 86 87 /** The number of TCP messages. */ 88 #define NET_TCP_COUNT 0 89 90 /** The number of transport layer messages. */ 91 #define NET_TL_COUNT 1 92 93 /** The number of UDP messages. */ 94 #define NET_UDP_COUNT 0 59 #define NET_ARP_COUNT 5 /**< Number of ARP messages. */ 60 #define NET_ETH_COUNT 0 /**< Number of Ethernet messages. */ 61 #define NET_ICMP_COUNT 6 /**< Number of ICMP messages. */ 62 #define NET_IL_COUNT 6 /**< Number of inter-network messages. */ 63 #define NET_IP_COUNT 4 /**< Number of IP messages. */ 64 #define NET_NET_COUNT 3 /**< Number of general networking messages. */ 65 #define NET_NETIF_COUNT 6 /**< Number of network interface driver messages. */ 66 #define NET_NIL_COUNT 7 /**< Number of network interface layer messages. */ 67 #define NET_PACKET_COUNT 5 /**< Number of packet management system messages. */ 68 #define NET_SOCKET_COUNT 14 /**< Number of socket messages. */ 69 #define NET_TCP_COUNT 0 /**< Number of TCP messages. */ 70 #define NET_TL_COUNT 1 /**< Number of transport layer messages. */ 71 #define NET_UDP_COUNT 0 /**< Number of UDP messages. */ 95 72 96 73 /*@}*/ … … 100 77 /*@{*/ 101 78 102 /** The first networking message. */ 103 #define NET_FIRST 2000 104 105 /** The first network interface layer message. */ 106 #define NET_NETIF_FIRST NET_FIRST 107 108 /** The last network interface layer message. */ 109 #define NET_NETIF_LAST (NET_NETIF_FIRST + NET_NETIF_COUNT) 110 111 /** The first general networking message. */ 112 #define NET_NET_FIRST (NET_NETIF_LAST + 0) 113 114 /** The last general networking message. */ 115 #define NET_NET_LAST (NET_NET_FIRST + NET_NET_COUNT) 116 117 /** The first network interface layer message. */ 118 #define NET_NIL_FIRST (NET_NET_LAST + 0) 119 120 /** The last network interface layer message. */ 121 #define NET_NIL_LAST (NET_NIL_FIRST + NET_NIL_COUNT) 122 123 /** The first Ethernet message. */ 124 #define NET_ETH_FIRST (NET_NIL_LAST + 0) 125 126 /** The last Ethernet message. */ 127 #define NET_ETH_LAST (NET_ETH_FIRST + NET_ETH_COUNT) 128 129 /** The first inter-network message. */ 130 #define NET_IL_FIRST (NET_ETH_LAST + 0) 131 132 /** The last inter-network message. */ 133 #define NET_IL_LAST (NET_IL_FIRST + NET_IL_COUNT) 134 135 /** The first IP message. */ 136 #define NET_IP_FIRST (NET_IL_LAST + 0) 137 138 /** The last IP message. */ 139 #define NET_IP_LAST (NET_IP_FIRST + NET_IP_COUNT) 140 141 /** The first ARP message. */ 142 #define NET_ARP_FIRST (NET_IP_LAST + 0) 143 144 /** The last ARP message. */ 145 #define NET_ARP_LAST (NET_ARP_FIRST + NET_ARP_COUNT) 146 147 /** The first ICMP message. */ 148 #define NET_ICMP_FIRST (NET_ARP_LAST + 0) 149 150 /** The last ICMP message. */ 151 #define NET_ICMP_LAST (NET_ICMP_FIRST + NET_ICMP_COUNT) 152 153 /** The first ICMP message. */ 154 #define NET_TL_FIRST (NET_ICMP_LAST + 0) 155 156 /** The last ICMP message. */ 157 #define NET_TL_LAST (NET_TL_FIRST + NET_TL_COUNT) 158 159 /** The first UDP message. */ 160 #define NET_UDP_FIRST (NET_TL_LAST + 0) 161 162 /** The last UDP message. */ 163 #define NET_UDP_LAST (NET_UDP_FIRST + NET_UDP_COUNT) 164 165 /** The first TCP message. */ 166 #define NET_TCP_FIRST (NET_UDP_LAST + 0) 167 168 /** The last TCP message. */ 169 #define NET_TCP_LAST (NET_TCP_FIRST + NET_TCP_COUNT) 170 171 /** The first socket message. */ 172 #define NET_SOCKET_FIRST (NET_TCP_LAST + 0) 173 174 /** The last socket message. */ 175 #define NET_SOCKET_LAST (NET_SOCKET_FIRST + NET_SOCKET_COUNT) 176 177 /** The first packet management system message. */ 178 #define NET_PACKET_FIRST (NET_SOCKET_LAST + 0) 179 180 /** The last packet management system message. */ 181 #define NET_PACKET_LAST (NET_PACKET_FIRST + NET_PACKET_COUNT) 182 183 /** The last networking message. */ 184 #define NET_LAST NET_PACKET_LAST 185 186 /** The number of networking messages. */ 187 #define NET_COUNT (NET_LAST - NET_FIRST) 188 189 /** Returns a value indicating whether the IPC call is a generic networking 190 * message. 191 * @param[in] call The IPC call to be checked. 79 80 /** First networking message. */ 81 #define NET_FIRST 2000 82 83 /** First network interface layer message. */ 84 #define NET_NETIF_FIRST NET_FIRST 85 86 /** Last network interface layer message. */ 87 #define NET_NETIF_LAST (NET_NETIF_FIRST + NET_NETIF_COUNT) 88 89 /** First general networking message. */ 90 #define NET_NET_FIRST (NET_NETIF_LAST + 0) 91 92 /** Last general networking message. */ 93 #define NET_NET_LAST (NET_NET_FIRST + NET_NET_COUNT) 94 95 /** First network interface layer message. */ 96 #define NET_NIL_FIRST (NET_NET_LAST + 0) 97 98 /** Last network interface layer message. */ 99 #define NET_NIL_LAST (NET_NIL_FIRST + NET_NIL_COUNT) 100 101 /** First Ethernet message. */ 102 #define NET_ETH_FIRST (NET_NIL_LAST + 0) 103 104 /** Last Ethernet message. */ 105 #define NET_ETH_LAST (NET_ETH_FIRST + NET_ETH_COUNT) 106 107 /** First inter-network message. */ 108 #define NET_IL_FIRST (NET_ETH_LAST + 0) 109 110 /** Last inter-network message. */ 111 #define NET_IL_LAST (NET_IL_FIRST + NET_IL_COUNT) 112 113 /** First IP message. */ 114 #define NET_IP_FIRST (NET_IL_LAST + 0) 115 116 /** Last IP message. */ 117 #define NET_IP_LAST (NET_IP_FIRST + NET_IP_COUNT) 118 119 /** First ARP message. */ 120 #define NET_ARP_FIRST (NET_IP_LAST + 0) 121 122 /** Last ARP message. */ 123 #define NET_ARP_LAST (NET_ARP_FIRST + NET_ARP_COUNT) 124 125 /** First ICMP message. */ 126 #define NET_ICMP_FIRST (NET_ARP_LAST + 0) 127 128 /** Last ICMP message. */ 129 #define NET_ICMP_LAST (NET_ICMP_FIRST + NET_ICMP_COUNT) 130 131 /** First ICMP message. */ 132 #define NET_TL_FIRST (NET_ICMP_LAST + 0) 133 134 /** Last ICMP message. */ 135 #define NET_TL_LAST (NET_TL_FIRST + NET_TL_COUNT) 136 137 /** First UDP message. */ 138 #define NET_UDP_FIRST (NET_TL_LAST + 0) 139 140 /** Last UDP message. */ 141 #define NET_UDP_LAST (NET_UDP_FIRST + NET_UDP_COUNT) 142 143 /** First TCP message. */ 144 #define NET_TCP_FIRST (NET_UDP_LAST + 0) 145 146 /** Last TCP message. */ 147 #define NET_TCP_LAST (NET_TCP_FIRST + NET_TCP_COUNT) 148 149 /** First socket message. */ 150 #define NET_SOCKET_FIRST (NET_TCP_LAST + 0) 151 152 /** Last socket message. */ 153 #define NET_SOCKET_LAST (NET_SOCKET_FIRST + NET_SOCKET_COUNT) 154 155 /** First packet management system message. */ 156 #define NET_PACKET_FIRST (NET_SOCKET_LAST + 0) 157 158 /** Last packet management system message. */ 159 #define NET_PACKET_LAST (NET_PACKET_FIRST + NET_PACKET_COUNT) 160 161 /** Last networking message. */ 162 #define NET_LAST NET_PACKET_LAST 163 164 /** Number of networking messages. */ 165 #define NET_COUNT (NET_LAST - NET_FIRST) 166 167 /** Check if the IPC call is a generic networking message. 168 * 169 * @param[in] call IPC call to be checked. 170 * 192 171 */ 193 172 #define IS_NET_MESSAGE(call) \ 194 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_FIRST, NET_LAST) 195 196 /** Returns a value indicating whether the IPC call is an ARP message. 197 * @param[in] call The IPC call to be checked. 173 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_FIRST, NET_LAST) 174 175 /** Check if the IPC call is an ARP message. 176 * 177 * @param[in] call IPC call to be checked. 178 * 198 179 */ 199 180 #define IS_NET_ARP_MESSAGE(call) \ 200 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ARP_FIRST, NET_ARP_LAST) 201 202 /** Returns a value indicating whether the IPC call is an Ethernet message. 203 * @param[in] call The IPC call to be checked. 181 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_ARP_FIRST, NET_ARP_LAST) 182 183 /** Check if the IPC call is an Ethernet message. 184 * 185 * @param[in] call IPC call to be checked. 186 * 204 187 */ 205 188 #define IS_NET_ETH_MESSAGE(call) \ 206 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ETH_FIRST, NET_ETH_LAST) 207 208 /** Returns a value indicating whether the IPC call is an ICMP message. 209 * @param[in] call The IPC call to be checked. 189 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_ETH_FIRST, NET_ETH_LAST) 190 191 /** Check if the IPC call is an ICMP message. 192 * 193 * @param[in] call IPC call to be checked. 194 * 210 195 */ 211 196 #define IS_NET_ICMP_MESSAGE(call) \ 212 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ICMP_FIRST, NET_ICMP_LAST) 213 214 /** Returns a value indicating whether the IPC call is an inter-network layer 215 * message. 216 * @param[in] call The IPC call to be checked. 197 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_ICMP_FIRST, NET_ICMP_LAST) 198 199 /** Check if the IPC call is an inter-network layer message. 200 * 201 * @param[in] call IPC call to be checked. 202 * 217 203 */ 218 204 #define IS_NET_IL_MESSAGE(call) \ 219 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_IL_FIRST, NET_IL_LAST) 220 221 /** Returns a value indicating whether the IPC call is an IP message. 222 * @param[in] call The IPC call to be checked. 205 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_IL_FIRST, NET_IL_LAST) 206 207 /** Check if the IPC call is an IP message. 208 * 209 * @param[in] call IPC call to be checked. 210 * 223 211 */ 224 212 #define IS_NET_IP_MESSAGE(call) \ 225 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_IP_FIRST, NET_IP_LAST) 226 227 /** Returns a value indicating whether the IPC call is a generic networking 228 * message. 229 * @param[in] call The IPC call to be checked. 213 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_IP_FIRST, NET_IP_LAST) 214 215 /** Check if the IPC call is a generic networking message. 216 * 217 * @param[in] call IPC call to be checked. 218 * 230 219 */ 231 220 #define IS_NET_NET_MESSAGE(call) \ 232 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_NET_FIRST, NET_NET_LAST) 233 234 /** Returns a value indicating whether the IPC call is a network interface layer 235 * message. 236 * @param[in] call The IPC call to be checked. 221 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_NET_FIRST, NET_NET_LAST) 222 223 /** Check if the IPC call is a network interface layer message. 224 * 225 * @param[in] call IPC call to be checked. 226 * 237 227 */ 238 228 #define IS_NET_NIL_MESSAGE(call) \ 239 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_NIL_FIRST, NET_NIL_LAST) 240 241 /** Returns a value indicating whether the IPC call is a packet manaagement 242 * system message. 243 * @param[in] call The IPC call to be checked. 229 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_NIL_FIRST, NET_NIL_LAST) 230 231 /** Check if the IPC call is a packet manaagement system message. 232 * 233 * @param[in] call IPC call to be checked. 234 * 244 235 */ 245 236 #define IS_NET_PACKET_MESSAGE(call) \ 246 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_PACKET_FIRST, NET_PACKET_LAST) 247 248 /** Returns a value indicating whether the IPC call is a socket message. 249 * @param[in] call The IPC call to be checked. 237 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_PACKET_FIRST, NET_PACKET_LAST) 238 239 /** Check if the IPC call is a socket message. 240 * 241 * @param[in] call IPC call to be checked. 242 * 250 243 */ 251 244 #define IS_NET_SOCKET_MESSAGE(call) \ 252 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_SOCKET_FIRST, NET_SOCKET_LAST) 253 254 /** Returns a value indicating whether the IPC call is a TCP message. 255 * @param[in] call The IPC call to be checked. 245 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_SOCKET_FIRST, NET_SOCKET_LAST) 246 247 /** Check if the IPC call is a TCP message. 248 * 249 * @param[in] call IPC call to be checked. 250 * 256 251 */ 257 252 #define IS_NET_TCP_MESSAGE(call) \ 258 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_TCP_FIRST, NET_TCP_LAST) 259 260 /** Returns a value indicating whether the IPC call is a transport layer message. 261 * @param[in] call The IPC call to be checked. 253 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_TCP_FIRST, NET_TCP_LAST) 254 255 /** Check if the IPC call is a transport layer message. 256 * 257 * @param[in] call IPC call to be checked. 258 * 262 259 */ 263 260 #define IS_NET_TL_MESSAGE(call) \ 264 IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_TL_FIRST, NET_TL_LAST) 265 266 /** Returns a value indicating whether the IPC call is a UDP message. 267 * @param[in] call The IPC call to be checked. 261 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_TL_FIRST, NET_TL_LAST) 262 263 /** Check if the IPC call is a UDP message. 264 * 265 * @param[in] call IPC call to be checked. 266 * 268 267 */ 269 268 #define IS_NET_UDP_MESSAGE(call) \ 270 IS_IN_INTERVAL(IPC_GET_IMETHOD( *call), NET_UDP_FIRST, NET_UDP_LAST)269 IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_UDP_FIRST, NET_UDP_LAST) 271 270 272 271 /*@}*/ … … 275 274 /*@{*/ 276 275 277 /** Returns the device identifier message argument. 278 * @param[in] call The message call structure. 279 */ 280 #define IPC_GET_DEVICE(call) \ 281 ({ \ 282 device_id_t device_id = (device_id_t) IPC_GET_ARG1(*call); \ 283 device_id; \ 284 }) 285 286 /** Returns the packet identifier message argument. 287 * @param[in] call The message call structure. 288 */ 289 #define IPC_GET_PACKET(call) \ 290 ({ \ 291 packet_id_t packet_id = (packet_id_t) IPC_GET_ARG2(*call); \ 292 packet_id; \ 293 }) 294 295 /** Returns the count message argument. 296 * @param[in] call The message call structure. 297 */ 298 #define IPC_GET_COUNT(call) \ 299 ({ \ 300 size_t size = (size_t) IPC_GET_ARG2(*call); \ 301 size; \ 302 }) 303 304 /** Returns the device state message argument. 305 * @param[in] call The message call structure. 306 */ 307 #define IPC_GET_STATE(call) \ 308 ({ \ 309 device_state_t state = (device_state_t) IPC_GET_ARG2(*call); \ 310 state; \ 311 }) 312 313 /** Returns the maximum transmission unit message argument. 314 * @param[in] call The message call structure. 315 */ 316 #define IPC_GET_MTU(call) \ 317 ({ \ 318 size_t size = (size_t) IPC_GET_ARG2(*call); \ 319 size; \ 320 }) 321 322 /** Returns the device driver service message argument. 323 * @param[in] call The message call structure. 324 */ 325 #define IPC_GET_SERVICE(call) \ 326 ({ \ 327 services_t service = (services_t) IPC_GET_ARG3(*call); \ 328 service; \ 329 }) 330 331 /** Returns the target service message argument. 332 * @param[in] call The message call structure. 333 */ 334 #define IPC_GET_TARGET(call) \ 335 ({ \ 336 services_t service = (services_t) IPC_GET_ARG3(*call); \ 337 service; \ 338 }) 339 340 /** Returns the sender service message argument. 341 * @param[in] call The message call structure. 342 */ 343 #define IPC_GET_SENDER(call) \ 344 ({ \ 345 services_t service = (services_t) IPC_GET_ARG3(*call); \ 346 service; \ 347 }) 348 349 /** Returns the error service message argument. 350 * @param[in] call The message call structure. 351 */ 352 #define IPC_GET_ERROR(call) \ 353 ({ \ 354 services_t service = (services_t) IPC_GET_ARG4(*call); \ 355 service; \ 356 }) 357 358 /** Returns the phone message argument. 359 * @param[in] call The message call structure. 360 */ 361 #define IPC_GET_PHONE(call) \ 362 ({ \ 363 int phone = (int) IPC_GET_ARG5(*call); \ 364 phone; \ 365 }) 366 367 /** Sets the device identifier in the message answer. 368 * @param[out] answer The message answer structure. 369 */ 370 #define IPC_SET_DEVICE(answer, value) \ 371 do { \ 372 sysarg_t argument = (sysarg_t) (value); \ 373 IPC_SET_ARG1(*answer, argument); \ 374 } while (0) 375 376 /** Sets the minimum address length in the message answer. 377 * @param[out] answer The message answer structure. 378 */ 379 #define IPC_SET_ADDR(answer, value) \ 380 do { \ 381 sysarg_t argument = (sysarg_t) (value); \ 382 IPC_SET_ARG1(*answer, argument); \ 383 } while (0) 384 385 /** Sets the minimum prefix size in the message answer. 386 * @param[out] answer The message answer structure. 387 */ 388 #define IPC_SET_PREFIX(answer, value) \ 389 do { \ 390 sysarg_t argument = (sysarg_t) (value); \ 391 IPC_SET_ARG2(*answer, argument); \ 392 } while (0) 393 394 /** Sets the maximum content size in the message answer. 395 * @param[out] answer The message answer structure. 396 */ 397 #define IPC_SET_CONTENT(answer, value) \ 398 do { \ 399 sysarg_t argument = (sysarg_t) (value); \ 400 IPC_SET_ARG3(*answer, argument); \ 401 } while (0) 402 403 /** Sets the minimum suffix size in the message answer. 404 * @param[out] answer The message answer structure. 405 */ 406 #define IPC_SET_SUFFIX(answer, value) \ 407 do { \ 408 sysarg_t argument = (sysarg_t) (value); \ 409 IPC_SET_ARG4(*answer, argument); \ 410 } while (0) 276 /** Return the device identifier message argument. 277 * 278 * @param[in] call Message call structure. 279 * 280 */ 281 #define IPC_GET_DEVICE(call) ((device_id_t) IPC_GET_ARG1(call)) 282 283 /** Return the packet identifier message argument. 284 * 285 * @param[in] call Message call structure. 286 * 287 */ 288 #define IPC_GET_PACKET(call) ((packet_id_t) IPC_GET_ARG2(call)) 289 290 /** Return the count message argument. 291 * 292 * @param[in] call Message call structure. 293 * 294 */ 295 #define IPC_GET_COUNT(call) ((size_t) IPC_GET_ARG2(call)) 296 297 /** Return the device state message argument. 298 * 299 * @param[in] call Message call structure. 300 * 301 */ 302 #define IPC_GET_STATE(call) ((device_state_t) IPC_GET_ARG2(call)) 303 304 /** Return the maximum transmission unit message argument. 305 * 306 * @param[in] call Message call structure. 307 * 308 */ 309 #define IPC_GET_MTU(call) ((size_t) IPC_GET_ARG2(call)) 310 311 /** Return the device driver service message argument. 312 * 313 * @param[in] call Message call structure. 314 * 315 */ 316 #define IPC_GET_SERVICE(call) ((services_t) IPC_GET_ARG3(call)) 317 318 /** Return the target service message argument. 319 * 320 * @param[in] call Message call structure. 321 * 322 */ 323 #define IPC_GET_TARGET(call) ((services_t) IPC_GET_ARG3(call)) 324 325 /** Return the sender service message argument. 326 * 327 * @param[in] call Message call structure. 328 * 329 */ 330 #define IPC_GET_SENDER(call) ((services_t) IPC_GET_ARG3(call)) 331 332 /** Return the error service message argument. 333 & 334 * @param[in] call Message call structure. 335 * 336 */ 337 #define IPC_GET_ERROR(call) ((services_t) IPC_GET_ARG4(call)) 338 339 /** Return the phone message argument. 340 * 341 * @param[in] call Message call structure. 342 * 343 */ 344 #define IPC_GET_PHONE(call) ((int) IPC_GET_ARG5(call)) 345 346 /** Set the device identifier in the message answer. 347 * 348 * @param[out] answer Message answer structure. 349 * @param[in] value Value to set. 350 * 351 */ 352 #define IPC_SET_DEVICE(answer, value) IPC_SET_ARG1(answer, (sysarg_t) (value)) 353 354 /** Set the minimum address length in the message answer. 355 * 356 * @param[out] answer Message answer structure. 357 * @param[in] value Value to set. 358 * 359 */ 360 #define IPC_SET_ADDR(answer, value) IPC_SET_ARG1(answer, (sysarg_t) (value)) 361 362 /** Set the minimum prefix size in the message answer. 363 * 364 * @param[out] answer Message answer structure. 365 * @param[in] value Value to set. 366 * 367 */ 368 #define IPC_SET_PREFIX(answer, value) IPC_SET_ARG2(answer, (sysarg_t) (value)) 369 370 /** Set the maximum content size in the message answer. 371 * 372 * @param[out] answer Message answer structure. 373 * @param[in] value Value to set. 374 * 375 */ 376 #define IPC_SET_CONTENT(answer, value) IPC_SET_ARG3(answer, (sysarg_t) (value)) 377 378 /** Set the minimum suffix size in the message answer. 379 * 380 * @param[out] answer Message answer structure. 381 * @param[in] value Value to set. 382 * 383 */ 384 #define IPC_SET_SUFFIX(answer, value) IPC_SET_ARG4(answer, (sysarg_t) (value)) 411 385 412 386 /*@}*/ -
uspace/lib/c/include/ipc/netif.h
r3c106e88 r774e6d1a 47 47 */ 48 48 NET_NETIF_PROBE = NET_NETIF_FIRST, 49 49 50 /** Send packet message. 50 51 * @see netif_send_msg() 51 52 */ 52 53 NET_NETIF_SEND, 54 53 55 /** Start device message. 54 56 * @see netif_start_req() 55 57 */ 56 58 NET_NETIF_START, 59 57 60 /** Get device usage statistics message. 58 61 * @see netif_stats_req() 59 62 */ 60 63 NET_NETIF_STATS, 64 61 65 /** Stop device message. 62 66 * @see netif_stop_req() 63 67 */ 64 68 NET_NETIF_STOP, 69 65 70 /** Get device address message. 66 71 * @see netif_get_addr_req() … … 73 78 74 79 /** Return the interrupt number message parameter. 75 * @param[in] call The message call structure. 80 * 81 * @param[in] call Mmessage call structure. 82 * 76 83 */ 77 #define NETIF_GET_IRQ(call) \ 78 ({ \ 79 int irq = (int) IPC_GET_ARG2(*call); \ 80 irq; \ 81 }) 84 #define NETIF_GET_IRQ(call) ((int) IPC_GET_ARG2(call)) 82 85 83 86 /** Return the input/output address message parameter. 84 * @param[in] call The message call structure. 87 * 88 * @param[in] call Message call structure. 89 * 85 90 */ 86 #define NETIF_GET_IO(call) \ 87 ({ \ 88 int io = (int) IPC_GET_ARG3(*call); \ 89 io; \ 90 }) 91 #define NETIF_GET_IO(call) ((void *) IPC_GET_ARG3(call)) 91 92 92 93 /*@}*/ -
uspace/lib/c/include/ipc/nil.h
r3c106e88 r774e6d1a 77 77 78 78 /** Return the protocol service message parameter. */ 79 #define NIL_GET_PROTO(call) \ 80 ({ \ 81 services_t service = (services_t) IPC_GET_ARG2(*call); \ 82 service; \ 83 }) 79 #define NIL_GET_PROTO(call) ((services_t) IPC_GET_ARG2(call)) 84 80 85 81 /*@}*/ -
uspace/lib/c/include/ipc/packet.h
r3c106e88 r774e6d1a 70 70 } packet_messages; 71 71 72 /** Return sthe protocol service message parameter. */73 #define ARP_GET_PROTO(call) (services_t) IPC_GET_ARG2(*call)72 /** Return the protocol service message parameter. */ 73 #define ARP_GET_PROTO(call) ((services_t) IPC_GET_ARG2(call)) 74 74 75 /** Return sthe packet identifier message parameter. */76 #define IPC_GET_ID(call) (packet_id_t) IPC_GET_ARG1(*call)75 /** Return the packet identifier message parameter. */ 76 #define IPC_GET_ID(call) ((packet_id_t) IPC_GET_ARG1(call)) 77 77 78 /** Return sthe maximal content length message parameter. */79 #define IPC_GET_CONTENT(call) (size_t) IPC_GET_ARG1(*call)78 /** Return the maximal content length message parameter. */ 79 #define IPC_GET_CONTENT(call) ((size_t) IPC_GET_ARG1(call)) 80 80 81 /** Return sthe maximal address length message parameter. */82 #define IPC_GET_ADDR_LEN(call) (size_t) IPC_GET_ARG2(*call)81 /** Return the maximal address length message parameter. */ 82 #define IPC_GET_ADDR_LEN(call) ((size_t) IPC_GET_ARG2(call)) 83 83 84 /** Return sthe maximal prefix length message parameter. */85 #define IPC_GET_PREFIX(call) (size_t) IPC_GET_ARG3(*call)84 /** Return the maximal prefix length message parameter. */ 85 #define IPC_GET_PREFIX(call) ((size_t) IPC_GET_ARG3(call)) 86 86 87 /** Return sthe maximal suffix length message parameter. */88 #define IPC_GET_SUFFIX(call) (size_t) IPC_GET_ARG4(*call)87 /** Return the maximal suffix length message parameter. */ 88 #define IPC_GET_SUFFIX(call) ((size_t) IPC_GET_ARG4(call)) 89 89 90 90 #endif -
uspace/lib/c/include/net/in.h
r3c106e88 r774e6d1a 43 43 44 44 /** INET string address maximum length. */ 45 #define INET_ADDRSTRLEN 45 #define INET_ADDRSTRLEN (4 * 3 + 3 + 1) 46 46 47 47 /** Type definition of the INET address. 48 48 * @see in_addr 49 49 */ 50 typedef struct in_addr 50 typedef struct in_addr in_addr_t; 51 51 52 52 /** Type definition of the INET socket address. -
uspace/lib/c/include/net/modules.h
r3c106e88 r774e6d1a 51 51 /** Connect to the needed module function type definition. 52 52 * 53 * @param[in] need The needed module service. 54 * @return The phone of the needed service. 53 * @param[in] need The needed module service. 54 * 55 * @return The phone of the needed service. 56 * 55 57 */ 56 58 typedef int connect_module_t(services_t need); 57 59 58 extern void answer_call(ipc_callid_t, int, ipc_call_t *, int);60 extern void answer_call(ipc_callid_t, int, ipc_call_t *, size_t); 59 61 extern int bind_service(services_t, sysarg_t, sysarg_t, sysarg_t, 60 62 async_client_conn_t); … … 64 66 extern int connect_to_service_timeout(services_t, suseconds_t); 65 67 extern int data_reply(void *, size_t); 66 extern void refresh_answer(ipc_call_t *, int *);68 extern void refresh_answer(ipc_call_t *, size_t *); 67 69 68 70 #endif -
uspace/lib/net/Makefile
r3c106e88 r774e6d1a 40 40 generic/protocol_map.c \ 41 41 adt/module_map.c \ 42 netif/netif_local.c \43 42 netif/netif_remote.c \ 43 netif/netif_skel.c \ 44 44 nil/nil_remote.c \ 45 45 il/il_interface.c \ -
uspace/lib/net/il/ip_remote.c
r3c106e88 r774e6d1a 170 170 free(*header); 171 171 else 172 *device_id = IPC_GET_DEVICE( &answer);172 *device_id = IPC_GET_DEVICE(answer); 173 173 174 174 return (int) result; -
uspace/lib/net/include/il_local.h
r3c106e88 r774e6d1a 49 49 */ 50 50 extern int il_module_message_standalone(ipc_callid_t callid, ipc_call_t *call, 51 ipc_call_t *answer, int *answer_count);51 ipc_call_t *answer, size_t *answer_count); 52 52 53 53 /** Starts the Internet layer module. -
uspace/lib/net/include/netif_remote.h
r3c106e88 r774e6d1a 41 41 #include <net/packet.h> 42 42 43 extern int netif_get_addr_req _remote(int, device_id_t, measured_string_t **,43 extern int netif_get_addr_req(int, device_id_t, measured_string_t **, 44 44 uint8_t **); 45 extern int netif_probe_req _remote(int, device_id_t, int, int);46 extern int netif_send_msg _remote(int, device_id_t, packet_t *, services_t);47 extern int netif_start_req _remote(int, device_id_t);48 extern int netif_stop_req _remote(int, device_id_t);49 extern int netif_stats_req _remote(int, device_id_t, device_stats_t *);50 extern int netif_bind_service _remote(services_t, device_id_t, services_t,45 extern int netif_probe_req(int, device_id_t, int, void *); 46 extern int netif_send_msg(int, device_id_t, packet_t *, services_t); 47 extern int netif_start_req(int, device_id_t); 48 extern int netif_stop_req(int, device_id_t); 49 extern int netif_stats_req(int, device_id_t, device_stats_t *); 50 extern int netif_bind_service(services_t, device_id_t, services_t, 51 51 async_client_conn_t); 52 52 -
uspace/lib/net/include/netif_skel.h
r3c106e88 r774e6d1a 36 36 */ 37 37 38 #ifndef NET_NETIF_ LOCAL_H_39 #define NET_NETIF_ LOCAL_H_38 #ifndef NET_NETIF_SKEL_H_ 39 #define NET_NETIF_SKEL_H_ 40 40 41 41 #include <async.h> … … 76 76 * 77 77 * This function has to be implemented in user code. 78 * 78 79 */ 79 80 extern int netif_initialize(void); … … 83 84 * This has to be implemented in user code. 84 85 * 85 * @param[in] device_id The device identifier. 86 * @param[in] irq The device interrupt number. 87 * @param[in] io The device input/output address. 88 * 89 * @return EOK on success. 90 * @return Other error codes as defined for the find_device() 91 * function. 92 * @return Other error codes as defined for the specific module 93 * message implementation. 94 */ 95 extern int netif_probe_message(device_id_t device_id, int irq, uintptr_t io); 86 * @param[in] device_id Device identifier. 87 * @param[in] irq Device interrupt number. 88 * @param[in] io Device input/output address. 89 * 90 * @return EOK on success. 91 * @return Other error codes as defined for the find_device() 92 * function. 93 * @return Other error codes as defined for the specific module 94 * message implementation. 95 * 96 */ 97 extern int netif_probe_message(device_id_t device_id, int irq, void *io); 96 98 97 99 /** Send the packet queue. … … 99 101 * This has to be implemented in user code. 100 102 * 101 * @param[in] device_id The device identifier. 102 * @param[in] packet The packet queue. 103 * @param[in] sender The sending module service. 104 * 105 * @return EOK on success. 106 * @return EFORWARD if the device is not active (in the 107 * NETIF_ACTIVE state). 108 * @return Other error codes as defined for the find_device() 109 * function. 110 * @return Other error codes as defined for the specific module 111 * message implementation. 103 * @param[in] device_id Device identifier. 104 * @param[in] packet Packet queue. 105 * @param[in] sender Sending module service. 106 * 107 * @return EOK on success. 108 * @return EFORWARD if the device is not active (in the 109 * NETIF_ACTIVE state). 110 * @return Other error codes as defined for the find_device() 111 * function. 112 * @return Other error codes as defined for the specific module 113 * message implementation. 114 * 112 115 */ 113 116 extern int netif_send_message(device_id_t device_id, packet_t *packet, … … 118 121 * This has to be implemented in user code. 119 122 * 120 * @param[in] device The device structure. 121 * 122 * @return EOK on success. 123 * @return Other error codes as defined for the find_device() 124 * function. 125 * @return Other error codes as defined for the specific module 126 * message implementation. 123 * @param[in] device Device structure. 124 * 125 * @return New network interface state (non-negative values). 126 * @return Other error codes as defined for the find_device() 127 * function. 128 * @return Other error codes as defined for the specific module 129 * message implementation. 130 131 * 127 132 */ 128 133 extern int netif_start_message(netif_device_t *device); … … 132 137 * This has to be implemented in user code. 133 138 * 134 * @param[in] device The device structure. 135 * 136 * @return EOK on success. 137 * @return Other error codes as defined for the find_device() 138 * function. 139 * @return Other error codes as defined for the specific module 140 * message implementation. 139 * @param[in] device Device structure. 140 * 141 * @return EOK on success. 142 * @return Other error codes as defined for the find_device() 143 * function. 144 * @return Other error codes as defined for the specific module 145 * message implementation. 146 * 141 147 */ 142 148 extern int netif_stop_message(netif_device_t *device); … … 146 152 * This has to be implemented in user code. 147 153 * 148 * @param[in] device_id The device identifier. 149 * @param[out] address The device local hardware address. 150 * 151 * @return EOK on success. 152 * @return EBADMEM if the address parameter is NULL. 153 * @return ENOENT if there no such device. 154 * @return Other error codes as defined for the find_device() 155 * function. 156 * @return Other error codes as defined for the specific module 157 * message implementation. 154 * @param[in] device_id Device identifier. 155 * @param[out] address Device local hardware address. 156 * 157 * @return EOK on success. 158 * @return EBADMEM if the address parameter is NULL. 159 * @return ENOENT if there no such device. 160 * @return Other error codes as defined for the find_device() 161 * function. 162 * @return Other error codes as defined for the specific module 163 * message implementation. 164 * 158 165 */ 159 166 extern int netif_get_addr_message(device_id_t device_id, … … 165 172 * skeleton. This has to be implemented in user code. 166 173 * 167 * @param[in] callid The message identifier.168 * @param[in] call The message parameters.169 * @param[out] answer The message answer parameters.170 * @param[out] answer_count The last parameter for the actual answer in171 * the answer parameter.172 * 173 * @return EOK on success.174 * @return ENOTSUP if the message is not known.175 * @return Other error codes as defined for the specific module176 * message implementation.174 * @param[in] callid Message identifier. 175 * @param[in] call Message. 176 * @param[out] answer Answer. 177 * @param[out] count Number of answer arguments. 178 * 179 * @return EOK on success. 180 * @return ENOTSUP if the message is not known. 181 * @return Other error codes as defined for the specific module 182 * message implementation. 183 * 177 184 */ 178 185 extern int netif_specific_message(ipc_callid_t callid, ipc_call_t *call, 179 ipc_call_t *answer, int *answer_count);186 ipc_call_t *answer, size_t *count); 180 187 181 188 /** Return the device usage statistics. … … 183 190 * This has to be implemented in user code. 184 191 * 185 * @param[in] device_id The device identifier. 186 * @param[out] stats The device usage statistics. 187 * 188 * @return EOK on success. 189 * @return Other error codes as defined for the find_device() 190 * function. 191 * @return Other error codes as defined for the specific module 192 * message implementation. 192 * @param[in] device_id Device identifier. 193 * @param[out] stats Device usage statistics. 194 * 195 * @return EOK on success. 196 * @return Other error codes as defined for the find_device() 197 * function. 198 * @return Other error codes as defined for the specific module 199 * message implementation. 200 * 193 201 */ 194 202 extern int netif_get_device_stats(device_id_t device_id, 195 203 device_stats_t *stats); 196 197 extern int netif_get_addr_req_local(int, device_id_t, measured_string_t **,198 uint8_t **);199 extern int netif_probe_req_local(int, device_id_t, int, int);200 extern int netif_send_msg_local(int, device_id_t, packet_t *, services_t);201 extern int netif_start_req_local(int, device_id_t);202 extern int netif_stop_req_local(int, device_id_t);203 extern int netif_stats_req_local(int, device_id_t, device_stats_t *);204 extern int netif_bind_service_local(services_t, device_id_t, services_t,205 async_client_conn_t);206 204 207 205 extern int find_device(device_id_t, netif_device_t **); … … 209 207 extern void netif_pq_release(packet_id_t); 210 208 extern packet_t *netif_packet_get_1(size_t); 211 extern int netif_init_module(async_client_conn_t); 212 213 extern int netif_module_message_standalone(const char *, ipc_callid_t, 214 ipc_call_t *, ipc_call_t *, int *); 215 extern int netif_module_start_standalone(async_client_conn_t); 209 210 extern int netif_module_start(void); 216 211 217 212 #endif -
uspace/lib/net/include/nil_local.h
r3c106e88 r774e6d1a 96 96 */ 97 97 extern int nil_message_standalone(const char *, ipc_callid_t, ipc_call_t *, 98 ipc_call_t *, int *);98 ipc_call_t *, size_t *); 99 99 100 100 /** Pass the parameters to the module specific nil_message() function. … … 112 112 */ 113 113 extern int nil_module_message_standalone(const char *, ipc_callid_t, 114 ipc_call_t *, ipc_call_t *, int *);114 ipc_call_t *, ipc_call_t *, size_t *); 115 115 116 116 /** Start the standalone nil layer module. -
uspace/lib/net/include/tl_local.h
r3c106e88 r774e6d1a 52 52 */ 53 53 extern int tl_module_message_standalone(ipc_callid_t, ipc_call_t *, 54 ipc_call_t *, int *); 55 54 ipc_call_t *, size_t *); 56 55 57 56 /** Processes the TL module message. -
uspace/lib/net/netif/netif_remote.c
r3c106e88 r774e6d1a 27 27 */ 28 28 29 /** @addtogroup libnet 29 /** @addtogroup libnet 30 30 * @{ 31 31 */ … … 49 49 /** Return the device local hardware address. 50 50 * 51 * @param[in] netif_phone The network interface phone. 52 * @param[in] device_id The device identifier. 53 * @param[out] address The device local hardware address. 54 * @param[out] data The address data. 55 * @return EOK on success. 56 * @return EBADMEM if the address parameter is NULL. 57 * @return ENOENT if there no such device. 58 * @return Other error codes as defined for the 59 * netif_get_addr_message() function. 51 * @param[in] netif_phone Network interface phone. 52 * @param[in] device_id Device identifier. 53 * @param[out] address Device local hardware address. 54 * @param[out] data Address data. 55 * 56 * @return EOK on success. 57 * @return EBADMEM if the address parameter is NULL. 58 * @return ENOENT if there no such device. 59 * @return Other error codes as defined for the 60 * netif_get_addr_message() function. 61 * 60 62 */ 61 int netif_get_addr_req _remote(int netif_phone, device_id_t device_id,63 int netif_get_addr_req(int netif_phone, device_id_t device_id, 62 64 measured_string_t **address, uint8_t **data) 63 65 { … … 68 70 /** Probe the existence of the device. 69 71 * 70 * @param[in] netif_phone The network interface phone. 71 * @param[in] device_id The device identifier. 72 * @param[in] irq The device interrupt number. 73 * @param[in] io The device input/output address. 74 * @return EOK on success. 75 * @return Other error codes as defined for the 76 * netif_probe_message(). 72 * @param[in] netif_phone Network interface phone. 73 * @param[in] device_id Device identifier. 74 * @param[in] irq Device interrupt number. 75 * @param[in] io Device input/output address. 76 * 77 * @return EOK on success. 78 * @return Other error codes as defined for the 79 * netif_probe_message(). 80 * 77 81 */ 78 int 79 netif_probe_req_remote(int netif_phone, device_id_t device_id, int irq, int io) 82 int netif_probe_req(int netif_phone, device_id_t device_id, int irq, void *io) 80 83 { 81 return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq, io); 84 return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq, 85 (sysarg_t) io); 82 86 } 83 87 84 88 /** Send the packet queue. 85 89 * 86 * @param[in] netif_phone The network interface phone. 87 * @param[in] device_id The device identifier. 88 * @param[in] packet The packet queue. 89 * @param[in] sender The sending module service. 90 * @return EOK on success. 91 * @return Other error codes as defined for the generic_send_msg() 92 * function. 90 * @param[in] netif_phone Network interface phone. 91 * @param[in] device_id Device identifier. 92 * @param[in] packet Packet queue. 93 * @param[in] sender Sending module service. 94 * 95 * @return EOK on success. 96 * @return Other error codes as defined for the generic_send_msg() 97 * function. 98 * 93 99 */ 94 int 95 netif_send_msg_remote(int netif_phone, device_id_t device_id, packet_t *packet, 100 int netif_send_msg(int netif_phone, device_id_t device_id, packet_t *packet, 96 101 services_t sender) 97 102 { … … 102 107 /** Start the device. 103 108 * 104 * @param[in] netif_phone The network interface phone. 105 * @param[in] device_id The device identifier. 106 * @return EOK on success. 107 * @return Other error codes as defined for the find_device() 108 * function. 109 * @return Other error codes as defined for the 110 * netif_start_message() function. 109 * @param[in] netif_phone Network interface phone. 110 * @param[in] device_id Device identifier. 111 * 112 * @return EOK on success. 113 * @return Other error codes as defined for the find_device() 114 * function. 115 * @return Other error codes as defined for the 116 * netif_start_message() function. 117 * 111 118 */ 112 int netif_start_req _remote(int netif_phone, device_id_t device_id)119 int netif_start_req(int netif_phone, device_id_t device_id) 113 120 { 114 121 return async_req_1_0(netif_phone, NET_NETIF_START, device_id); … … 117 124 /** Stop the device. 118 125 * 119 * @param[in] netif_phone The network interface phone. 120 * @param[in] device_id The device identifier. 121 * @return EOK on success. 122 * @return Other error codes as defined for the find_device() 123 * function. 124 * @return Other error codes as defined for the 125 * netif_stop_message() function. 126 * @param[in] netif_phone Network interface phone. 127 * @param[in] device_id Device identifier. 128 * 129 * @return EOK on success. 130 * @return Other error codes as defined for the find_device() 131 * function. 132 * @return Other error codes as defined for the 133 * netif_stop_message() function. 134 * 126 135 */ 127 int netif_stop_req _remote(int netif_phone, device_id_t device_id)136 int netif_stop_req(int netif_phone, device_id_t device_id) 128 137 { 129 138 return async_req_1_0(netif_phone, NET_NETIF_STOP, device_id); … … 132 141 /** Return the device usage statistics. 133 142 * 134 * @param[in] netif_phone The network interface phone. 135 * @param[in] device_id The device identifier. 136 * @param[out] stats The device usage statistics. 143 * @param[in] netif_phone Network interface phone. 144 * @param[in] device_id Device identifier. 145 * @param[out] stats Device usage statistics. 146 * 137 147 * @return EOK on success. 148 * 138 149 */ 139 int netif_stats_req _remote(int netif_phone, device_id_t device_id,150 int netif_stats_req(int netif_phone, device_id_t device_id, 140 151 device_stats_t *stats) 141 152 { … … 153 164 } 154 165 155 /** Create bidirectional connection with the network interface module and 156 * registers the message receiver. 166 /** Create bidirectional connection with the network interface module 167 * 168 * Create bidirectional connection with the network interface module and 169 * register the message receiver. 157 170 * 158 171 * @param[in] service The network interface module service. … … 161 174 * @param[in] receiver The message receiver. 162 175 * 163 * @return The phone of the needed service. 164 * @return EOK on success. 165 * @return Other error codes as defined for the bind_service() 166 * function. 176 * @return The phone of the needed service. 177 * @return EOK on success. 178 * @return Other error codes as defined for the bind_service() 179 * function. 180 * 167 181 */ 168 int 169 netif_bind_service_remote(services_t service, device_id_t device_id, 182 int netif_bind_service(services_t service, device_id_t device_id, 170 183 services_t me, async_client_conn_t receiver) 171 184 { -
uspace/lib/net/netif/netif_skel.c
r3c106e88 r774e6d1a 27 27 */ 28 28 29 /** @addtogroup libnet 29 /** @addtogroup libnet 30 30 * @{ 31 31 */ … … 53 53 #include <net/device.h> 54 54 #include <nil_interface.h> 55 #include <netif_local.h> 56 #include <netif_interface.h> 55 #include <netif_skel.h> 57 56 58 57 DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t); … … 63 62 /** Probe the existence of the device. 64 63 * 65 * @param[in] netif_phone The network interface phone. 66 * @param[in] device_id The device identifier. 67 * @param[in] irq The device interrupt number. 68 * @param[in] io The device input/output address. 69 * @return EOK on success. 70 * @return Other error codes as defined for the 71 * netif_probe_message(). 72 */ 73 int 74 netif_probe_req_local(int netif_phone, device_id_t device_id, int irq, int io) 64 * @param[in] netif_phone Network interface phone. 65 * @param[in] device_id Device identifier. 66 * @param[in] irq Device interrupt number. 67 * @param[in] io Device input/output address. 68 * 69 * @return EOK on success. 70 * @return Other error codes as defined for the 71 * netif_probe_message(). 72 * 73 */ 74 static int netif_probe_req_local(int netif_phone, device_id_t device_id, 75 int irq, void *io) 75 76 { 76 77 fibril_rwlock_write_lock(&netif_globals.lock); … … 83 84 /** Send the packet queue. 84 85 * 85 * @param[in] netif_phone The network interface phone. 86 * @param[in] device_id The device identifier. 87 * @param[in] packet The packet queue. 88 * @param[in] sender The sending module service. 89 * @return EOK on success. 90 * @return Other error codes as defined for the generic_send_msg() 91 * function. 92 */ 93 int netif_send_msg_local(int netif_phone, device_id_t device_id, 86 * @param[in] netif_phone Network interface phone. 87 * @param[in] device_id Device identifier. 88 * @param[in] packet Packet queue. 89 * @param[in] sender Sending module service. 90 * 91 * @return EOK on success. 92 * @return Other error codes as defined for the generic_send_msg() 93 * function. 94 * 95 */ 96 static int netif_send_msg_local(int netif_phone, device_id_t device_id, 94 97 packet_t *packet, services_t sender) 95 98 { … … 103 106 /** Start the device. 104 107 * 105 * @param[in] netif_phone The network interface phone.106 * @param[in] device_id The device identifier.107 * @return EOK on success.108 * @return Other error codes as defined for the find_device()109 * function.110 * @return Other error codes as defined for the111 * netif_start_message() function.112 * /113 int netif_start_req_local(int netif_phone, device_id_t device_id) 114 { 115 int rc; 116 108 * @param[in] netif_phone Network interface phone. 109 * @param[in] device_id Device identifier. 110 * 111 * @return EOK on success. 112 * @return Other error codes as defined for the find_device() 113 * function. 114 * @return Other error codes as defined for the 115 * netif_start_message() function. 116 * 117 */ 118 static int netif_start_req_local(int netif_phone, device_id_t device_id) 119 { 117 120 fibril_rwlock_write_lock(&netif_globals.lock); 118 121 119 122 netif_device_t *device; 120 rc = find_device(device_id, &device);123 int rc = find_device(device_id, &device); 121 124 if (rc != EOK) { 122 125 fibril_rwlock_write_unlock(&netif_globals.lock); … … 139 142 /** Stop the device. 140 143 * 141 * @param[in] netif_phone The network interface phone.142 * @param[in] device_id The device identifier.143 * @return EOK on success.144 * @return Other error codes as defined for the find_device()145 * function.146 * @return Other error codes as defined for the147 * netif_stop_message() function.148 * /149 int netif_stop_req_local(int netif_phone, device_id_t device_id) 150 { 151 int rc; 152 144 * @param[in] netif_phone Network interface phone. 145 * @param[in] device_id Device identifier. 146 * 147 * @return EOK on success. 148 * @return Other error codes as defined for the find_device() 149 * function. 150 * @return Other error codes as defined for the 151 * netif_stop_message() function. 152 * 153 */ 154 static int netif_stop_req_local(int netif_phone, device_id_t device_id) 155 { 153 156 fibril_rwlock_write_lock(&netif_globals.lock); 154 157 155 158 netif_device_t *device; 156 rc = find_device(device_id, &device);159 int rc = find_device(device_id, &device); 157 160 if (rc != EOK) { 158 161 fibril_rwlock_write_unlock(&netif_globals.lock); … … 173 176 } 174 177 175 /** Return the device usage statistics.176 *177 * @param[in] netif_phone The network interface phone.178 * @param[in] device_id The device identifier.179 * @param[out] stats The device usage statistics.180 * @return EOK on success.181 */182 int netif_stats_req_local(int netif_phone, device_id_t device_id,183 device_stats_t *stats)184 {185 fibril_rwlock_read_lock(&netif_globals.lock);186 int res = netif_get_device_stats(device_id, stats);187 fibril_rwlock_read_unlock(&netif_globals.lock);188 189 return res;190 }191 192 /** Return the device local hardware address.193 *194 * @param[in] netif_phone The network interface phone.195 * @param[in] device_id The device identifier.196 * @param[out] address The device local hardware address.197 * @param[out] data The address data.198 * @return EOK on success.199 * @return EBADMEM if the address parameter is NULL.200 * @return ENOENT if there no such device.201 * @return Other error codes as defined for the202 * netif_get_addr_message() function.203 */204 int netif_get_addr_req_local(int netif_phone, device_id_t device_id,205 measured_string_t **address, uint8_t **data)206 {207 int rc;208 209 if (!address || !data)210 return EBADMEM;211 212 fibril_rwlock_read_lock(&netif_globals.lock);213 214 measured_string_t translation;215 rc = netif_get_addr_message(device_id, &translation);216 if (rc == EOK) {217 *address = measured_string_copy(&translation);218 rc = (*address) ? EOK : ENOMEM;219 }220 221 fibril_rwlock_read_unlock(&netif_globals.lock);222 223 *data = (**address).value;224 225 return rc;226 }227 228 178 /** Find the device specific data. 229 179 * 230 * @param[in] device_id The device identifier. 231 * @param[out] device The device specific data. 232 * @return EOK on success. 233 * @return ENOENT if device is not found. 234 * @return EPERM if the device is not initialized. 180 * @param[in] device_id Device identifier. 181 * @param[out] device Device specific data. 182 * 183 * @return EOK on success. 184 * @return ENOENT if device is not found. 185 * @return EPERM if the device is not initialized. 186 * 235 187 */ 236 188 int find_device(device_id_t device_id, netif_device_t **device) … … 251 203 /** Clear the usage statistics. 252 204 * 253 * @param[in] stats The usage statistics. 205 * @param[in] stats The usage statistics. 206 * 254 207 */ 255 208 void null_device_stats(device_stats_t *stats) … … 258 211 } 259 212 260 /** Initialize the netif module. 261 * 262 * @param[in] client_connection The client connection functio to be registered. 263 * @return EOK on success. 264 * @return Other error codes as defined for each specific module 265 * message function. 266 */ 267 int netif_init_module(async_client_conn_t client_connection) 268 { 269 int rc; 270 271 async_set_client_connection(client_connection); 272 273 netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING); 274 netif_device_map_initialize(&netif_globals.device_map); 275 276 rc = pm_init(); 213 /** Release the given packet. 214 * 215 * Prepared for future optimization. 216 * 217 * @param[in] packet_id The packet identifier. 218 * 219 */ 220 void netif_pq_release(packet_id_t packet_id) 221 { 222 pq_release_remote(netif_globals.net_phone, packet_id); 223 } 224 225 /** Allocate new packet to handle the given content size. 226 * 227 * @param[in] content Minimum content size. 228 * 229 * @return The allocated packet. 230 * @return NULL on error. 231 * 232 */ 233 packet_t *netif_packet_get_1(size_t content) 234 { 235 return packet_get_1_remote(netif_globals.net_phone, content); 236 } 237 238 /** Register the device notification receiver, 239 * 240 * Register a network interface layer module as the device 241 * notification receiver. 242 * 243 * @param[in] device_id Device identifier. 244 * @param[in] phone Network interface layer module phone. 245 * 246 * @return EOK on success. 247 * @return ENOENT if there is no such device. 248 * @return ELIMIT if there is another module registered. 249 * 250 */ 251 static int register_message(device_id_t device_id, int phone) 252 { 253 netif_device_t *device; 254 int rc = find_device(device_id, &device); 277 255 if (rc != EOK) 278 256 return rc; 279 257 280 fibril_rwlock_initialize(&netif_globals.lock); 281 282 rc = netif_initialize(); 283 if (rc != EOK) { 284 pm_destroy(); 285 return rc; 286 } 287 258 if (device->nil_phone >= 0) 259 return ELIMIT; 260 261 device->nil_phone = phone; 288 262 return EOK; 289 263 } 290 264 291 /** Release the given packet.292 *293 * Prepared for future optimization.294 *295 * @param[in] packet_id The packet identifier.296 */297 void netif_pq_release(packet_id_t packet_id)298 {299 pq_release_remote(netif_globals.net_phone, packet_id);300 }301 302 /** Allocate new packet to handle the given content size.303 *304 * @param[in] content The minimum content size.305 * @return The allocated packet.306 * @return NULL if there is an error.307 *308 */309 packet_t *netif_packet_get_1(size_t content)310 {311 return packet_get_1_remote(netif_globals.net_phone, content);312 }313 314 /** Register the device notification receiver, the network interface layer315 * module.316 *317 * @param[in] name Module name.318 * @param[in] device_id The device identifier.319 * @param[in] phone The network interface layer module phone.320 * @return EOK on success.321 * @return ENOENT if there is no such device.322 * @return ELIMIT if there is another module registered.323 */324 static int register_message(const char *name, device_id_t device_id, int phone)325 {326 netif_device_t *device;327 int rc;328 329 rc = find_device(device_id, &device);330 if (rc != EOK)331 return rc;332 333 if (device->nil_phone > 0)334 return ELIMIT;335 336 device->nil_phone = phone;337 printf("%s: Receiver of device %d registered (phone: %d)\n",338 name, device->device_id, device->nil_phone);339 return EOK;340 }341 342 265 /** Process the netif module messages. 343 266 * 344 * @param[in] name Module name. 345 * @param[in] callid The message identifier. 346 * @param[in] call The message parameters. 347 * @param[out] answer The message answer parameters. 348 * @param[out] answer_count The last parameter for the actual answer in the 349 * answer parameter. 350 * @return EOK on success. 351 * @return ENOTSUP if the message is not known. 352 * @return Other error codes as defined for each specific module 353 * message function. 267 * @param[in] callid Mmessage identifier. 268 * @param[in] call Message. 269 * @param[out] answer Answer. 270 * @param[out] count Number of arguments of the answer. 271 * 272 * @return EOK on success. 273 * @return ENOTSUP if the message is unknown. 274 * @return Other error codes as defined for each specific module 275 * message function. 354 276 * 355 277 * @see IS_NET_NETIF_MESSAGE() 356 278 * 357 279 */ 358 int netif_module_message_standalone(const char *name, ipc_callid_t callid,359 ipc_call_t * call, ipc_call_t *answer, int *answer_count)280 static int netif_module_message(ipc_callid_t callid, ipc_call_t *call, 281 ipc_call_t *answer, size_t *count) 360 282 { 361 283 size_t length; … … 365 287 int rc; 366 288 367 *answer_count = 0; 289 *count = 0; 290 368 291 switch (IPC_GET_IMETHOD(*call)) { 369 292 case IPC_M_PHONE_HUNGUP: … … 371 294 372 295 case NET_NETIF_PROBE: 373 return netif_probe_req_local(0, IPC_GET_DEVICE( call),374 NETIF_GET_IRQ( call), NETIF_GET_IO(call));375 296 return netif_probe_req_local(0, IPC_GET_DEVICE(*call), 297 NETIF_GET_IRQ(*call), NETIF_GET_IO(*call)); 298 376 299 case IPC_M_CONNECT_TO_ME: 377 300 fibril_rwlock_write_lock(&netif_globals.lock); 378 rc = register_message(name, IPC_GET_DEVICE(call), 379 IPC_GET_PHONE(call)); 301 302 rc = register_message(IPC_GET_DEVICE(*call), IPC_GET_PHONE(*call)); 303 380 304 fibril_rwlock_write_unlock(&netif_globals.lock); 381 305 return rc; 382 306 383 307 case NET_NETIF_SEND: 384 308 rc = packet_translate_remote(netif_globals.net_phone, &packet, 385 IPC_GET_PACKET( call));309 IPC_GET_PACKET(*call)); 386 310 if (rc != EOK) 387 311 return rc; 388 return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet, 389 IPC_GET_SENDER(call)); 390 312 313 return netif_send_msg_local(0, IPC_GET_DEVICE(*call), packet, 314 IPC_GET_SENDER(*call)); 315 391 316 case NET_NETIF_START: 392 return netif_start_req_local(0, IPC_GET_DEVICE( call));393 317 return netif_start_req_local(0, IPC_GET_DEVICE(*call)); 318 394 319 case NET_NETIF_STATS: 395 320 fibril_rwlock_read_lock(&netif_globals.lock); 396 321 397 322 rc = async_data_read_receive(&callid, &length); 398 323 if (rc != EOK) { … … 400 325 return rc; 401 326 } 327 402 328 if (length < sizeof(device_stats_t)) { 403 329 fibril_rwlock_read_unlock(&netif_globals.lock); 404 330 return EOVERFLOW; 405 331 } 406 407 rc = netif_get_device_stats(IPC_GET_DEVICE( call), &stats);332 333 rc = netif_get_device_stats(IPC_GET_DEVICE(*call), &stats); 408 334 if (rc == EOK) { 409 335 rc = async_data_read_finalize(callid, &stats, 410 336 sizeof(device_stats_t)); 411 337 } 412 338 413 339 fibril_rwlock_read_unlock(&netif_globals.lock); 414 340 return rc; 415 341 416 342 case NET_NETIF_STOP: 417 return netif_stop_req_local(0, IPC_GET_DEVICE( call));418 343 return netif_stop_req_local(0, IPC_GET_DEVICE(*call)); 344 419 345 case NET_NETIF_GET_ADDR: 420 346 fibril_rwlock_read_lock(&netif_globals.lock); 421 rc = netif_get_addr_message(IPC_GET_DEVICE(call), &address); 347 348 rc = netif_get_addr_message(IPC_GET_DEVICE(*call), &address); 422 349 if (rc == EOK) 423 350 rc = measured_strings_reply(&address, 1); 351 424 352 fibril_rwlock_read_unlock(&netif_globals.lock); 425 353 return rc; 426 354 } 427 355 428 return netif_specific_message(callid, call, answer, answer_count); 356 return netif_specific_message(callid, call, answer, count); 357 } 358 359 /** Default fibril for new module connections. 360 * 361 * @param[in] iid Initial message identifier. 362 * @param[in] icall Initial message call structure. 363 * 364 */ 365 static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall) 366 { 367 /* 368 * Accept the connection by answering 369 * the initial IPC_M_CONNECT_ME_TO call. 370 */ 371 ipc_answer_0(iid, EOK); 372 373 while (true) { 374 ipc_call_t answer; 375 size_t count; 376 377 /* Clear the answer structure */ 378 refresh_answer(&answer, &count); 379 380 /* Fetch the next message */ 381 ipc_call_t call; 382 ipc_callid_t callid = async_get_call(&call); 383 384 /* Process the message */ 385 int res = netif_module_message(callid, &call, &answer, &count); 386 387 /* End if said to either by the message or the processing result */ 388 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || 389 (res == EHANGUP)) 390 return; 391 392 /* Answer the message */ 393 answer_call(callid, res, &answer, count); 394 } 429 395 } 430 396 … … 435 401 * messages in an infinite loop. 436 402 * 437 * @param[in] client_connection The client connection processing function. 438 * The module skeleton propagates its own one. 439 * @return EOK on success. 440 * @return Other error codes as defined for each specific module 441 * message function. 442 */ 443 int netif_module_start_standalone(async_client_conn_t client_connection) 444 { 445 int rc; 446 447 rc = netif_init_module(client_connection); 403 * @return EOK on success. 404 * @return Other error codes as defined for each specific module 405 * message function. 406 * 407 */ 408 int netif_module_start(void) 409 { 410 async_set_client_connection(netif_client_connection); 411 412 netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING); 413 netif_device_map_initialize(&netif_globals.device_map); 414 415 int rc = pm_init(); 448 416 if (rc != EOK) 449 417 return rc; 418 419 fibril_rwlock_initialize(&netif_globals.lock); 420 421 rc = netif_initialize(); 422 if (rc != EOK) { 423 pm_destroy(); 424 return rc; 425 } 450 426 451 427 async_manager(); -
uspace/lib/packet/generic/packet_server.c
r3c106e88 r774e6d1a 322 322 int 323 323 packet_server_message(ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, 324 int *answer_count)324 size_t *answer_count) 325 325 { 326 326 packet_t *packet; … … 333 333 case NET_PACKET_CREATE_1: 334 334 packet = packet_get_local(DEFAULT_ADDR_LEN, DEFAULT_PREFIX, 335 IPC_GET_CONTENT( call), DEFAULT_SUFFIX);335 IPC_GET_CONTENT(*call), DEFAULT_SUFFIX); 336 336 if (!packet) 337 337 return ENOMEM; … … 343 343 case NET_PACKET_CREATE_4: 344 344 packet = packet_get_local( 345 ((DEFAULT_ADDR_LEN < IPC_GET_ADDR_LEN( call)) ?346 IPC_GET_ADDR_LEN( call) : DEFAULT_ADDR_LEN),347 DEFAULT_PREFIX + IPC_GET_PREFIX( call),348 IPC_GET_CONTENT( call),349 DEFAULT_SUFFIX + IPC_GET_SUFFIX( call));345 ((DEFAULT_ADDR_LEN < IPC_GET_ADDR_LEN(*call)) ? 346 IPC_GET_ADDR_LEN(*call) : DEFAULT_ADDR_LEN), 347 DEFAULT_PREFIX + IPC_GET_PREFIX(*call), 348 IPC_GET_CONTENT(*call), 349 DEFAULT_SUFFIX + IPC_GET_SUFFIX(*call)); 350 350 if (!packet) 351 351 return ENOMEM; … … 356 356 357 357 case NET_PACKET_GET: 358 packet = pm_find(IPC_GET_ID( call));358 packet = pm_find(IPC_GET_ID(*call)); 359 359 if (!packet_is_valid(packet)) 360 360 return ENOENT; … … 362 362 363 363 case NET_PACKET_GET_SIZE: 364 packet = pm_find(IPC_GET_ID( call));364 packet = pm_find(IPC_GET_ID(*call)); 365 365 if (!packet_is_valid(packet)) 366 366 return ENOENT; … … 370 370 371 371 case NET_PACKET_RELEASE: 372 return packet_release_wrapper(IPC_GET_ID( call));372 return packet_release_wrapper(IPC_GET_ID(*call)); 373 373 } 374 374 -
uspace/lib/packet/include/packet_server.h
r3c106e88 r774e6d1a 48 48 49 49 extern int packet_server_message(ipc_callid_t, ipc_call_t *, ipc_call_t *, 50 int *);50 size_t *); 51 51 52 52 #endif -
uspace/srv/net/il/arp/arp.c
r3c106e88 r774e6d1a 457 457 uint8_t *des_proto; 458 458 int rc; 459 459 460 460 length = packet_get_data_length(packet); 461 461 if (length <= sizeof(arp_header_t)) … … 677 677 int 678 678 arp_message_standalone(ipc_callid_t callid, ipc_call_t *call, 679 ipc_call_t *answer, int *answer_count)679 ipc_call_t *answer, size_t *answer_count) 680 680 { 681 681 measured_string_t *address; … … 696 696 return rc; 697 697 698 rc = arp_device_message(IPC_GET_DEVICE( call),699 IPC_GET_SERVICE( call), ARP_GET_NETIF(call), address);698 rc = arp_device_message(IPC_GET_DEVICE(*call), 699 IPC_GET_SERVICE(*call), ARP_GET_NETIF(*call), address); 700 700 if (rc != EOK) { 701 701 free(address); … … 710 710 711 711 fibril_mutex_lock(&arp_globals.lock); 712 rc = arp_translate_message(IPC_GET_DEVICE( call),713 IPC_GET_SERVICE( call), address, &translation);712 rc = arp_translate_message(IPC_GET_DEVICE(*call), 713 IPC_GET_SERVICE(*call), address, &translation); 714 714 free(address); 715 715 free(data); … … 727 727 728 728 case NET_ARP_CLEAR_DEVICE: 729 return arp_clear_device_req(0, IPC_GET_DEVICE( call));729 return arp_clear_device_req(0, IPC_GET_DEVICE(*call)); 730 730 731 731 case NET_ARP_CLEAR_ADDRESS: … … 734 734 return rc; 735 735 736 arp_clear_address_req(0, IPC_GET_DEVICE( call),737 IPC_GET_SERVICE( call), address);736 arp_clear_address_req(0, IPC_GET_DEVICE(*call), 737 IPC_GET_SERVICE(*call), address); 738 738 free(address); 739 739 free(data); … … 750 750 751 751 rc = packet_translate_remote(arp_globals.net_phone, &packet, 752 IPC_GET_PACKET( call));752 IPC_GET_PACKET(*call)); 753 753 if (rc != EOK) 754 754 return rc; … … 757 757 do { 758 758 next = pq_detach(packet); 759 rc = arp_receive_message(IPC_GET_DEVICE( call), packet);759 rc = arp_receive_message(IPC_GET_DEVICE(*call), packet); 760 760 if (rc != 1) { 761 761 pq_release_remote(arp_globals.net_phone, … … 769 769 770 770 case NET_IL_MTU_CHANGED: 771 return arp_mtu_changed_message(IPC_GET_DEVICE( call),772 IPC_GET_MTU( call));771 return arp_mtu_changed_message(IPC_GET_DEVICE(*call), 772 IPC_GET_MTU(*call)); 773 773 } 774 774 … … 791 791 while (true) { 792 792 ipc_call_t answer; 793 int answer_count;793 size_t count; 794 794 795 795 /* Clear the answer structure */ 796 refresh_answer(&answer, & answer_count);796 refresh_answer(&answer, &count); 797 797 798 798 /* Fetch the next message */ … … 802 802 /* Process the message */ 803 803 int res = il_module_message_standalone(callid, &call, &answer, 804 & answer_count);804 &count); 805 805 806 806 /* … … 813 813 814 814 /* Answer the message */ 815 answer_call(callid, res, &answer, answer_count);815 answer_call(callid, res, &answer, count); 816 816 } 817 817 } -
uspace/srv/net/il/arp/arp_module.c
r3c106e88 r774e6d1a 58 58 59 59 int il_module_message_standalone(ipc_callid_t callid, ipc_call_t *call, 60 ipc_call_t *answer, int *answer_count)60 ipc_call_t *answer, size_t *count) 61 61 { 62 return arp_message_standalone(callid, call, answer, answer_count);62 return arp_message_standalone(callid, call, answer, count); 63 63 } 64 64 -
uspace/srv/net/il/arp/arp_module.h
r3c106e88 r774e6d1a 44 44 extern int arp_initialize(async_client_conn_t); 45 45 extern int arp_message_standalone(ipc_callid_t, ipc_call_t *, ipc_call_t *, 46 int *);46 size_t *); 47 47 48 48 #endif -
uspace/srv/net/il/ip/ip.c
r3c106e88 r774e6d1a 477 477 ip_globals.gateway.gateway.s_addr = gateway.s_addr; 478 478 ip_globals.gateway.netif = ip_netif; 479 480 char defgateway[INET_ADDRSTRLEN]; 481 inet_ntop(AF_INET, (uint8_t *) &gateway.s_addr, 482 defgateway, INET_ADDRSTRLEN); 483 printf("%s: Default gateway (%s)\n", NAME, defgateway); 479 484 } 480 485 … … 1069 1074 int index; 1070 1075 ip_route_t *route; 1071 1076 1072 1077 if (!netif) 1073 1078 return NULL; 1074 1075 / / start with the first one - the direct route1079 1080 /* Start with the first one (the direct route) */ 1076 1081 for (index = 0; index < ip_routes_count(&netif->routes); index++) { 1077 1082 route = ip_routes_get_index(&netif->routes, index); 1078 if ( route&&1083 if ((route) && 1079 1084 ((route->address.s_addr & route->netmask.s_addr) == 1080 (destination.s_addr & route->netmask.s_addr))) {1085 (destination.s_addr & route->netmask.s_addr))) 1081 1086 return route; 1082 }1083 1087 } 1084 1088 … … 1288 1292 if (device_id > 0) { 1289 1293 netif = ip_netifs_find(&ip_globals.netifs, device_id); 1290 route = ip_netif_find_route(netif, * 1294 route = ip_netif_find_route(netif, *dest); 1291 1295 if (netif && !route && (ip_globals.gateway.netif == netif)) 1292 1296 route = &ip_globals.gateway; … … 1318 1322 } 1319 1323 } 1320 1324 1321 1325 // if the local host is the destination 1322 1326 if ((route->address.s_addr == dest->s_addr) && … … 1562 1566 socklen_t addrlen; 1563 1567 int rc; 1564 1568 1565 1569 header = (ip_header_t *) packet_get_data(packet); 1566 1570 if (!header) … … 1588 1592 return EINVAL; 1589 1593 } 1590 1594 1591 1595 // process ipopt and get destination 1592 1596 dest = ip_get_destination(header); … … 1609 1613 if (rc != EOK) 1610 1614 return rc; 1611 1615 1612 1616 route = ip_find_route(dest); 1613 1617 if (!route) { … … 1886 1890 int 1887 1891 ip_message_standalone(ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, 1888 int *answer_count)1892 size_t *answer_count) 1889 1893 { 1890 1894 packet_t *packet; … … 1905 1909 1906 1910 case IPC_M_CONNECT_TO_ME: 1907 return ip_register(IL_GET_PROTO( call), IL_GET_SERVICE(call),1908 IPC_GET_PHONE( call), NULL);1911 return ip_register(IL_GET_PROTO(*call), IL_GET_SERVICE(*call), 1912 IPC_GET_PHONE(*call), NULL); 1909 1913 1910 1914 case NET_IL_DEVICE: 1911 return ip_device_req_local(0, IPC_GET_DEVICE( call),1912 IPC_GET_SERVICE( call));1915 return ip_device_req_local(0, IPC_GET_DEVICE(*call), 1916 IPC_GET_SERVICE(*call)); 1913 1917 1914 1918 case NET_IL_SEND: 1915 1919 rc = packet_translate_remote(ip_globals.net_phone, &packet, 1916 IPC_GET_PACKET( call));1920 IPC_GET_PACKET(*call)); 1917 1921 if (rc != EOK) 1918 1922 return rc; 1919 return ip_send_msg_local(0, IPC_GET_DEVICE( call), packet, 0,1920 IPC_GET_ERROR( call));1923 return ip_send_msg_local(0, IPC_GET_DEVICE(*call), packet, 0, 1924 IPC_GET_ERROR(*call)); 1921 1925 1922 1926 case NET_IL_DEVICE_STATE: 1923 return ip_device_state_message(IPC_GET_DEVICE( call),1924 IPC_GET_STATE( call));1927 return ip_device_state_message(IPC_GET_DEVICE(*call), 1928 IPC_GET_STATE(*call)); 1925 1929 1926 1930 case NET_IL_RECEIVED: 1927 1931 rc = packet_translate_remote(ip_globals.net_phone, &packet, 1928 IPC_GET_PACKET( call));1932 IPC_GET_PACKET(*call)); 1929 1933 if (rc != EOK) 1930 1934 return rc; 1931 return ip_receive_message(IPC_GET_DEVICE( call), packet);1935 return ip_receive_message(IPC_GET_DEVICE(*call), packet); 1932 1936 1933 1937 case NET_IP_RECEIVED_ERROR: 1934 1938 rc = packet_translate_remote(ip_globals.net_phone, &packet, 1935 IPC_GET_PACKET( call));1939 IPC_GET_PACKET(*call)); 1936 1940 if (rc != EOK) 1937 1941 return rc; 1938 return ip_received_error_msg_local(0, IPC_GET_DEVICE( call),1939 packet, IPC_GET_TARGET( call), IPC_GET_ERROR(call));1942 return ip_received_error_msg_local(0, IPC_GET_DEVICE(*call), 1943 packet, IPC_GET_TARGET(*call), IPC_GET_ERROR(*call)); 1940 1944 1941 1945 case NET_IP_ADD_ROUTE: 1942 return ip_add_route_req_local(0, IPC_GET_DEVICE( call),1943 IP_GET_ADDRESS( call), IP_GET_NETMASK(call),1944 IP_GET_GATEWAY( call));1946 return ip_add_route_req_local(0, IPC_GET_DEVICE(*call), 1947 IP_GET_ADDRESS(*call), IP_GET_NETMASK(*call), 1948 IP_GET_GATEWAY(*call)); 1945 1949 1946 1950 case NET_IP_SET_GATEWAY: 1947 return ip_set_gateway_req_local(0, IPC_GET_DEVICE( call),1948 IP_GET_GATEWAY( call));1951 return ip_set_gateway_req_local(0, IPC_GET_DEVICE(*call), 1952 IP_GET_GATEWAY(*call)); 1949 1953 1950 1954 case NET_IP_GET_ROUTE: … … 1954 1958 return rc; 1955 1959 1956 rc = ip_get_route_req_local(0, IP_GET_PROTOCOL( call), addr,1960 rc = ip_get_route_req_local(0, IP_GET_PROTOCOL(*call), addr, 1957 1961 (socklen_t) addrlen, &device_id, &header, &headerlen); 1958 1962 if (rc != EOK) 1959 1963 return rc; 1960 1964 1961 IPC_SET_DEVICE( answer, device_id);1962 IP_SET_HEADERLEN( answer, headerlen);1965 IPC_SET_DEVICE(*answer, device_id); 1966 IP_SET_HEADERLEN(*answer, headerlen); 1963 1967 1964 1968 *answer_count = 2; … … 1972 1976 1973 1977 case NET_IL_PACKET_SPACE: 1974 rc = ip_packet_size_message(IPC_GET_DEVICE( call), &addrlen,1978 rc = ip_packet_size_message(IPC_GET_DEVICE(*call), &addrlen, 1975 1979 &prefix, &content, &suffix); 1976 1980 if (rc != EOK) 1977 1981 return rc; 1978 1982 1979 IPC_SET_ADDR( answer, addrlen);1980 IPC_SET_PREFIX( answer, prefix);1981 IPC_SET_CONTENT( answer, content);1982 IPC_SET_SUFFIX( answer, suffix);1983 IPC_SET_ADDR(*answer, addrlen); 1984 IPC_SET_PREFIX(*answer, prefix); 1985 IPC_SET_CONTENT(*answer, content); 1986 IPC_SET_SUFFIX(*answer, suffix); 1983 1987 *answer_count = 4; 1984 1988 return EOK; 1985 1989 1986 1990 case NET_IL_MTU_CHANGED: 1987 return ip_mtu_changed_message(IPC_GET_DEVICE( call),1988 IPC_GET_MTU( call));1991 return ip_mtu_changed_message(IPC_GET_DEVICE(*call), 1992 IPC_GET_MTU(*call)); 1989 1993 } 1990 1994 … … 2007 2011 while (true) { 2008 2012 ipc_call_t answer; 2009 int answer_count;2013 size_t count; 2010 2014 2011 2015 /* Clear the answer structure */ 2012 refresh_answer(&answer, & answer_count);2016 refresh_answer(&answer, &count); 2013 2017 2014 2018 /* Fetch the next message */ … … 2018 2022 /* Process the message */ 2019 2023 int res = il_module_message_standalone(callid, &call, &answer, 2020 & answer_count);2024 &count); 2021 2025 2022 2026 /* … … 2030 2034 2031 2035 /* Answer the message */ 2032 answer_call(callid, res, &answer, answer_count);2036 answer_call(callid, res, &answer, count); 2033 2037 } 2034 2038 } -
uspace/srv/net/il/ip/ip_module.c
r3c106e88 r774e6d1a 59 59 int 60 60 il_module_message_standalone(ipc_callid_t callid, ipc_call_t *call, 61 ipc_call_t *answer, int *answer_count)61 ipc_call_t *answer, size_t *count) 62 62 { 63 return ip_message_standalone(callid, call, answer, answer_count);63 return ip_message_standalone(callid, call, answer, count); 64 64 } 65 65 -
uspace/srv/net/il/ip/ip_module.h
r3c106e88 r774e6d1a 43 43 extern int ip_initialize(async_client_conn_t); 44 44 extern int ip_message_standalone(ipc_callid_t, ipc_call_t *, ipc_call_t *, 45 int *);45 size_t *); 46 46 47 47 #endif -
uspace/srv/net/net/net.c
r3c106e88 r774e6d1a 474 474 475 475 setting = measured_strings_find(&netif->configuration, (uint8_t *) CONF_IO, 0); 476 int io = setting ? strtol((char *) setting->value, NULL, 16) : 0;477 478 rc = netif_probe_req _remote(netif->driver->phone, netif->id, irq,io);476 uintptr_t io = setting ? strtol((char *) setting->value, NULL, 16) : 0; 477 478 rc = netif_probe_req(netif->driver->phone, netif->id, irq, (void *) io); 479 479 if (rc != EOK) 480 480 return rc; … … 511 511 } 512 512 513 return netif_start_req _remote(netif->driver->phone, netif->id);513 return netif_start_req(netif->driver->phone, netif->id); 514 514 } 515 515 … … 613 613 /** Process the networking message. 614 614 * 615 * @param[in] callidThe message identifier.616 * @param[in] callThe message parameters.615 * @param[in] callid The message identifier. 616 * @param[in] call The message parameters. 617 617 * @param[out] answer The message answer parameters. 618 618 * @param[out] answer_count The last parameter for the actual answer … … 627 627 */ 628 628 int net_message(ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, 629 int *answer_count)629 size_t *answer_count) 630 630 { 631 631 measured_string_t *strings; … … 639 639 case NET_NET_GET_DEVICE_CONF: 640 640 rc = measured_strings_receive(&strings, &data, 641 IPC_GET_COUNT( call));641 IPC_GET_COUNT(*call)); 642 642 if (rc != EOK) 643 643 return rc; 644 net_get_device_conf_req(0, IPC_GET_DEVICE( call), &strings,645 IPC_GET_COUNT( call), NULL);644 net_get_device_conf_req(0, IPC_GET_DEVICE(*call), &strings, 645 IPC_GET_COUNT(*call), NULL); 646 646 647 647 /* Strings should not contain received data anymore */ 648 648 free(data); 649 649 650 rc = measured_strings_reply(strings, IPC_GET_COUNT( call));650 rc = measured_strings_reply(strings, IPC_GET_COUNT(*call)); 651 651 free(strings); 652 652 return rc; 653 653 case NET_NET_GET_CONF: 654 654 rc = measured_strings_receive(&strings, &data, 655 IPC_GET_COUNT( call));655 IPC_GET_COUNT(*call)); 656 656 if (rc != EOK) 657 657 return rc; 658 net_get_conf_req(0, &strings, IPC_GET_COUNT( call), NULL);658 net_get_conf_req(0, &strings, IPC_GET_COUNT(*call), NULL); 659 659 660 660 /* Strings should not contain received data anymore */ 661 661 free(data); 662 662 663 rc = measured_strings_reply(strings, IPC_GET_COUNT( call));663 rc = measured_strings_reply(strings, IPC_GET_COUNT(*call)); 664 664 free(strings); 665 665 return rc; … … 688 688 /* Clear the answer structure */ 689 689 ipc_call_t answer; 690 int answer_count;690 size_t answer_count; 691 691 refresh_answer(&answer, &answer_count); 692 692 -
uspace/srv/net/net/net.h
r3c106e88 r774e6d1a 135 135 extern int add_configuration(measured_strings_t *, const uint8_t *, 136 136 const uint8_t *); 137 extern int net_module_message(ipc_callid_t, ipc_call_t *, ipc_call_t *, int *);137 extern int net_module_message(ipc_callid_t, ipc_call_t *, ipc_call_t *, size_t *); 138 138 extern int net_initialize_build(async_client_conn_t); 139 extern int net_message(ipc_callid_t, ipc_call_t *, ipc_call_t *, int *);139 extern int net_message(ipc_callid_t, ipc_call_t *, ipc_call_t *, size_t *); 140 140 141 141 #endif -
uspace/srv/net/net/net_standalone.c
r3c106e88 r774e6d1a 100 100 */ 101 101 int net_module_message(ipc_callid_t callid, ipc_call_t *call, 102 ipc_call_t *answer, int *answer_count)102 ipc_call_t *answer, size_t *count) 103 103 { 104 if (IS_NET_PACKET_MESSAGE( call))105 return packet_server_message(callid, call, answer, answer_count);104 if (IS_NET_PACKET_MESSAGE(*call)) 105 return packet_server_message(callid, call, answer, count); 106 106 107 return net_message(callid, call, answer, answer_count);107 return net_message(callid, call, answer, count); 108 108 } 109 109 -
uspace/srv/net/netif/lo/lo.c
r3c106e88 r774e6d1a 49 49 #include <net/device.h> 50 50 #include <nil_interface.h> 51 #include <netif_interface.h> 52 #include <netif_local.h> 51 #include <netif_skel.h> 53 52 54 53 /** Default hardware address. */ … … 65 64 66 65 int netif_specific_message(ipc_callid_t callid, ipc_call_t *call, 67 ipc_call_t *answer, int *answer_count)66 ipc_call_t *answer, size_t *count) 68 67 { 69 68 return ENOTSUP; … … 172 171 } 173 172 174 int netif_probe_message(device_id_t device_id, int irq, uintptr_tio)173 int netif_probe_message(device_id_t device_id, int irq, void *io) 175 174 { 176 175 netif_device_t *device; … … 233 232 } 234 233 235 /** Default thread for new connections.236 *237 * @param[in] iid The initial message identifier.238 * @param[in] icall The initial message call structure.239 */240 static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall)241 {242 /*243 * Accept the connection244 * - Answer the first IPC_M_CONNECT_ME_TO call.245 */246 ipc_answer_0(iid, EOK);247 248 while (true) {249 ipc_call_t answer;250 int answer_count;251 252 /* Clear the answer structure */253 refresh_answer(&answer, &answer_count);254 255 /* Fetch the next message */256 ipc_call_t call;257 ipc_callid_t callid = async_get_call(&call);258 259 /* Process the message */260 int res = netif_module_message(NAME, callid, &call, &answer,261 &answer_count);262 263 /*264 * End if told to either by the message or the processing265 * result.266 */267 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||268 (res == EHANGUP))269 return;270 271 /* Answer the message */272 answer_call(callid, res, &answer, answer_count);273 }274 }275 276 234 int main(int argc, char *argv[]) 277 235 { 278 int rc;279 280 236 /* Start the module */ 281 rc = netif_module_start(netif_client_connection); 282 return rc; 237 return netif_module_start(); 283 238 } 284 239 -
uspace/srv/net/nil/eth/eth.c
r3c106e88 r774e6d1a 54 54 #include <protocol_map.h> 55 55 #include <net/device.h> 56 #include <netif_ interface.h>56 #include <netif_remote.h> 57 57 #include <net_interface.h> 58 58 #include <nil_interface.h> … … 239 239 switch (IPC_GET_IMETHOD(*icall)) { 240 240 case NET_NIL_DEVICE_STATE: 241 nil_device_state_msg_local(0, IPC_GET_DEVICE( icall),242 IPC_GET_STATE( icall));241 nil_device_state_msg_local(0, IPC_GET_DEVICE(*icall), 242 IPC_GET_STATE(*icall)); 243 243 ipc_answer_0(iid, EOK); 244 244 break; 245 245 case NET_NIL_RECEIVED: 246 246 rc = packet_translate_remote(eth_globals.net_phone, 247 &packet, IPC_GET_PACKET( icall));247 &packet, IPC_GET_PACKET(*icall)); 248 248 if (rc == EOK) { 249 249 rc = nil_received_msg_local(0, 250 IPC_GET_DEVICE( icall), packet, 0);250 IPC_GET_DEVICE(*icall), packet, 0); 251 251 } 252 252 ipc_answer_0(iid, (sysarg_t) rc); … … 837 837 838 838 int nil_message_standalone(const char *name, ipc_callid_t callid, 839 ipc_call_t *call, ipc_call_t *answer, int *answer_count)839 ipc_call_t *call, ipc_call_t *answer, size_t *answer_count) 840 840 { 841 841 measured_string_t *address; … … 853 853 854 854 case NET_NIL_DEVICE: 855 return eth_device_message(IPC_GET_DEVICE( call),856 IPC_GET_SERVICE( call), IPC_GET_MTU(call));855 return eth_device_message(IPC_GET_DEVICE(*call), 856 IPC_GET_SERVICE(*call), IPC_GET_MTU(*call)); 857 857 case NET_NIL_SEND: 858 858 rc = packet_translate_remote(eth_globals.net_phone, &packet, 859 IPC_GET_PACKET( call));859 IPC_GET_PACKET(*call)); 860 860 if (rc != EOK) 861 861 return rc; 862 return eth_send_message(IPC_GET_DEVICE( call), packet,863 IPC_GET_SERVICE( call));862 return eth_send_message(IPC_GET_DEVICE(*call), packet, 863 IPC_GET_SERVICE(*call)); 864 864 case NET_NIL_PACKET_SPACE: 865 rc = eth_packet_space_message(IPC_GET_DEVICE( call), &addrlen,865 rc = eth_packet_space_message(IPC_GET_DEVICE(*call), &addrlen, 866 866 &prefix, &content, &suffix); 867 867 if (rc != EOK) 868 868 return rc; 869 IPC_SET_ADDR( answer, addrlen);870 IPC_SET_PREFIX( answer, prefix);871 IPC_SET_CONTENT( answer, content);872 IPC_SET_SUFFIX( answer, suffix);869 IPC_SET_ADDR(*answer, addrlen); 870 IPC_SET_PREFIX(*answer, prefix); 871 IPC_SET_CONTENT(*answer, content); 872 IPC_SET_SUFFIX(*answer, suffix); 873 873 *answer_count = 4; 874 874 return EOK; 875 875 case NET_NIL_ADDR: 876 rc = eth_addr_message(IPC_GET_DEVICE( call), ETH_LOCAL_ADDR,876 rc = eth_addr_message(IPC_GET_DEVICE(*call), ETH_LOCAL_ADDR, 877 877 &address); 878 878 if (rc != EOK) … … 880 880 return measured_strings_reply(address, 1); 881 881 case NET_NIL_BROADCAST_ADDR: 882 rc = eth_addr_message(IPC_GET_DEVICE( call), ETH_BROADCAST_ADDR,882 rc = eth_addr_message(IPC_GET_DEVICE(*call), ETH_BROADCAST_ADDR, 883 883 &address); 884 884 if (rc != EOK) … … 886 886 return measured_strings_reply(address, 1); 887 887 case IPC_M_CONNECT_TO_ME: 888 return eth_register_message(NIL_GET_PROTO( call),889 IPC_GET_PHONE( call));888 return eth_register_message(NIL_GET_PROTO(*call), 889 IPC_GET_PHONE(*call)); 890 890 } 891 891 … … 908 908 while (true) { 909 909 ipc_call_t answer; 910 int answer_count;910 size_t count; 911 911 912 912 /* Clear the answer structure */ 913 refresh_answer(&answer, & answer_count);913 refresh_answer(&answer, &count); 914 914 915 915 /* Fetch the next message */ … … 919 919 /* Process the message */ 920 920 int res = nil_module_message_standalone(NAME, callid, &call, 921 &answer, & answer_count);921 &answer, &count); 922 922 923 923 /* … … 930 930 931 931 /* Answer the message */ 932 answer_call(callid, res, &answer, answer_count);932 answer_call(callid, res, &answer, count); 933 933 } 934 934 } -
uspace/srv/net/nil/eth/eth_header.h
r3c106e88 r774e6d1a 42 42 43 43 /** Ethernet address length. */ 44 #define ETH_ADDR 44 #define ETH_ADDR 6 45 45 46 46 /** Ethernet header preamble value. */ 47 #define ETH_PREAMBLE 47 #define ETH_PREAMBLE 0x55 48 48 49 49 /** Ethernet header start of frame value. */ 50 #define ETH_SFD 50 #define ETH_SFD 0xD5 51 51 52 52 /** IEEE 802.2 unordered information control field. */ 53 #define IEEE_8023_2_UI 53 #define IEEE_8023_2_UI 0x03 54 54 55 55 /** Type definition of the Ethernet header IEEE 802.3 + 802.2 + SNAP extensions. -
uspace/srv/net/nil/eth/eth_module.c
r3c106e88 r774e6d1a 78 78 79 79 int nil_module_message_standalone(const char *name, ipc_callid_t callid, 80 ipc_call_t *call, ipc_call_t *answer, int *answer_count)80 ipc_call_t *call, ipc_call_t *answer, size_t *count) 81 81 { 82 return nil_message_standalone(name, callid, call, answer, answer_count);82 return nil_message_standalone(name, callid, call, answer, count); 83 83 } 84 84 -
uspace/srv/net/nil/nildummy/nildummy.c
r3c106e88 r774e6d1a 47 47 #include <net/modules.h> 48 48 #include <net/device.h> 49 #include <netif_interface.h>50 49 #include <nil_interface.h> 51 50 #include <il_interface.h> … … 53 52 #include <net/packet.h> 54 53 #include <packet_remote.h> 54 #include <netif_remote.h> 55 55 #include <nil_local.h> 56 56 … … 113 113 case NET_NIL_DEVICE_STATE: 114 114 rc = nil_device_state_msg_local(0, 115 IPC_GET_DEVICE( icall), IPC_GET_STATE(icall));115 IPC_GET_DEVICE(*icall), IPC_GET_STATE(*icall)); 116 116 ipc_answer_0(iid, (sysarg_t) rc); 117 117 break; … … 119 119 case NET_NIL_RECEIVED: 120 120 rc = packet_translate_remote(nildummy_globals.net_phone, 121 &packet, IPC_GET_PACKET( icall));121 &packet, IPC_GET_PACKET(*icall)); 122 122 if (rc == EOK) { 123 123 rc = nil_received_msg_local(0, 124 IPC_GET_DEVICE( icall), packet, 0);124 IPC_GET_DEVICE(*icall), packet, 0); 125 125 } 126 126 ipc_answer_0(iid, (sysarg_t) rc); … … 375 375 376 376 int nil_message_standalone(const char *name, ipc_callid_t callid, 377 ipc_call_t *call, ipc_call_t *answer, int *answer_count)377 ipc_call_t *call, ipc_call_t *answer, size_t *answer_count) 378 378 { 379 379 measured_string_t *address; … … 391 391 392 392 case NET_NIL_DEVICE: 393 return nildummy_device_message(IPC_GET_DEVICE( call),394 IPC_GET_SERVICE( call), IPC_GET_MTU(call));393 return nildummy_device_message(IPC_GET_DEVICE(*call), 394 IPC_GET_SERVICE(*call), IPC_GET_MTU(*call)); 395 395 396 396 case NET_NIL_SEND: 397 397 rc = packet_translate_remote(nildummy_globals.net_phone, 398 &packet, IPC_GET_PACKET( call));398 &packet, IPC_GET_PACKET(*call)); 399 399 if (rc != EOK) 400 400 return rc; 401 return nildummy_send_message(IPC_GET_DEVICE( call), packet,402 IPC_GET_SERVICE( call));401 return nildummy_send_message(IPC_GET_DEVICE(*call), packet, 402 IPC_GET_SERVICE(*call)); 403 403 404 404 case NET_NIL_PACKET_SPACE: 405 rc = nildummy_packet_space_message(IPC_GET_DEVICE( call),405 rc = nildummy_packet_space_message(IPC_GET_DEVICE(*call), 406 406 &addrlen, &prefix, &content, &suffix); 407 407 if (rc != EOK) 408 408 return rc; 409 IPC_SET_ADDR( answer, addrlen);410 IPC_SET_PREFIX( answer, prefix);411 IPC_SET_CONTENT( answer, content);412 IPC_SET_SUFFIX( answer, suffix);409 IPC_SET_ADDR(*answer, addrlen); 410 IPC_SET_PREFIX(*answer, prefix); 411 IPC_SET_CONTENT(*answer, content); 412 IPC_SET_SUFFIX(*answer, suffix); 413 413 *answer_count = 4; 414 414 return EOK; 415 415 416 416 case NET_NIL_ADDR: 417 rc = nildummy_addr_message(IPC_GET_DEVICE( call), &address);417 rc = nildummy_addr_message(IPC_GET_DEVICE(*call), &address); 418 418 if (rc != EOK) 419 419 return rc; … … 421 421 422 422 case NET_NIL_BROADCAST_ADDR: 423 rc = nildummy_addr_message(IPC_GET_DEVICE( call), &address);423 rc = nildummy_addr_message(IPC_GET_DEVICE(*call), &address); 424 424 if (rc != EOK) 425 425 return rc; … … 427 427 428 428 case IPC_M_CONNECT_TO_ME: 429 return nildummy_register_message(NIL_GET_PROTO( call),430 IPC_GET_PHONE( call));429 return nildummy_register_message(NIL_GET_PROTO(*call), 430 IPC_GET_PHONE(*call)); 431 431 } 432 432 … … 449 449 while (true) { 450 450 ipc_call_t answer; 451 int answer_count;451 size_t count; 452 452 453 453 /* Clear the answer structure */ 454 refresh_answer(&answer, & answer_count);454 refresh_answer(&answer, &count); 455 455 456 456 /* Fetch the next message */ … … 460 460 /* Process the message */ 461 461 int res = nil_module_message_standalone(NAME, callid, &call, 462 &answer, & answer_count);462 &answer, &count); 463 463 464 464 /* … … 471 471 472 472 /* Answer the message */ 473 answer_call(callid, res, &answer, answer_count);473 answer_call(callid, res, &answer, count); 474 474 } 475 475 } -
uspace/srv/net/nil/nildummy/nildummy_module.c
r3c106e88 r774e6d1a 79 79 80 80 int nil_module_message_standalone(const char *name, ipc_callid_t callid, 81 ipc_call_t *call, ipc_call_t *answer, int *answer_count)81 ipc_call_t *call, ipc_call_t *answer, size_t *count) 82 82 { 83 return nil_message_standalone(name, callid, call, answer, answer_count);83 return nil_message_standalone(name, callid, call, answer, count); 84 84 } 85 85 -
uspace/srv/net/tl/icmp/icmp.c
r3c106e88 r774e6d1a 696 696 case NET_ICMP_DEST_UNREACH: 697 697 rc = packet_translate_remote(icmp_globals.net_phone, &packet, 698 IPC_GET_PACKET( call));698 IPC_GET_PACKET(*call)); 699 699 if (rc != EOK) 700 700 return rc; 701 701 return icmp_destination_unreachable_msg_local(0, 702 ICMP_GET_CODE( call), ICMP_GET_MTU(call), packet);702 ICMP_GET_CODE(*call), ICMP_GET_MTU(*call), packet); 703 703 case NET_ICMP_SOURCE_QUENCH: 704 704 rc = packet_translate_remote(icmp_globals.net_phone, &packet, 705 IPC_GET_PACKET( call));705 IPC_GET_PACKET(*call)); 706 706 if (rc != EOK) 707 707 return rc; … … 709 709 case NET_ICMP_TIME_EXCEEDED: 710 710 rc = packet_translate_remote(icmp_globals.net_phone, &packet, 711 IPC_GET_PACKET( call));711 IPC_GET_PACKET(*call)); 712 712 if (rc != EOK) 713 713 return rc; 714 return icmp_time_exceeded_msg_local(0, ICMP_GET_CODE( call),714 return icmp_time_exceeded_msg_local(0, ICMP_GET_CODE(*call), 715 715 packet); 716 716 case NET_ICMP_PARAMETERPROB: 717 717 rc = packet_translate_remote(icmp_globals.net_phone, &packet, 718 IPC_GET_PACKET( call));718 IPC_GET_PACKET(*call)); 719 719 if (rc != EOK) 720 720 return rc; 721 return icmp_parameter_problem_msg_local(0, ICMP_GET_CODE( call),722 ICMP_GET_POINTER( call), packet);721 return icmp_parameter_problem_msg_local(0, ICMP_GET_CODE(*call), 722 ICMP_GET_POINTER(*call), packet); 723 723 default: 724 724 return ENOTSUP; … … 787 787 bool keep_on_going = true; 788 788 ipc_call_t answer; 789 int answer_count;789 size_t answer_count; 790 790 size_t length; 791 791 struct sockaddr *addr; … … 894 894 */ 895 895 int icmp_message_standalone(ipc_callid_t callid, ipc_call_t *call, 896 ipc_call_t *answer, int *answer_count)896 ipc_call_t *answer, size_t *answer_count) 897 897 { 898 898 packet_t *packet; … … 903 903 case NET_TL_RECEIVED: 904 904 rc = packet_translate_remote(icmp_globals.net_phone, &packet, 905 IPC_GET_PACKET( call));905 IPC_GET_PACKET(*call)); 906 906 if (rc != EOK) 907 907 return rc; 908 return icmp_received_msg_local(IPC_GET_DEVICE( call), packet,909 SERVICE_ICMP, IPC_GET_ERROR( call));908 return icmp_received_msg_local(IPC_GET_DEVICE(*call), packet, 909 SERVICE_ICMP, IPC_GET_ERROR(*call)); 910 910 911 911 case NET_ICMP_INIT: 912 return icmp_process_client_messages(callid, * 912 return icmp_process_client_messages(callid, *call); 913 913 914 914 default: … … 936 936 while (true) { 937 937 ipc_call_t answer; 938 int answer_count;938 size_t answer_count; 939 939 940 940 /* Clear the answer structure */ -
uspace/srv/net/tl/icmp/icmp_module.c
r3c106e88 r774e6d1a 86 86 87 87 int tl_module_message_standalone(ipc_callid_t callid, ipc_call_t *call, 88 ipc_call_t *answer, int *answer_count)88 ipc_call_t *answer, size_t *count) 89 89 { 90 return icmp_message_standalone(callid, call, answer, answer_count);90 return icmp_message_standalone(callid, call, answer, count); 91 91 } 92 92 -
uspace/srv/net/tl/icmp/icmp_module.h
r3c106e88 r774e6d1a 44 44 extern int icmp_initialize(async_client_conn_t); 45 45 extern int icmp_message_standalone(ipc_callid_t, ipc_call_t *, ipc_call_t *, 46 int *);46 size_t *); 47 47 48 48 #endif -
uspace/srv/net/tl/tcp/tcp.c
r3c106e88 r774e6d1a 1262 1262 int 1263 1263 tcp_message_standalone(ipc_callid_t callid, ipc_call_t *call, 1264 ipc_call_t *answer, int *answer_count)1264 ipc_call_t *answer, size_t *answer_count) 1265 1265 { 1266 1266 packet_t *packet; … … 1276 1276 // fibril_rwlock_read_lock(&tcp_globals.lock); 1277 1277 rc = packet_translate_remote(tcp_globals.net_phone, &packet, 1278 IPC_GET_PACKET( call));1278 IPC_GET_PACKET(*call)); 1279 1279 if (rc != EOK) { 1280 1280 // fibril_rwlock_read_unlock(&tcp_globals.lock); 1281 1281 return rc; 1282 1282 } 1283 rc = tcp_received_msg(IPC_GET_DEVICE( call), packet, SERVICE_TCP,1284 IPC_GET_ERROR( call));1283 rc = tcp_received_msg(IPC_GET_DEVICE(*call), packet, SERVICE_TCP, 1284 IPC_GET_ERROR(*call)); 1285 1285 // fibril_rwlock_read_unlock(&tcp_globals.lock); 1286 1286 return rc; … … 1323 1323 bool keep_on_going = true; 1324 1324 socket_cores_t local_sockets; 1325 int app_phone = IPC_GET_PHONE( &call);1325 int app_phone = IPC_GET_PHONE(call); 1326 1326 struct sockaddr *addr; 1327 1327 int socket_id; … … 1330 1330 fibril_rwlock_t lock; 1331 1331 ipc_call_t answer; 1332 int answer_count;1332 size_t answer_count; 1333 1333 tcp_socket_data_t *socket_data; 1334 1334 socket_core_t *socket; … … 2502 2502 while (true) { 2503 2503 ipc_call_t answer; 2504 int answer_count;2504 size_t answer_count; 2505 2505 2506 2506 /* Clear the answer structure */ -
uspace/srv/net/tl/tcp/tcp_module.c
r3c106e88 r774e6d1a 87 87 88 88 int tl_module_message_standalone(ipc_callid_t callid, ipc_call_t *call, 89 ipc_call_t *answer, int *answer_count)89 ipc_call_t *answer, size_t *count) 90 90 { 91 return tcp_message_standalone(callid, call, answer, answer_count);91 return tcp_message_standalone(callid, call, answer, count); 92 92 } 93 93 -
uspace/srv/net/tl/tcp/tcp_module.h
r3c106e88 r774e6d1a 44 44 extern int tcp_initialize(async_client_conn_t); 45 45 extern int tcp_message_standalone(ipc_callid_t, ipc_call_t *, ipc_call_t *, 46 int *);46 size_t *); 47 47 48 48 #endif -
uspace/srv/net/tl/udp/udp.c
r3c106e88 r774e6d1a 707 707 bool keep_on_going = true; 708 708 socket_cores_t local_sockets; 709 int app_phone = IPC_GET_PHONE( &call);709 int app_phone = IPC_GET_PHONE(call); 710 710 struct sockaddr *addr; 711 711 int socket_id; … … 713 713 size_t size; 714 714 ipc_call_t answer; 715 int answer_count;715 size_t answer_count; 716 716 packet_dimension_t *packet_dimension; 717 717 … … 861 861 */ 862 862 int udp_message_standalone(ipc_callid_t callid, ipc_call_t *call, 863 ipc_call_t *answer, int *answer_count)863 ipc_call_t *answer, size_t *answer_count) 864 864 { 865 865 packet_t *packet; … … 871 871 case NET_TL_RECEIVED: 872 872 rc = packet_translate_remote(udp_globals.net_phone, &packet, 873 IPC_GET_PACKET( call));873 IPC_GET_PACKET(*call)); 874 874 if (rc != EOK) 875 875 return rc; 876 return udp_received_msg(IPC_GET_DEVICE( call), packet,877 SERVICE_UDP, IPC_GET_ERROR( call));876 return udp_received_msg(IPC_GET_DEVICE(*call), packet, 877 SERVICE_UDP, IPC_GET_ERROR(*call)); 878 878 case IPC_M_CONNECT_TO_ME: 879 return udp_process_client_messages(callid, * 879 return udp_process_client_messages(callid, *call); 880 880 } 881 881 … … 898 898 while (true) { 899 899 ipc_call_t answer; 900 int answer_count;900 size_t answer_count; 901 901 902 902 /* Clear the answer structure */ -
uspace/srv/net/tl/udp/udp_module.c
r3c106e88 r774e6d1a 87 87 88 88 int tl_module_message_standalone(ipc_callid_t callid, ipc_call_t *call, 89 ipc_call_t *answer, int *answer_count)89 ipc_call_t *answer, size_t *count) 90 90 { 91 return udp_message_standalone(callid, call, answer, answer_count);91 return udp_message_standalone(callid, call, answer, count); 92 92 } 93 93 -
uspace/srv/net/tl/udp/udp_module.h
r3c106e88 r774e6d1a 44 44 extern int udp_initialize(async_client_conn_t); 45 45 extern int udp_message_standalone(ipc_callid_t, ipc_call_t *, ipc_call_t *, 46 int *);46 size_t *); 47 47 48 48 #endif
Note:
See TracChangeset
for help on using the changeset viewer.