Changeset 14f1db0 in mainline for uspace/srv
- Timestamp:
- 2010-04-09T12:54:57Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a1caa3c2
- Parents:
- 24ab58b3
- Location:
- uspace/srv
- Files:
-
- 1 deleted
- 30 edited
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/netif/dp8390/Makefile
r24ab58b3 r14f1db0 39 39 -include $(CONFIG_MAKEFILE) 40 40 41 ifeq ($(CONFIG_NET WORKING),modular)42 BINARY = dp839041 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y) 42 LIBS += $(USPACE_PREFIX)/srv/net/nil/eth/libeth.a 43 43 endif 44 44 45 ifeq ($(CONFIG_NETWORKING),module) 46 LIBRARY = libdp8390 47 endif 45 BINARY = dp8390 48 46 49 47 SOURCES = \ -
uspace/srv/hw/netif/dp8390/dp8390.c
r24ab58b3 r14f1db0 37 37 38 38 #include <net_byteorder.h> 39 39 #include <netif_local.h> 40 40 #include <packet/packet.h> 41 41 #include <packet/packet_client.h> 42 43 #include <netif.h>44 42 45 43 #include "dp8390_drv.h" -
uspace/srv/hw/netif/dp8390/dp8390_module.c
r24ab58b3 r14f1db0 50 50 #include <net_device.h> 51 51 #include <nil_interface.h> 52 #include <netif .h>53 #include <netif_ module.h>52 #include <netif_interface.h> 53 #include <netif_local.h> 54 54 55 55 #include "dp8390.h" … … 95 95 }; 96 96 97 /** Network interface module global data.98 */99 netif_globals_t netif_globals;100 101 97 /** Handles the interrupt messages. 102 98 * This is the interrupt handler callback function. … … 104 100 * @param[in] call The interrupt message. 105 101 */ 106 void irq_handler(ipc_callid_t iid, ipc_call_t * call); 107 108 /** Changes the network interface state. 109 * @param[in,out] device The network interface. 110 * @param[in] state The new state. 111 * @returns The new state. 112 */ 113 int change_state(device_ref device, device_state_t state); 114 115 int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 116 return ENOTSUP; 117 } 118 119 int netif_get_device_stats(device_id_t device_id, device_stats_ref stats){ 120 ERROR_DECLARE; 121 122 device_ref device; 123 eth_stat_t * de_stat; 124 125 if(! stats){ 126 return EBADMEM; 127 } 128 ERROR_PROPAGATE(find_device(device_id, &device)); 129 de_stat = &((dpeth_t *) device->specific)->de_stat; 130 null_device_stats(stats); 131 stats->receive_errors = de_stat->ets_recvErr; 132 stats->send_errors = de_stat->ets_sendErr; 133 stats->receive_crc_errors = de_stat->ets_CRCerr; 134 stats->receive_frame_errors = de_stat->ets_frameAll; 135 stats->receive_missed_errors = de_stat->ets_missedP; 136 stats->receive_packets = de_stat->ets_packetR; 137 stats->send_packets = de_stat->ets_packetT; 138 stats->collisions = de_stat->ets_collision; 139 stats->send_aborted_errors = de_stat->ets_transAb; 140 stats->send_carrier_errors = de_stat->ets_carrSense; 141 stats->send_heartbeat_errors = de_stat->ets_CDheartbeat; 142 stats->send_window_errors = de_stat->ets_OWC; 143 return EOK; 144 } 145 146 int netif_get_addr_message(device_id_t device_id, measured_string_ref address){ 147 ERROR_DECLARE; 148 149 device_ref device; 150 151 if(! address){ 152 return EBADMEM; 153 } 154 ERROR_PROPAGATE(find_device(device_id, &device)); 155 address->value = (char *) (&((dpeth_t *) device->specific)->de_address); 156 address->length = CONVERT_SIZE(ether_addr_t, char, 1); 157 return EOK; 158 } 159 160 void irq_handler(ipc_callid_t iid, ipc_call_t * call) 102 static void irq_handler(ipc_callid_t iid, ipc_call_t * call) 161 103 { 162 device_refdevice;104 netif_device_t * device; 163 105 dpeth_t * dep; 164 106 packet_t received; … … 203 145 } 204 146 147 /** Changes the network interface state. 148 * @param[in,out] device The network interface. 149 * @param[in] state The new state. 150 * @returns The new state. 151 */ 152 static int change_state(netif_device_t * device, device_state_t state) 153 { 154 if (device->state != state) { 155 device->state = state; 156 157 printf("%s: State changed to %s\n", NAME, 158 (state == NETIF_ACTIVE) ? "active" : "stopped"); 159 160 return state; 161 } 162 163 return EOK; 164 } 165 166 int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 167 return ENOTSUP; 168 } 169 170 int netif_get_device_stats(device_id_t device_id, device_stats_ref stats){ 171 ERROR_DECLARE; 172 173 netif_device_t * device; 174 eth_stat_t * de_stat; 175 176 if(! stats){ 177 return EBADMEM; 178 } 179 ERROR_PROPAGATE(find_device(device_id, &device)); 180 de_stat = &((dpeth_t *) device->specific)->de_stat; 181 null_device_stats(stats); 182 stats->receive_errors = de_stat->ets_recvErr; 183 stats->send_errors = de_stat->ets_sendErr; 184 stats->receive_crc_errors = de_stat->ets_CRCerr; 185 stats->receive_frame_errors = de_stat->ets_frameAll; 186 stats->receive_missed_errors = de_stat->ets_missedP; 187 stats->receive_packets = de_stat->ets_packetR; 188 stats->send_packets = de_stat->ets_packetT; 189 stats->collisions = de_stat->ets_collision; 190 stats->send_aborted_errors = de_stat->ets_transAb; 191 stats->send_carrier_errors = de_stat->ets_carrSense; 192 stats->send_heartbeat_errors = de_stat->ets_CDheartbeat; 193 stats->send_window_errors = de_stat->ets_OWC; 194 return EOK; 195 } 196 197 int netif_get_addr_message(device_id_t device_id, measured_string_ref address){ 198 ERROR_DECLARE; 199 200 netif_device_t * device; 201 202 if(! address){ 203 return EBADMEM; 204 } 205 ERROR_PROPAGATE(find_device(device_id, &device)); 206 address->value = (char *) (&((dpeth_t *) device->specific)->de_address); 207 address->length = CONVERT_SIZE(ether_addr_t, char, 1); 208 return EOK; 209 } 210 211 212 205 213 int netif_probe_message(device_id_t device_id, int irq, uintptr_t io){ 206 214 ERROR_DECLARE; 207 215 208 device_refdevice;209 dpeth_t * dep; 210 211 device = ( device_ref) malloc(sizeof(device_t));216 netif_device_t * device; 217 dpeth_t * dep; 218 219 device = (netif_device_t *) malloc(sizeof(netif_device_t)); 212 220 if(! device){ 213 221 return ENOMEM; … … 218 226 return ENOMEM; 219 227 } 220 bzero(device, sizeof( device_t));228 bzero(device, sizeof(netif_device_t)); 221 229 bzero(dep, sizeof(dpeth_t)); 222 230 device->device_id = device_id; … … 233 241 return ERROR_CODE; 234 242 } 235 if(ERROR_OCCURRED( device_map_add(&netif_globals.device_map, device->device_id, device))){243 if(ERROR_OCCURRED(netif_device_map_add(&netif_globals.device_map, device->device_id, device))){ 236 244 free(dep); 237 245 free(device); … … 244 252 ERROR_DECLARE; 245 253 246 device_refdevice;254 netif_device_t * device; 247 255 dpeth_t * dep; 248 256 packet_t next; … … 271 279 } 272 280 273 int netif_start_message( device_refdevice){281 int netif_start_message(netif_device_t * device){ 274 282 ERROR_DECLARE; 275 283 … … 290 298 } 291 299 292 int netif_stop_message( device_refdevice){300 int netif_stop_message(netif_device_t * device){ 293 301 dpeth_t * dep; 294 302 … … 302 310 } 303 311 304 int change_state(device_ref device, device_state_t state)305 {306 if (device->state != state) {307 device->state = state;308 309 printf("%s: State changed to %s\n", NAME,310 (state == NETIF_ACTIVE) ? "active" : "stopped");311 312 return state;313 }314 315 return EOK;316 }317 318 312 int netif_initialize(void){ 319 313 ipcarg_t phonehash; … … 323 317 return REGISTER_ME(SERVICE_DP8390, &phonehash); 324 318 } 325 326 #ifdef CONFIG_NETWORKING_modular327 328 #include <netif_standalone.h>329 319 330 320 /** Default thread for new connections. … … 386 376 } 387 377 388 #endif /* CONFIG_NETWORKING_modular */389 390 391 378 /** @} 392 379 */ -
uspace/srv/net/cfg/Makefile
r24ab58b3 r14f1db0 1 1 # 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar 2 # Copyright (c) 2010 Martin Decky 4 3 # All rights reserved. 5 4 # … … 28 27 # 29 28 30 USPACE_PREFIX = ../.. 31 EXTRA_CFLAGS = -Iinclude -I$(LIBNET_PREFIX)/include -I$(LIBSOCKET_PREFIX)/include 32 LIBRARY = libnetif 29 USPACE_PREFIX = ../../.. 30 ROOT_PATH = $(USPACE_PREFIX)/.. 33 31 34 SOURCES = \ 35 generic/netif_remote.c 32 COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common 33 CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config 36 34 37 include $(USPACE_PREFIX)/Makefile.common 35 -include $(COMMON_MAKEFILE) 36 -include $(CONFIG_MAKEFILE) 37 38 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y) 39 LO_SOURCE = lo.netif_nil_bundle 40 NE2K_SOURCE = ne2k.netif_nil_bundle 41 else 42 LO_SOURCE = lo.netif_standalone 43 NE2K_SOURCE = ne2k.netif_standalone 44 endif 45 46 LO_TARGET = lo 47 NE2K_TARGET = ne2k 48 49 .PHONY: all clean 50 51 all: $(LO_TARGET) $(NE2K_TARGET) 52 53 clean: 54 rm -f $(LO_TARGET) $(NE2K_TARGET) 55 56 $(LO_TARGET): $(LO_SOURCE) 57 cp $< $@ 58 59 $(NE2K_TARGET): $(NE2K_SOURCE) 60 cp $< $@ -
uspace/srv/net/il/arp/arp.c
r24ab58b3 r14f1db0 57 57 #include <packet/packet.h> 58 58 #include <packet/packet_client.h> 59 #include <packet_remote.h> 59 60 #include <il_messages.h> 61 #include <il_interface.h> 62 #include <il_local.h> 60 63 #include <arp_messages.h> 61 64 … … 370 373 } 371 374 372 int arp_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 375 int arp_message_standalone(ipc_callid_t callid, ipc_call_t *call, 376 ipc_call_t *answer, int *answer_count) 377 { 373 378 ERROR_DECLARE; 374 379 375 380 measured_string_ref address; 376 381 measured_string_ref translation; … … 378 383 packet_t packet; 379 384 packet_t next; 380 381 // printf("message %d - %d\n", IPC_GET_METHOD(*call), NET_ARP_FIRST); 385 382 386 *answer_count = 0; 383 switch (IPC_GET_METHOD(*call)){387 switch (IPC_GET_METHOD(*call)) { 384 388 case IPC_M_PHONE_HUNGUP: 385 389 return EOK; … … 418 422 return EOK; 419 423 case NET_IL_RECEIVED: 420 if(! ERROR_OCCURRED(packet_translate (arp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){424 if(! ERROR_OCCURRED(packet_translate_remote(arp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){ 421 425 fibril_rwlock_read_lock(&arp_globals.lock); 422 426 do{ … … 424 428 ERROR_CODE = arp_receive_message(IPC_GET_DEVICE(call), packet); 425 429 if(ERROR_CODE != 1){ 426 pq_release (arp_globals.net_phone, packet_get_id(packet));430 pq_release_remote(arp_globals.net_phone, packet_get_id(packet)); 427 431 } 428 432 packet = next; … … 434 438 return arp_mtu_changed_message(IPC_GET_DEVICE(call), IPC_GET_MTU(call)); 435 439 } 440 436 441 return ENOTSUP; 437 442 } … … 570 575 return NULL; 571 576 } 572 packet = packet_get_4 (arp_globals.net_phone, device->packet_dimension.addr_len, device->packet_dimension.prefix, length, device->packet_dimension.suffix);577 packet = packet_get_4_remote(arp_globals.net_phone, device->packet_dimension.addr_len, device->packet_dimension.prefix, length, device->packet_dimension.suffix); 573 578 if(! packet){ 574 579 return NULL; … … 576 581 header = (arp_header_ref) packet_suffix(packet, length); 577 582 if(! header){ 578 pq_release (arp_globals.net_phone, packet_get_id(packet));583 pq_release_remote(arp_globals.net_phone, packet_get_id(packet)); 579 584 return NULL; 580 585 } … … 593 598 memcpy(((uint8_t *) header) + length, target->value, target->length); 594 599 if(packet_set_addr(packet, (uint8_t *) device->addr->value, (uint8_t *) device->broadcast_addr->value, CONVERT_SIZE(char, uint8_t, device->addr->length)) != EOK){ 595 pq_release (arp_globals.net_phone, packet_get_id(packet));600 pq_release_remote(arp_globals.net_phone, packet_get_id(packet)); 596 601 return NULL; 597 602 } … … 619 624 } 620 625 } 621 622 #ifdef CONFIG_NETWORKING_modular623 624 #include <il_standalone.h>625 626 626 627 /** Default thread for new connections. … … 650 651 651 652 /* Process the message */ 652 int res = il_module_message(callid, &call, &answer, &answer_count); 653 int res = il_module_message_standalone(callid, &call, &answer, 654 &answer_count); 653 655 654 656 /* End if said to either by the message or the processing result */ … … 675 677 676 678 /* Start the module */ 677 if (ERROR_OCCURRED(il_module_start (il_client_connection)))679 if (ERROR_OCCURRED(il_module_start_standalone(il_client_connection))) 678 680 return ERROR_CODE; 679 681 … … 681 683 } 682 684 683 #endif /* CONFIG_NETWORKING_modular */684 685 685 /** @} 686 686 */ -
uspace/srv/net/il/arp/arp_module.c
r24ab58b3 r14f1db0 48 48 #include <net_interface.h> 49 49 #include <packet/packet.h> 50 #include <il_ standalone.h>50 #include <il_local.h> 51 51 52 52 #include "arp.h" … … 65 65 * @returns Other error codes as defined for the arp_message() function. 66 66 */ 67 int il_module_message (ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){68 return arp_message (callid, call, answer, answer_count);67 int il_module_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 68 return arp_message_standalone(callid, call, answer, answer_count); 69 69 } 70 70 … … 76 76 * @returns Other error codes as defined for the REGISTER_ME() macro function. 77 77 */ 78 int il_module_start (async_client_conn_t client_connection){78 int il_module_start_standalone(async_client_conn_t client_connection){ 79 79 ERROR_DECLARE; 80 81 ipcarg_t phonehash; 82 80 83 81 async_set_client_connection(client_connection); 84 82 arp_globals.net_phone = net_connect_module(SERVICE_NETWORKING); 85 83 ERROR_PROPAGATE(pm_init()); 86 if(ERROR_OCCURRED(arp_initialize(client_connection)) 87 || ERROR_OCCURRED(REGISTER_ME(SERVICE_ARP, &phonehash))){ 84 85 ipcarg_t phonehash; 86 if (ERROR_OCCURRED(arp_initialize(client_connection)) 87 || ERROR_OCCURRED(REGISTER_ME(SERVICE_ARP, &phonehash))) { 88 88 pm_destroy(); 89 89 return ERROR_CODE; 90 90 } 91 91 92 92 async_manager(); 93 93 94 94 pm_destroy(); 95 95 return EOK; -
uspace/srv/net/il/arp/arp_module.h
r24ab58b3 r14f1db0 58 58 * @see IS_NET_ARP_MESSAGE() 59 59 */ 60 int arp_message (ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);60 int arp_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count); 61 61 62 62 #endif -
uspace/srv/net/il/ip/ip.c
r24ab58b3 r14f1db0 69 69 #include <adt/module_map.h> 70 70 #include <packet/packet_client.h> 71 #include <packet_remote.h> 71 72 #include <nil_messages.h> 72 73 #include <il_messages.h> 74 #include <il_local.h> 75 #include <ip_local.h> 73 76 74 77 #include "ip.h" … … 424 427 } 425 428 426 int ip_device_req (int il_phone, device_id_t device_id, services_t netif){429 int ip_device_req_local(int il_phone, device_id_t device_id, services_t netif){ 427 430 ERROR_DECLARE; 428 431 … … 656 659 } 657 660 658 int ip_send_msg (int il_phone, device_id_t device_id, packet_t packet, services_t sender, services_t error){661 int ip_send_msg_local(int il_phone, device_id_t device_id, packet_t packet, services_t sender, services_t error){ 659 662 ERROR_DECLARE; 660 663 … … 782 785 // sleep(1); 783 786 // ERROR_PROPAGATE(arp_translate_req(netif->arp->phone, netif->device_id, SERVICE_IP, &destination, &translation, &data)); 784 pq_release (ip_globals.net_phone, packet_get_id(packet));787 pq_release_remote(ip_globals.net_phone, packet_get_id(packet)); 785 788 return ERROR_CODE; 786 789 } … … 799 802 }else translation = NULL; 800 803 if(ERROR_OCCURRED(ip_prepare_packet(src, dest, packet, translation))){ 801 pq_release (ip_globals.net_phone, packet_get_id(packet));804 pq_release_remote(ip_globals.net_phone, packet_get_id(packet)); 802 805 }else{ 803 806 packet = ip_split_packet(packet, netif->packet_dimension.prefix, netif->packet_dimension.content, netif->packet_dimension.suffix, netif->packet_dimension.addr_len, error); … … 891 894 } 892 895 893 int ip_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 896 int ip_message_standalone(ipc_callid_t callid, ipc_call_t *call, 897 ipc_call_t *answer, int * answer_count) 898 { 894 899 ERROR_DECLARE; 895 900 896 901 packet_t packet; 897 struct sockaddr * 902 struct sockaddr *addr; 898 903 size_t addrlen; 899 904 size_t prefix; 900 905 size_t suffix; 901 906 size_t content; 902 ip_pseudo_header_refheader;907 void *header; 903 908 size_t headerlen; 904 909 device_id_t device_id; 905 910 906 911 *answer_count = 0; 907 switch (IPC_GET_METHOD(*call)){912 switch (IPC_GET_METHOD(*call)) { 908 913 case IPC_M_PHONE_HUNGUP: 909 914 return EOK; 910 915 case NET_IL_DEVICE: 911 return ip_device_req(0, IPC_GET_DEVICE(call), IPC_GET_SERVICE(call)); 916 return ip_device_req_local(0, IPC_GET_DEVICE(call), 917 IPC_GET_SERVICE(call)); 912 918 case IPC_M_CONNECT_TO_ME: 913 return ip_register(IL_GET_PROTO(call), IL_GET_SERVICE(call), IPC_GET_PHONE(call), NULL); 919 return ip_register(IL_GET_PROTO(call), IL_GET_SERVICE(call), 920 IPC_GET_PHONE(call), NULL); 914 921 case NET_IL_SEND: 915 ERROR_PROPAGATE(packet_translate(ip_globals.net_phone, &packet, IPC_GET_PACKET(call))); 916 return ip_send_msg(0, IPC_GET_DEVICE(call), packet, 0, IPC_GET_ERROR(call)); 922 ERROR_PROPAGATE(packet_translate_remote(ip_globals.net_phone, &packet, 923 IPC_GET_PACKET(call))); 924 return ip_send_msg_local(0, IPC_GET_DEVICE(call), packet, 0, 925 IPC_GET_ERROR(call)); 917 926 case NET_IL_DEVICE_STATE: 918 return ip_device_state_message(IPC_GET_DEVICE(call), IPC_GET_STATE(call)); 927 return ip_device_state_message(IPC_GET_DEVICE(call), 928 IPC_GET_STATE(call)); 919 929 case NET_IL_RECEIVED: 920 ERROR_PROPAGATE(packet_translate(ip_globals.net_phone, &packet, IPC_GET_PACKET(call))); 930 ERROR_PROPAGATE(packet_translate_remote(ip_globals.net_phone, &packet, 931 IPC_GET_PACKET(call))); 921 932 return ip_receive_message(IPC_GET_DEVICE(call), packet); 922 933 case NET_IP_RECEIVED_ERROR: 923 ERROR_PROPAGATE(packet_translate(ip_globals.net_phone, &packet, IPC_GET_PACKET(call))); 924 return ip_received_error_msg(0, IPC_GET_DEVICE(call), packet, IPC_GET_TARGET(call), IPC_GET_ERROR(call)); 934 ERROR_PROPAGATE(packet_translate_remote(ip_globals.net_phone, &packet, 935 IPC_GET_PACKET(call))); 936 return ip_received_error_msg_local(0, IPC_GET_DEVICE(call), packet, 937 IPC_GET_TARGET(call), IPC_GET_ERROR(call)); 925 938 case NET_IP_ADD_ROUTE: 926 return ip_add_route_req(0, IPC_GET_DEVICE(call), IP_GET_ADDRESS(call), IP_GET_NETMASK(call), IP_GET_GATEWAY(call)); 939 return ip_add_route_req_local(0, IPC_GET_DEVICE(call), 940 IP_GET_ADDRESS(call), IP_GET_NETMASK(call), IP_GET_GATEWAY(call)); 927 941 case NET_IP_SET_GATEWAY: 928 return ip_set_gateway_req(0, IPC_GET_DEVICE(call), IP_GET_GATEWAY(call)); 942 return ip_set_gateway_req_local(0, IPC_GET_DEVICE(call), 943 IP_GET_GATEWAY(call)); 929 944 case NET_IP_GET_ROUTE: 930 945 ERROR_PROPAGATE(data_receive((void **) &addr, &addrlen)); 931 ERROR_PROPAGATE(ip_get_route_req (0, IP_GET_PROTOCOL(call), addr, (socklen_t) addrlen,932 &device_id, &header, &headerlen));946 ERROR_PROPAGATE(ip_get_route_req_local(0, IP_GET_PROTOCOL(call), 947 addr, (socklen_t) addrlen, &device_id, &header, &headerlen)); 933 948 IPC_SET_DEVICE(answer, device_id); 934 949 IP_SET_HEADERLEN(answer, headerlen); 950 935 951 *answer_count = 2; 936 if(! ERROR_OCCURRED(data_reply(&headerlen, sizeof(headerlen)))){ 952 953 if (!ERROR_OCCURRED(data_reply(&headerlen, sizeof(headerlen)))) 937 954 ERROR_CODE = data_reply(header, headerlen); 938 }955 939 956 free(header); 940 957 return ERROR_CODE; 941 958 case NET_IL_PACKET_SPACE: 942 ERROR_PROPAGATE(ip_packet_size_message(IPC_GET_DEVICE(call), &addrlen, &prefix, &content, &suffix)); 959 ERROR_PROPAGATE(ip_packet_size_message(IPC_GET_DEVICE(call), 960 &addrlen, &prefix, &content, &suffix)); 943 961 IPC_SET_ADDR(answer, addrlen); 944 962 IPC_SET_PREFIX(answer, prefix); … … 948 966 return EOK; 949 967 case NET_IL_MTU_CHANGED: 950 return ip_mtu_changed_message(IPC_GET_DEVICE(call), IPC_GET_MTU(call)); 951 } 968 return ip_mtu_changed_message(IPC_GET_DEVICE(call), 969 IPC_GET_MTU(call)); 970 } 971 952 972 return ENOTSUP; 953 973 } 954 974 955 int ip_packet_size_req(int ip_phone, device_id_t device_id, packet_dimension_ref packet_dimension){ 956 if(! packet_dimension){ 975 int ip_packet_size_req_local(int ip_phone, device_id_t device_id, 976 packet_dimension_ref packet_dimension) 977 { 978 if (!packet_dimension) 957 979 return EBADMEM; 958 } 959 return ip_packet_size_message(device_id, &packet_dimension->addr_len, &packet_dimension->prefix, &packet_dimension->content, &packet_dimension->suffix); 980 981 return ip_packet_size_message(device_id, &packet_dimension->addr_len, 982 &packet_dimension->prefix, &packet_dimension->content, 983 &packet_dimension->suffix); 960 984 } 961 985 … … 1003 1027 } 1004 1028 1005 int ip_add_route_req (int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway){1029 int ip_add_route_req_local(int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway){ 1006 1030 ip_route_ref route; 1007 1031 ip_netif_ref netif; … … 1067 1091 } 1068 1092 1069 int ip_set_gateway_req(int ip_phone, device_id_t device_id, in_addr_t gateway){ 1093 int ip_set_gateway_req_local(int ip_phone, device_id_t device_id, in_addr_t gateway) 1094 { 1070 1095 ip_netif_ref netif; 1071 1096 … … 1112 1137 } 1113 1138 }else{ 1114 pq_release (ip_globals.net_phone, packet_get_id(next));1139 pq_release_remote(ip_globals.net_phone, packet_get_id(next)); 1115 1140 } 1116 1141 next = new_packet; … … 1153 1178 } 1154 1179 // create the last fragment 1155 new_packet = packet_get_4 (ip_globals.net_phone, prefix, length, suffix, ((addrlen > addr_len) ? addrlen : addr_len));1180 new_packet = packet_get_4_remote(ip_globals.net_phone, prefix, length, suffix, ((addrlen > addr_len) ? addrlen : addr_len)); 1156 1181 if(! new_packet){ 1157 1182 return ENOMEM; … … 1177 1202 // create middle framgents 1178 1203 while(IP_TOTAL_LENGTH(header) > length){ 1179 new_packet = packet_get_4 (ip_globals.net_phone, prefix, length, suffix, ((addrlen >= addr_len) ? addrlen : addr_len));1204 new_packet = packet_get_4_remote(ip_globals.net_phone, prefix, length, suffix, ((addrlen >= addr_len) ? addrlen : addr_len)); 1180 1205 if(! new_packet){ 1181 1206 return ENOMEM; … … 1357 1382 } 1358 1383 1359 int ip_received_error_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t target, services_t error){ 1384 /** Notify the IP module about the received error notification packet. 1385 * 1386 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 1387 * @param[in] device_id The device identifier. 1388 * @param[in] packet The received packet or the received packet queue. 1389 * @param[in] target The target internetwork module service to be 1390 * delivered to. 1391 * @param[in] error The packet error reporting service. Prefixes the 1392 * received packet. 1393 * 1394 * @return EOK on success. 1395 * 1396 */ 1397 int ip_received_error_msg_local(int ip_phone, device_id_t device_id, packet_t packet, services_t target, services_t error){ 1360 1398 uint8_t * data; 1361 1399 int offset; … … 1492 1530 next = pq_detach(packet); 1493 1531 if(next){ 1494 pq_release (ip_globals.net_phone, packet_get_id(next));1532 pq_release_remote(ip_globals.net_phone, packet_get_id(next)); 1495 1533 } 1496 1534 if(! header){ … … 1556 1594 1557 1595 int ip_release_and_return(packet_t packet, int result){ 1558 pq_release (ip_globals.net_phone, packet_get_id(packet));1596 pq_release_remote(ip_globals.net_phone, packet_get_id(packet)); 1559 1597 return result; 1560 1598 } 1561 1599 1562 int ip_get_route_req (int ip_phone, ip_protocol_t protocol, const struct sockaddr * destination, socklen_t addrlen, device_id_t * device_id, ip_pseudo_header_ref *header, size_t * headerlen){1600 int ip_get_route_req_local(int ip_phone, ip_protocol_t protocol, const struct sockaddr * destination, socklen_t addrlen, device_id_t * device_id, void **header, size_t * headerlen){ 1563 1601 struct sockaddr_in * address_in; 1564 1602 // struct sockaddr_in6 * address_in6; … … 1624 1662 header_in->protocol = protocol; 1625 1663 header_in->data_length = 0; 1626 *header = (ip_pseudo_header_ref)header_in;1664 *header = header_in; 1627 1665 return EOK; 1628 1666 } 1629 1630 #ifdef CONFIG_NETWORKING_modular1631 1632 #include <il_standalone.h>1633 1667 1634 1668 /** Default thread for new connections. … … 1658 1692 1659 1693 /* Process the message */ 1660 int res = il_module_message(callid, &call, &answer, &answer_count); 1694 int res = il_module_message_standalone(callid, &call, &answer, 1695 &answer_count); 1661 1696 1662 1697 /* End if said to either by the message or the processing result */ … … 1683 1718 1684 1719 /* Start the module */ 1685 if (ERROR_OCCURRED(il_module_start (il_client_connection)))1720 if (ERROR_OCCURRED(il_module_start_standalone(il_client_connection))) 1686 1721 return ERROR_CODE; 1687 1722 … … 1689 1724 } 1690 1725 1691 #endif /* CONFIG_NETWORKING_modular */1692 1693 1726 /** @} 1694 1727 */ -
uspace/srv/net/il/ip/ip_module.c
r24ab58b3 r14f1db0 47 47 #include <net_interface.h> 48 48 #include <packet/packet.h> 49 #include <il_ standalone.h>49 #include <il_local.h> 50 50 51 51 #include "ip.h" … … 54 54 /** IP module global data. 55 55 */ 56 extern ip_globals_t 56 extern ip_globals_t ip_globals; 57 57 58 58 /** Processes the IP message. … … 64 64 * @returns Other error codes as defined for the ip_message() function. 65 65 */ 66 int il_module_message (ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){67 return ip_message (callid, call, answer, answer_count);66 int il_module_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 67 return ip_message_standalone(callid, call, answer, answer_count); 68 68 } 69 69 … … 75 75 * @returns Other error codes as defined for the REGISTER_ME() macro function. 76 76 */ 77 int il_module_start (async_client_conn_t client_connection){77 int il_module_start_standalone(async_client_conn_t client_connection){ 78 78 ERROR_DECLARE; 79 80 ipcarg_t phonehash; 81 79 82 80 async_set_client_connection(client_connection); 83 81 ip_globals.net_phone = net_connect_module(SERVICE_NETWORKING); 84 82 ERROR_PROPAGATE(pm_init()); 85 if(ERROR_OCCURRED(ip_initialize(client_connection)) 86 || ERROR_OCCURRED(REGISTER_ME(SERVICE_IP, &phonehash))){ 83 84 ipcarg_t phonehash; 85 if (ERROR_OCCURRED(ip_initialize(client_connection)) 86 || ERROR_OCCURRED(REGISTER_ME(SERVICE_IP, &phonehash))) { 87 87 pm_destroy(); 88 88 return ERROR_CODE; 89 89 } 90 90 91 91 async_manager(); 92 92 93 93 pm_destroy(); 94 94 return EOK; -
uspace/srv/net/il/ip/ip_module.h
r24ab58b3 r14f1db0 59 59 * @see IS_NET_IP_MESSAGE() 60 60 */ 61 int ip_message (ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);61 int ip_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count); 62 62 63 63 #endif -
uspace/srv/net/net/Makefile
r24ab58b3 r14f1db0 30 30 USPACE_PREFIX = ../../.. 31 31 ROOT_PATH = $(USPACE_PREFIX)/.. 32 LIBS = $(LIBNET IF_PREFIX)/libnetif.a $(LIBNET_PREFIX)/libnet.a $(LIBSOCKET_PREFIX)/libsocket.a33 EXTRA_CFLAGS = -I$(LIBNET IF_PREFIX)/include -I$(LIBNET_PREFIX)/include -I$(LIBSOCKET_PREFIX)/include32 LIBS = $(LIBNET_PREFIX)/libnet.a $(LIBSOCKET_PREFIX)/libsocket.a 33 EXTRA_CFLAGS = -I$(LIBNET_PREFIX)/include -I$(LIBSOCKET_PREFIX)/include 34 34 35 35 COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common -
uspace/srv/net/net/net.c
r24ab58b3 r14f1db0 56 56 #include <packet/packet.h> 57 57 #include <il_messages.h> 58 #include <netif_remote.h> 58 59 #include <net_device.h> 59 #include <netif_interface.h>60 60 #include <nil_interface.h> 61 61 #include <net_interface.h> … … 461 461 int io = setting ? strtol(setting->value, NULL, 16) : 0; 462 462 463 ERROR_PROPAGATE(netif_probe_req (netif->driver->phone, netif->id, irq, io));463 ERROR_PROPAGATE(netif_probe_req_remote(netif->driver->phone, netif->id, irq, io)); 464 464 465 465 /* Network interface layer startup */ … … 490 490 } 491 491 492 ERROR_PROPAGATE(netif_start_req (netif->driver->phone, netif->id));492 ERROR_PROPAGATE(netif_start_req_remote(netif->driver->phone, netif->id)); 493 493 return EOK; 494 494 } -
uspace/srv/net/net/net_standalone.c
r24ab58b3 r14f1db0 49 49 /** Networking module global data. 50 50 */ 51 extern net_globals_t 51 extern net_globals_t net_globals; 52 52 53 /** Initializes the networking module for the chosen subsystem build type. 54 * @param[in] client_connection The client connection processing function. The module skeleton propagates its own one. 55 * @returns EOK on success. 56 * @returns ENOMEM if there is not enough memory left. 53 /** Initialize the networking module for the chosen subsystem build type. 54 * 55 * @param[in] client_connection The client connection processing function. 56 * The module skeleton propagates its own one. 57 * 58 * @return EOK on success. 59 * @return ENOMEM if there is not enough memory left. 60 * 57 61 */ 58 62 int net_initialize_build(async_client_conn_t client_connection){ 59 63 ERROR_DECLARE; 60 61 task_id_t task_id; 62 63 task_id = spawn("/srv/ip"); 64 if(! task_id){ 64 65 task_id_t task_id = spawn("/srv/ip"); 66 if (!task_id) 65 67 return EINVAL; 66 } 67 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, IP_NAME, IP_FILENAME, SERVICE_IP, task_id, ip_connect_module)); 68 if(! spawn("/srv/icmp")){ 68 69 ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, IP_NAME, 70 IP_FILENAME, SERVICE_IP, task_id, ip_connect_module)); 71 72 if (!spawn("/srv/icmp")) 69 73 return EINVAL; 70 }71 if (! spawn("/srv/udp")){74 75 if (!spawn("/srv/udp")) 72 76 return EINVAL; 73 }74 if (! spawn("/srv/tcp")){77 78 if (!spawn("/srv/tcp")) 75 79 return EINVAL; 76 }80 77 81 return EOK; 78 82 } 79 83 80 /** Processes the module message. 81 * Distributes the message to the right bundled module. 82 * @param[in] callid The message identifier. 83 * @param[in] call The message parameters. 84 * @param[out] answer The message answer parameters. 85 * @param[out] answer_count The last parameter for the actual answer in the answer parameter. 86 * @returns EOK on success. 87 * @returns ENOTSUP if the message is not known. 88 * @returns Other error codes as defined for each bundled module message function. 84 /** Process the module message. 85 * 86 * Distribute the message to the right module. 87 * 88 * @param[in] callid The message identifier. 89 * @param[in] call The message parameters. 90 * @param[out] answer The message answer parameters. 91 * @param[out] answer_count The last parameter for the actual answer in 92 * the answer parameter. 93 * 94 * @return EOK on success. 95 * @return ENOTSUP if the message is not known. 96 * @return Other error codes as defined for each bundled module 97 * message function. 98 * 89 99 */ 90 int net_module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 91 if(IS_NET_PACKET_MESSAGE(call)){ 100 int net_module_message(ipc_callid_t callid, ipc_call_t *call, 101 ipc_call_t *answer, int *answer_count) 102 { 103 if (IS_NET_PACKET_MESSAGE(call)) 92 104 return packet_server_message(callid, call, answer, answer_count); 93 }else{ 94 return net_message(callid, call, answer, answer_count); 95 } 105 106 return net_message(callid, call, answer, answer_count); 96 107 } 97 108 -
uspace/srv/net/netif/lo/Makefile
r24ab58b3 r14f1db0 39 39 -include $(CONFIG_MAKEFILE) 40 40 41 ifeq ($(CONFIG_NET WORKING),modular)42 BINARY = lo41 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y) 42 LIBS += $(USPACE_PREFIX)/srv/net/nil/nildummy/libnildummy.a 43 43 endif 44 44 45 ifeq ($(CONFIG_NETWORKING),module) 46 LIBRARY = liblo 47 endif 45 BINARY = lo 48 46 49 47 SOURCES = \ -
uspace/srv/net/netif/lo/lo.c
r24ab58b3 r14f1db0 51 51 #include <nil_interface.h> 52 52 #include <nil_messages.h> 53 #include <netif .h>54 #include <netif_ module.h>53 #include <netif_interface.h> 54 #include <netif_local.h> 55 55 56 56 /** Default hardware address. … … 76 76 * @returns EOK otherwise. 77 77 */ 78 int change_state_message( device_refdevice, device_state_t state);78 int change_state_message(netif_device_t * device, device_state_t state); 79 79 80 80 /** Creates and returns the loopback network interface structure. … … 85 85 * @returns ENOMEM if there is not enough memory left. 86 86 */ 87 int create(device_id_t device_id, device_ref* device);87 int create(device_id_t device_id, netif_device_t * * device); 88 88 89 89 int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ … … 103 103 ERROR_DECLARE; 104 104 105 device_refdevice;105 netif_device_t * device; 106 106 107 107 if(! stats){ … … 113 113 } 114 114 115 int change_state_message( device_refdevice, device_state_t state)115 int change_state_message(netif_device_t * device, device_state_t state) 116 116 { 117 117 if (device->state != state) { … … 127 127 } 128 128 129 int create(device_id_t device_id, device_ref* device){129 int create(device_id_t device_id, netif_device_t * * device){ 130 130 int index; 131 131 132 if( device_map_count(&netif_globals.device_map) > 0){132 if(netif_device_map_count(&netif_globals.device_map) > 0){ 133 133 return EXDEV; 134 134 }else{ 135 *device = ( device_ref) malloc(sizeof(device_t));135 *device = (netif_device_t *) malloc(sizeof(netif_device_t)); 136 136 if(!(*device)){ 137 137 return ENOMEM; … … 146 146 (** device).nil_phone = -1; 147 147 (** device).state = NETIF_STOPPED; 148 index = device_map_add(&netif_globals.device_map, (** device).device_id, * device);148 index = netif_device_map_add(&netif_globals.device_map, (** device).device_id, * device); 149 149 if(index < 0){ 150 150 free(*device); … … 166 166 ERROR_DECLARE; 167 167 168 device_refdevice;168 netif_device_t * device; 169 169 170 170 // create a new device … … 178 178 ERROR_DECLARE; 179 179 180 device_refdevice;180 netif_device_t * device; 181 181 size_t length; 182 182 packet_t next; … … 204 204 } 205 205 206 int netif_start_message( device_refdevice){206 int netif_start_message(netif_device_t * device){ 207 207 return change_state_message(device, NETIF_ACTIVE); 208 208 } 209 209 210 int netif_stop_message( device_refdevice){210 int netif_stop_message(netif_device_t * device){ 211 211 return change_state_message(device, NETIF_STOPPED); 212 212 } 213 213 214 #ifdef CONFIG_NETWORKING_modular215 216 #include <netif_standalone.h>217 218 214 /** Default thread for new connections. 219 215 * 220 * 221 * 222 * 223 */ 224 static void netif_client_connection(ipc_callid_t iid, ipc_call_t * 216 * @param[in] iid The initial message identifier. 217 * @param[in] icall The initial message call structure. 218 * 219 */ 220 static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall) 225 221 { 226 222 /* … … 254 250 } 255 251 256 /** Starts the module.257 *258 * @param argc The count of the command line arguments. Ignored parameter.259 * @param argv The command line parameters. Ignored parameter.260 *261 * @returns EOK on success.262 * @returns Other error codes as defined for each specific module start function.263 *264 */265 252 int main(int argc, char *argv[]) 266 253 { … … 274 261 } 275 262 276 #endif /* CONFIG_NETWORKING_modular */277 278 263 /** @} 279 264 */ -
uspace/srv/net/nil/eth/Makefile
r24ab58b3 r14f1db0 29 29 30 30 USPACE_PREFIX = ../../../.. 31 LIBS = $(LIBNETIF_PREFIX)/libnetif.a $(LIBNET_PREFIX)/libnet.a $(LIBSOCKET_PREFIX)/libsocket.a 32 EXTRA_CFLAGS = -I$(LIBNETIF_PREFIX)/include -I$(LIBNET_PREFIX)/include -I$(LIBSOCKET_PREFIX)/include 33 BINARY = eth 31 ROOT_PATH = $(USPACE_PREFIX)/.. 32 LIBS = $(LIBNET_PREFIX)/libnet.a $(LIBSOCKET_PREFIX)/libsocket.a 33 EXTRA_CFLAGS = -I$(LIBNET_PREFIX)/include -I$(LIBSOCKET_PREFIX)/include 34 35 COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common 36 CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config 37 38 -include $(COMMON_MAKEFILE) 39 -include $(CONFIG_MAKEFILE) 40 41 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y) 42 LIBRARY = libeth 43 else 44 BINARY = eth 45 endif 34 46 35 47 SOURCES = \ -
uspace/srv/net/nil/eth/eth.c
r24ab58b3 r14f1db0 60 60 #include <adt/measured_strings.h> 61 61 #include <packet/packet_client.h> 62 #include <nil_module.h> 62 #include <packet_remote.h> 63 #include <nil_local.h> 63 64 64 65 #include "eth.h" … … 271 272 INT_MAP_IMPLEMENT(eth_protos, eth_proto_t) 272 273 273 int nil_device_state_msg (int nil_phone, device_id_t device_id, int state){274 int nil_device_state_msg_local(int nil_phone, device_id_t device_id, int state){ 274 275 int index; 275 276 eth_proto_ref proto; … … 475 476 } 476 477 477 int nil_received_msg (int nil_phone, device_id_t device_id, packet_t packet, services_t target){478 int nil_received_msg_local(int nil_phone, device_id_t device_id, packet_t packet, services_t target){ 478 479 eth_proto_ref proto; 479 480 packet_t next; … … 497 498 }else{ 498 499 // drop invalid/unknown 499 pq_release (eth_globals.net_phone, packet_get_id(packet));500 pq_release_remote(eth_globals.net_phone, packet_get_id(packet)); 500 501 } 501 502 packet = next; … … 681 682 ethertype = htons(protocol_map(SERVICE_ETHERNET, sender)); 682 683 if(! ethertype){ 683 pq_release (eth_globals.net_phone, packet_get_id(packet));684 pq_release_remote(eth_globals.net_phone, packet_get_id(packet)); 684 685 return EINVAL; 685 686 } … … 699 700 packet = tmp; 700 701 } 701 pq_release (eth_globals.net_phone, packet_get_id(next));702 pq_release_remote(eth_globals.net_phone, packet_get_id(next)); 702 703 next = tmp; 703 704 }else{ … … 713 714 } 714 715 715 int nil_message (const char *name, ipc_callid_t callid, ipc_call_t *call,716 int nil_message_standalone(const char *name, ipc_callid_t callid, ipc_call_t *call, 716 717 ipc_call_t *answer, int *answer_count) 717 718 { … … 733 734 IPC_GET_SERVICE(call), IPC_GET_MTU(call)); 734 735 case NET_NIL_SEND: 735 ERROR_PROPAGATE(packet_translate (eth_globals.net_phone, &packet,736 ERROR_PROPAGATE(packet_translate_remote(eth_globals.net_phone, &packet, 736 737 IPC_GET_PACKET(call))); 737 738 return eth_send_message(IPC_GET_DEVICE(call), packet, … … 771 772 switch(IPC_GET_METHOD(*icall)){ 772 773 case NET_NIL_DEVICE_STATE: 773 nil_device_state_msg (0, IPC_GET_DEVICE(icall), IPC_GET_STATE(icall));774 nil_device_state_msg_local(0, IPC_GET_DEVICE(icall), IPC_GET_STATE(icall)); 774 775 ipc_answer_0(iid, EOK); 775 776 break; 776 777 case NET_NIL_RECEIVED: 777 if(! ERROR_OCCURRED(packet_translate (eth_globals.net_phone, &packet, IPC_GET_PACKET(icall)))){778 ERROR_CODE = nil_received_msg (0, IPC_GET_DEVICE(icall), packet, 0);778 if(! ERROR_OCCURRED(packet_translate_remote(eth_globals.net_phone, &packet, IPC_GET_PACKET(icall)))){ 779 ERROR_CODE = nil_received_msg_local(0, IPC_GET_DEVICE(icall), packet, 0); 779 780 } 780 781 ipc_answer_0(iid, (ipcarg_t) ERROR_CODE); … … 787 788 } 788 789 789 #ifdef CONFIG_NETWORKING_modular 790 791 #include <nil_standalone.h> 790 #ifndef CONFIG_NETIF_NIL_BUNDLE 792 791 793 792 /** Default thread for new connections. 794 793 * 795 * 796 * 794 * @param[in] iid The initial message identifier. 795 * @param[in] icall The initial message call structure. 797 796 * 798 797 */ 799 static void nil_client_connection(ipc_callid_t iid, ipc_call_t * 798 static void nil_client_connection(ipc_callid_t iid, ipc_call_t *icall) 800 799 { 801 800 /* … … 817 816 818 817 /* Process the message */ 819 int res = nil_module_message (NAME, callid, &call, &answer,818 int res = nil_module_message_standalone(NAME, callid, &call, &answer, 820 819 &answer_count); 821 820 … … 829 828 } 830 829 831 /** Starts the module.832 *833 * @param argc The count of the command line arguments. Ignored parameter.834 * @param argv The command line parameters. Ignored parameter.835 *836 * @returns EOK on success.837 * @returns Other error codes as defined for each specific module start function.838 *839 */840 830 int main(int argc, char *argv[]) 841 831 { … … 843 833 844 834 /* Start the module */ 845 if (ERROR_OCCURRED(nil_module_start (nil_client_connection)))835 if (ERROR_OCCURRED(nil_module_start_standalone(nil_client_connection))) 846 836 return ERROR_CODE; 847 837 … … 849 839 } 850 840 851 #endif /* CONFIG_NET WORKING_modular*/841 #endif /* CONFIG_NETIF_NIL_BUNDLE */ 852 842 853 843 /** @} -
uspace/srv/net/nil/eth/eth_module.c
r24ab58b3 r14f1db0 46 46 #include <net_interface.h> 47 47 #include <packet/packet.h> 48 #include <nil_module.h> 49 #include <nil_standalone.h> 48 #include <nil_local.h> 50 49 51 50 #include "eth.h" … … 59 58 * @returns Other error codes as defined for the REGISTER_ME() macro function. 60 59 */ 61 int nil_module_start(async_client_conn_t client_connection){ 60 int nil_module_start_standalone(async_client_conn_t client_connection) 61 { 62 62 ERROR_DECLARE; 63 63 64 async_set_client_connection(client_connection); 65 int net_phone = net_connect_module(SERVICE_NETWORKING); 66 ERROR_PROPAGATE(pm_init()); 67 64 68 ipcarg_t phonehash; 65 int net_phone; 66 67 async_set_client_connection(client_connection); 68 net_phone = net_connect_module(SERVICE_NETWORKING); 69 ERROR_PROPAGATE(pm_init()); 70 if(ERROR_OCCURRED(nil_initialize(net_phone)) 71 || ERROR_OCCURRED(REGISTER_ME(SERVICE_ETHERNET, &phonehash))){ 69 if (ERROR_OCCURRED(nil_initialize(net_phone)) 70 || ERROR_OCCURRED(REGISTER_ME(SERVICE_ETHERNET, &phonehash))) { 72 71 pm_destroy(); 73 72 return ERROR_CODE; 74 73 } 75 74 76 75 async_manager(); 77 76 78 77 pm_destroy(); 79 78 return EOK; … … 95 94 * 96 95 */ 97 int nil_module_message (const char *name, ipc_callid_t callid, ipc_call_t *call,96 int nil_module_message_standalone(const char *name, ipc_callid_t callid, ipc_call_t *call, 98 97 ipc_call_t *answer, int *answer_count) 99 98 { 100 return nil_message (name, callid, call, answer, answer_count);99 return nil_message_standalone(name, callid, call, answer, answer_count); 101 100 } 102 101 -
uspace/srv/net/nil/nildummy/Makefile
r24ab58b3 r14f1db0 29 29 30 30 USPACE_PREFIX = ../../../.. 31 LIBS = $(LIBNETIF_PREFIX)/libnetif.a $(LIBNET_PREFIX)/libnet.a $(LIBSOCKET_PREFIX)/libsocket.a 32 EXTRA_CFLAGS = -I$(LIBNETIF_PREFIX)/include -I$(LIBNET_PREFIX)/include -I$(LIBSOCKET_PREFIX)/include 33 BINARY = nildummy 31 ROOT_PATH = $(USPACE_PREFIX)/.. 32 LIBS = $(LIBNET_PREFIX)/libnet.a $(LIBSOCKET_PREFIX)/libsocket.a 33 EXTRA_CFLAGS = -I$(LIBNET_PREFIX)/include -I$(LIBSOCKET_PREFIX)/include 34 35 COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common 36 CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config 37 38 -include $(COMMON_MAKEFILE) 39 -include $(CONFIG_MAKEFILE) 40 41 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y) 42 LIBRARY = libnildummy 43 else 44 BINARY = nildummy 45 endif 34 46 35 47 SOURCES = \ -
uspace/srv/net/nil/nildummy/nildummy.c
r24ab58b3 r14f1db0 28 28 29 29 /** @addtogroup nildummy 30 * 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * 35 * 34 * Dummy network interface layer module implementation. 35 * @see nildummy.h 36 36 */ 37 37 … … 41 41 #include <stdio.h> 42 42 #include <str.h> 43 44 43 #include <ipc/ipc.h> 45 44 #include <ipc/services.h> … … 54 53 #include <adt/measured_strings.h> 55 54 #include <packet/packet.h> 56 #include <nil_module.h> 55 #include <packet_remote.h> 56 #include <nil_local.h> 57 57 58 58 #include "nildummy.h" 59 59 60 60 /** The module name. 61 * 61 62 */ 62 63 #define NAME "nildummy" 63 64 64 65 /** Default maximum transmission unit. 65 */ 66 #define NET_DEFAULT_MTU 1500 66 * 67 */ 68 #define NET_DEFAULT_MTU 1500 67 69 68 70 /** Network interface layer module global data. 69 */ 70 nildummy_globals_t nildummy_globals; 71 72 /** @name Message processing functions 73 */ 74 /*@{*/ 75 76 /** Processes IPC messages from the registered device driver modules in an infinite loop. 77 * @param[in] iid The message identifier. 78 * @param[in,out] icall The message parameters. 79 */ 80 void nildummy_receiver(ipc_callid_t iid, ipc_call_t * icall); 81 82 /** Registers new device or updates the MTU of an existing one. 83 * Determines the device local hardware address. 84 * @param[in] device_id The new device identifier. 85 * @param[in] service The device driver service. 86 * @param[in] mtu The device maximum transmission unit. 87 * @returns EOK on success. 88 * @returns EEXIST if the device with the different service exists. 89 * @returns ENOMEM if there is not enough memory left. 90 * @returns Other error codes as defined for the netif_bind_service() function. 91 * @returns Other error codes as defined for the netif_get_addr_req() function. 92 */ 93 int nildummy_device_message(device_id_t device_id, services_t service, size_t mtu); 94 95 /** Returns the device packet dimensions for sending. 96 * @param[in] device_id The device identifier. 97 * @param[out] addr_len The minimum reserved address length. 98 * @param[out] prefix The minimum reserved prefix size. 99 * @param[out] content The maximum content size. 100 * @param[out] suffix The minimum reserved suffix size. 101 * @returns EOK on success. 102 * @returns EBADMEM if either one of the parameters is NULL. 103 * @returns ENOENT if there is no such device. 104 */ 105 int nildummy_packet_space_message(device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix); 106 107 /** Registers receiving module service. 108 * Passes received packets for this service. 109 * @param[in] service The module service. 110 * @param[in] phone The service phone. 111 * @returns EOK on success. 112 * @returns ENOENT if the service is not known. 113 * @returns ENOMEM if there is not enough memory left. 114 */ 115 int nildummy_register_message(services_t service, int phone); 116 117 /** Sends the packet queue. 118 * @param[in] device_id The device identifier. 119 * @param[in] packet The packet queue. 120 * @param[in] sender The sending module service. 121 * @returns EOK on success. 122 * @returns ENOENT if there no such device. 123 * @returns EINVAL if the service parameter is not known. 124 */ 125 int nildummy_send_message(device_id_t device_id, packet_t packet, services_t sender); 126 127 /** Returns the device hardware address. 128 * @param[in] device_id The device identifier. 129 * @param[out] address The device hardware address. 130 * @returns EOK on success. 131 * @returns EBADMEM if the address parameter is NULL. 132 * @returns ENOENT if there no such device. 133 */ 134 int nildummy_addr_message(device_id_t device_id, measured_string_ref * address); 135 136 /*@}*/ 137 138 DEVICE_MAP_IMPLEMENT(nildummy_devices, nildummy_device_t) 139 140 int nil_device_state_msg(int nil_phone, device_id_t device_id, int state){ 71 * 72 */ 73 nildummy_globals_t nildummy_globals; 74 75 DEVICE_MAP_IMPLEMENT(nildummy_devices, nildummy_device_t); 76 77 int nil_device_state_msg_local(int nil_phone, device_id_t device_id, int state) 78 { 141 79 fibril_rwlock_read_lock(&nildummy_globals.protos_lock); 142 if(nildummy_globals.proto.phone){ 143 il_device_state_msg(nildummy_globals.proto.phone, device_id, state, nildummy_globals.proto.service); 144 } 80 81 if (nildummy_globals.proto.phone) 82 il_device_state_msg(nildummy_globals.proto.phone, device_id, state, 83 nildummy_globals.proto.service); 84 145 85 fibril_rwlock_read_unlock(&nildummy_globals.protos_lock); 146 return EOK; 147 } 148 149 int nil_initialize(int net_phone){ 86 87 return EOK; 88 } 89 90 int nil_initialize(int net_phone) 91 { 150 92 ERROR_DECLARE; 151 93 152 94 fibril_rwlock_initialize(&nildummy_globals.devices_lock); 153 95 fibril_rwlock_initialize(&nildummy_globals.protos_lock); 154 96 fibril_rwlock_write_lock(&nildummy_globals.devices_lock); 155 97 fibril_rwlock_write_lock(&nildummy_globals.protos_lock); 98 156 99 nildummy_globals.net_phone = net_phone; 157 100 nildummy_globals.proto.phone = 0; 158 101 ERROR_PROPAGATE(nildummy_devices_initialize(&nildummy_globals.devices)); 102 159 103 fibril_rwlock_write_unlock(&nildummy_globals.protos_lock); 160 104 fibril_rwlock_write_unlock(&nildummy_globals.devices_lock); 161 return EOK; 162 } 163 164 int nildummy_device_message(device_id_t device_id, services_t service, size_t mtu){ 105 106 return EOK; 107 } 108 109 /** Process IPC messages from the registered device driver modules in an infinite loop. 110 * 111 * @param[in] iid The message identifier. 112 * @param[in,out] icall The message parameters. 113 * 114 */ 115 static void nildummy_receiver(ipc_callid_t iid, ipc_call_t * icall){ 116 ERROR_DECLARE; 117 118 packet_t packet; 119 120 while(true){ 121 switch(IPC_GET_METHOD(*icall)){ 122 case NET_NIL_DEVICE_STATE: 123 ERROR_CODE = nil_device_state_msg_local(0, IPC_GET_DEVICE(icall), IPC_GET_STATE(icall)); 124 ipc_answer_0(iid, (ipcarg_t) ERROR_CODE); 125 break; 126 case NET_NIL_RECEIVED: 127 if(! ERROR_OCCURRED(packet_translate_remote(nildummy_globals.net_phone, &packet, IPC_GET_PACKET(icall)))){ 128 ERROR_CODE = nil_received_msg_local(0, IPC_GET_DEVICE(icall), packet, 0); 129 } 130 ipc_answer_0(iid, (ipcarg_t) ERROR_CODE); 131 break; 132 default: 133 ipc_answer_0(iid, (ipcarg_t) ENOTSUP); 134 } 135 iid = async_get_call(icall); 136 } 137 } 138 139 /** Register new device or updates the MTU of an existing one. 140 * 141 * Determine the device local hardware address. 142 * 143 * @param[in] device_id The new device identifier. 144 * @param[in] service The device driver service. 145 * @param[in] mtu The device maximum transmission unit. 146 * 147 * @returns EOK on success. 148 * @returns EEXIST if the device with the different service exists. 149 * @returns ENOMEM if there is not enough memory left. 150 * @returns Other error codes as defined for the netif_bind_service() function. 151 * @returns Other error codes as defined for the netif_get_addr_req() function. 152 * 153 */ 154 static int nildummy_device_message(device_id_t device_id, services_t service, 155 size_t mtu) 156 { 165 157 ERROR_DECLARE; 166 158 … … 235 227 } 236 228 237 int nildummy_addr_message(device_id_t device_id, measured_string_ref * address){ 229 /** Return the device hardware address. 230 * 231 * @param[in] device_id The device identifier. 232 * @param[out] address The device hardware address. 233 * 234 * @return EOK on success. 235 * @return EBADMEM if the address parameter is NULL. 236 * @return ENOENT if there no such device. 237 * 238 */ 239 static int nildummy_addr_message(device_id_t device_id, 240 measured_string_ref *address) 241 { 238 242 nildummy_device_ref device; 239 243 … … 252 256 } 253 257 254 int nildummy_packet_space_message(device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix){ 258 /** Return the device packet dimensions for sending. 259 * 260 * @param[in] device_id The device identifier. 261 * @param[out] addr_len The minimum reserved address length. 262 * @param[out] prefix The minimum reserved prefix size. 263 * @param[out] content The maximum content size. 264 * @param[out] suffix The minimum reserved suffix size. 265 * 266 * @return EOK on success. 267 * @return EBADMEM if either one of the parameters is NULL. 268 * @return ENOENT if there is no such device. 269 * 270 */ 271 static int nildummy_packet_space_message(device_id_t device_id, 272 size_t *addr_len, size_t *prefix, size_t *content, size_t *suffix) 273 { 255 274 nildummy_device_ref device; 256 275 … … 272 291 } 273 292 274 int nil_received_msg (int nil_phone, device_id_t device_id, packet_t packet, services_t target){293 int nil_received_msg_local(int nil_phone, device_id_t device_id, packet_t packet, services_t target){ 275 294 packet_t next; 276 295 … … 287 306 } 288 307 289 int nildummy_register_message(services_t service, int phone){ 308 /** Register receiving module service. 309 * 310 * Pass received packets for this service. 311 * 312 * @param[in] service The module service. 313 * @param[in] phone The service phone. 314 * 315 * @return EOK on success. 316 * @return ENOENT if the service is not known. 317 * @return ENOMEM if there is not enough memory left. 318 * 319 */ 320 static int nildummy_register_message(services_t service, int phone) 321 { 290 322 fibril_rwlock_write_lock(&nildummy_globals.protos_lock); 291 323 nildummy_globals.proto.service = service; … … 299 331 } 300 332 301 int nildummy_send_message(device_id_t device_id, packet_t packet, services_t sender){ 333 /** Send the packet queue. 334 * 335 * @param[in] device_id The device identifier. 336 * @param[in] packet The packet queue. 337 * @param[in] sender The sending module service. 338 * 339 * @return EOK on success. 340 * @return ENOENT if there no such device. 341 * @return EINVAL if the service parameter is not known. 342 * 343 */ 344 static int nildummy_send_message(device_id_t device_id, packet_t packet, 345 services_t sender) 346 { 302 347 nildummy_device_ref device; 303 348 … … 316 361 } 317 362 318 int nil_message (const char *name, ipc_callid_t callid, ipc_call_t *call,363 int nil_message_standalone(const char *name, ipc_callid_t callid, ipc_call_t *call, 319 364 ipc_call_t *answer, int *answer_count) 320 365 { … … 336 381 IPC_GET_SERVICE(call), IPC_GET_MTU(call)); 337 382 case NET_NIL_SEND: 338 ERROR_PROPAGATE(packet_translate (nildummy_globals.net_phone,383 ERROR_PROPAGATE(packet_translate_remote(nildummy_globals.net_phone, 339 384 &packet, IPC_GET_PACKET(call))); 340 385 return nildummy_send_message(IPC_GET_DEVICE(call), packet, … … 353 398 &address)); 354 399 return measured_strings_reply(address, 1); 400 case NET_NIL_BROADCAST_ADDR: 401 ERROR_PROPAGATE(nildummy_addr_message(IPC_GET_DEVICE(call), 402 &address)); 403 return measured_strings_reply(address, 1); 355 404 case IPC_M_CONNECT_TO_ME: 356 405 return nildummy_register_message(NIL_GET_PROTO(call), … … 361 410 } 362 411 363 void nildummy_receiver(ipc_callid_t iid, ipc_call_t * icall){ 364 ERROR_DECLARE; 365 366 packet_t packet; 367 368 while(true){ 369 // printf("message %d - %d\n", IPC_GET_METHOD(*icall), NET_NIL_FIRST); 370 switch(IPC_GET_METHOD(*icall)){ 371 case NET_NIL_DEVICE_STATE: 372 ERROR_CODE = nil_device_state_msg(0, IPC_GET_DEVICE(icall), IPC_GET_STATE(icall)); 373 ipc_answer_0(iid, (ipcarg_t) ERROR_CODE); 374 break; 375 case NET_NIL_RECEIVED: 376 if(! ERROR_OCCURRED(packet_translate(nildummy_globals.net_phone, &packet, IPC_GET_PACKET(icall)))){ 377 ERROR_CODE = nil_received_msg(0, IPC_GET_DEVICE(icall), packet, 0); 378 } 379 ipc_answer_0(iid, (ipcarg_t) ERROR_CODE); 380 break; 381 default: 382 ipc_answer_0(iid, (ipcarg_t) ENOTSUP); 383 } 384 iid = async_get_call(icall); 385 } 386 } 387 388 #ifdef CONFIG_NETWORKING_modular 389 390 #include <nil_standalone.h> 412 #ifndef CONFIG_NETIF_NIL_BUNDLE 391 413 392 414 /** Default thread for new connections. 393 415 * 394 * @param[in] iidThe initial message identifier.395 * 396 * 397 */ 398 static void nil_client_connection(ipc_callid_t iid, ipc_call_t * 416 * @param[in] iid The initial message identifier. 417 * @param[in] icall The initial message call structure. 418 * 419 */ 420 static void nil_client_connection(ipc_callid_t iid, ipc_call_t *icall) 399 421 { 400 422 /* … … 416 438 417 439 /* Process the message */ 418 int res = nil_module_message (NAME, callid, &call, &answer,440 int res = nil_module_message_standalone(NAME, callid, &call, &answer, 419 441 &answer_count); 420 442 … … 428 450 } 429 451 430 /** Starts the module.431 *432 * @param argc The count of the command line arguments. Ignored parameter.433 * @param argv The command line parameters. Ignored parameter.434 *435 * @returns EOK on success.436 * @returns Other error codes as defined for each specific module start function.437 *438 */439 452 int main(int argc, char *argv[]) 440 453 { … … 442 455 443 456 /* Start the module */ 444 if (ERROR_OCCURRED(nil_module_start (nil_client_connection)))457 if (ERROR_OCCURRED(nil_module_start_standalone(nil_client_connection))) 445 458 return ERROR_CODE; 446 459 … … 448 461 } 449 462 450 #endif /* CONFIG_NET WORKING_modular*/463 #endif /* CONFIG_NETIF_NIL_BUNDLE */ 451 464 452 465 /** @} -
uspace/srv/net/nil/nildummy/nildummy_module.c
r24ab58b3 r14f1db0 46 46 #include <net_interface.h> 47 47 #include <packet/packet.h> 48 #include <nil_module.h> 49 #include <nil_standalone.h> 48 #include <nil_local.h> 50 49 51 50 #include "nildummy.h" … … 67 66 * 68 67 */ 69 int nil_module_start (async_client_conn_t client_connection)68 int nil_module_start_standalone(async_client_conn_t client_connection) 70 69 { 71 70 ERROR_DECLARE; … … 103 102 * 104 103 */ 105 int nil_module_message (const char *name, ipc_callid_t callid,104 int nil_module_message_standalone(const char *name, ipc_callid_t callid, 106 105 ipc_call_t *call, ipc_call_t *answer, int *answer_count) 107 106 { 108 return nil_message (name, callid, call, answer, answer_count);107 return nil_message_standalone(name, callid, call, answer, answer_count); 109 108 } 110 109 -
uspace/srv/net/tl/icmp/icmp.c
r24ab58b3 r14f1db0 51 51 #include <net_modules.h> 52 52 #include <packet/packet_client.h> 53 #include <packet_remote.h> 53 54 #include <net_byteorder.h> 54 55 #include <net_checksum.h> … … 67 68 #include <socket_errno.h> 68 69 #include <tl_messages.h> 70 #include <tl_interface.h> 71 #include <tl_local.h> 69 72 #include <icmp_messages.h> 70 73 #include <icmp_header.h> … … 288 291 // TODO do not ask all the time 289 292 ERROR_PROPAGATE(ip_packet_size_req(icmp_globals.ip_phone, -1, &icmp_globals.packet_dimension)); 290 packet = packet_get_4 (icmp_globals.net_phone, size, icmp_globals.packet_dimension.addr_len, ICMP_HEADER_SIZE + icmp_globals.packet_dimension.prefix, icmp_globals.packet_dimension.suffix);293 packet = packet_get_4_remote(icmp_globals.net_phone, size, icmp_globals.packet_dimension.addr_len, ICMP_HEADER_SIZE + icmp_globals.packet_dimension.prefix, icmp_globals.packet_dimension.suffix); 291 294 if(! packet){ 292 295 return ENOMEM; … … 626 629 // compute the reply key 627 630 reply_key = ICMP_GET_REPLY_KEY(header->un.echo.identifier, header->un.echo.sequence_number); 628 pq_release (icmp_globals.net_phone, packet_get_id(packet));631 pq_release_remote(icmp_globals.net_phone, packet_get_id(packet)); 629 632 // lock the globals 630 633 fibril_rwlock_write_lock(&icmp_globals.lock); … … 641 644 } 642 645 643 int icmp_message (ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){646 int icmp_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 644 647 ERROR_DECLARE; 645 648 … … 649 652 switch(IPC_GET_METHOD(*call)){ 650 653 case NET_TL_RECEIVED: 651 if(! ERROR_OCCURRED(packet_translate (icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){654 if(! ERROR_OCCURRED(packet_translate_remote(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){ 652 655 ERROR_CODE = icmp_received_msg(IPC_GET_DEVICE(call), packet, SERVICE_ICMP, IPC_GET_ERROR(call)); 653 656 } … … 759 762 switch(IPC_GET_METHOD(*call)){ 760 763 case NET_ICMP_DEST_UNREACH: 761 if(! ERROR_OCCURRED(packet_translate (icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){764 if(! ERROR_OCCURRED(packet_translate_remote(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){ 762 765 ERROR_CODE = icmp_destination_unreachable_msg(0, ICMP_GET_CODE(call), ICMP_GET_MTU(call), packet); 763 766 } 764 767 return ERROR_CODE; 765 768 case NET_ICMP_SOURCE_QUENCH: 766 if(! ERROR_OCCURRED(packet_translate (icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){769 if(! ERROR_OCCURRED(packet_translate_remote(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){ 767 770 ERROR_CODE = icmp_source_quench_msg(0, packet); 768 771 } 769 772 return ERROR_CODE; 770 773 case NET_ICMP_TIME_EXCEEDED: 771 if(! ERROR_OCCURRED(packet_translate (icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){774 if(! ERROR_OCCURRED(packet_translate_remote(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){ 772 775 ERROR_CODE = icmp_time_exceeded_msg(0, ICMP_GET_CODE(call), packet); 773 776 } 774 777 return ERROR_CODE; 775 778 case NET_ICMP_PARAMETERPROB: 776 if(! ERROR_OCCURRED(packet_translate (icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){779 if(! ERROR_OCCURRED(packet_translate_remote(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){ 777 780 ERROR_CODE = icmp_parameter_problem_msg(0, ICMP_GET_CODE(call), ICMP_GET_POINTER(call), packet); 778 781 } … … 784 787 785 788 int icmp_release_and_return(packet_t packet, int result){ 786 pq_release (icmp_globals.net_phone, packet_get_id(packet));789 pq_release_remote(icmp_globals.net_phone, packet_get_id(packet)); 787 790 return result; 788 791 } … … 819 822 } 820 823 821 #ifdef CONFIG_NETWORKING_modular822 823 #include <tl_standalone.h>824 825 824 /** Default thread for new connections. 826 825 * … … 849 848 850 849 /* Process the message */ 851 int res = tl_module_message(callid, &call, &answer, &answer_count); 850 int res = tl_module_message_standalone(callid, &call, &answer, 851 &answer_count); 852 852 853 853 /* End if said to either by the message or the processing result */ … … 874 874 875 875 /* Start the module */ 876 if (ERROR_OCCURRED(tl_module_start (tl_client_connection)))876 if (ERROR_OCCURRED(tl_module_start_standalone(tl_client_connection))) 877 877 return ERROR_CODE; 878 878 … … 880 880 } 881 881 882 #endif /* CONFIG_NETWORKING_modular */883 884 882 /** @} 885 883 */ -
uspace/srv/net/tl/icmp/icmp_module.c
r24ab58b3 r14f1db0 47 47 #include <packet/packet.h> 48 48 #include <net_interface.h> 49 #include <tl_ standalone.h>49 #include <tl_local.h> 50 50 51 51 #include "icmp.h" … … 63 63 * @returns Other error codes as defined for the REGISTER_ME() macro function. 64 64 */ 65 int tl_module_start (async_client_conn_t client_connection){65 int tl_module_start_standalone(async_client_conn_t client_connection){ 66 66 ERROR_DECLARE; 67 67 … … 94 94 * @returns Other error codes as defined for the icmp_message() function. 95 95 */ 96 int tl_module_message (ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){97 return icmp_message (callid, call, answer, answer_count);96 int tl_module_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 97 return icmp_message_standalone(callid, call, answer, answer_count); 98 98 } 99 99 -
uspace/srv/net/tl/icmp/icmp_module.h
r24ab58b3 r14f1db0 59 59 * @see IS_NET_ICMP_MESSAGE() 60 60 */ 61 int icmp_message (ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);61 int icmp_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count); 62 62 63 63 #endif -
uspace/srv/net/tl/tcp/tcp.c
r24ab58b3 r14f1db0 51 51 #include <adt/dynamic_fifo.h> 52 52 #include <packet/packet_client.h> 53 #include <packet_remote.h> 53 54 #include <net_checksum.h> 54 55 #include <in.h> … … 68 69 #include <tl_common.h> 69 70 #include <tl_messages.h> 71 #include <tl_local.h> 72 #include <tl_interface.h> 70 73 71 74 #include "tcp.h" … … 421 424 break; 422 425 default: 423 pq_release (tcp_globals.net_phone, packet_get_id(packet));426 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 424 427 } 425 428 … … 473 476 // release the acknowledged packets 474 477 next_packet = pq_next(packet); 475 pq_release (tcp_globals.net_phone, packet_get_id(packet));478 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 476 479 packet = next_packet; 477 480 offset -= length; … … 517 520 next_packet = pq_next(next_packet); 518 521 pq_insert_after(tmp_packet, next_packet); 519 pq_release (tcp_globals.net_phone, packet_get_id(tmp_packet));522 pq_release_remote(tcp_globals.net_phone, packet_get_id(tmp_packet)); 520 523 } 521 524 assert(new_sequence_number + total_length == socket_data->next_incoming + socket_data->window); … … 548 551 socket_data->incoming = next_packet; 549 552 } 550 pq_release (tcp_globals.net_phone, packet_get_id(packet));553 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 551 554 packet = next_packet; 552 555 continue; … … 568 571 if(length <= 0){ 569 572 // remove the empty packet 570 pq_release (tcp_globals.net_phone, packet_get_id(packet));573 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 571 574 packet = next_packet; 572 575 continue; … … 595 598 } 596 599 // remove the duplicit or corrupted packet 597 pq_release (tcp_globals.net_phone, packet_get_id(packet));600 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 598 601 packet = next_packet; 599 602 continue; … … 617 620 if(ERROR_OCCURRED(pq_add(&socket_data->incoming, packet, new_sequence_number, length))){ 618 621 // remove the corrupted packets 619 pq_release (tcp_globals.net_phone, packet_get_id(packet));620 pq_release (tcp_globals.net_phone, packet_get_id(next_packet));622 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 623 pq_release_remote(tcp_globals.net_phone, packet_get_id(next_packet)); 621 624 }else{ 622 625 while(next_packet){ … … 626 629 if(ERROR_OCCURRED(pq_set_order(next_packet, new_sequence_number, length)) 627 630 || ERROR_OCCURRED(pq_insert_after(packet, next_packet))){ 628 pq_release (tcp_globals.net_phone, packet_get_id(next_packet));631 pq_release_remote(tcp_globals.net_phone, packet_get_id(next_packet)); 629 632 } 630 633 next_packet = tmp_packet; … … 634 637 printf("unexpected\n"); 635 638 // release duplicite or restricted 636 pq_release (tcp_globals.net_phone, packet_get_id(packet));639 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 637 640 } 638 641 … … 679 682 // queue the received packet 680 683 if(ERROR_OCCURRED(dyn_fifo_push(&socket->received, packet_get_id(packet), SOCKET_MAX_RECEIVED_SIZE)) 681 684 || ERROR_OCCURRED(tl_get_ip_packet_dimension(tcp_globals.ip_phone, &tcp_globals.dimensions, socket_data->device_id, &packet_dimension))){ 682 685 return tcp_release_and_return(packet, ERROR_CODE); 683 686 } … … 710 713 next_packet = pq_detach(packet); 711 714 if(next_packet){ 712 pq_release (tcp_globals.net_phone, packet_get_id(next_packet));715 pq_release_remote(tcp_globals.net_phone, packet_get_id(next_packet)); 713 716 } 714 717 // trim if longer than the header … … 780 783 free(socket_data->addr); 781 784 free(socket_data); 782 pq_release (tcp_globals.net_phone, packet_get_id(packet));785 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 783 786 return ERROR_CODE; 784 787 } … … 846 849 next_packet = pq_detach(packet); 847 850 if(next_packet){ 848 pq_release (tcp_globals.net_phone, packet_get_id(next_packet));851 pq_release_remote(tcp_globals.net_phone, packet_get_id(next_packet)); 849 852 } 850 853 // trim if longer than the header … … 895 898 896 899 socket_data->next_incoming = ntohl(header->sequence_number);// + 1; 897 pq_release (tcp_globals.net_phone, packet_get_id(packet));900 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 898 901 socket_data->state = TCP_SOCKET_ESTABLISHED; 899 902 listening_socket = socket_cores_find(socket_data->local_sockets, socket_data->listening_socket_id); … … 981 984 // add to acknowledged or release 982 985 if(pq_add(&acknowledged, packet, 0, 0) != EOK){ 983 pq_release (tcp_globals.net_phone, packet_get_id(packet));986 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 984 987 } 985 988 packet = next; … … 990 993 // release acknowledged 991 994 if(acknowledged){ 992 pq_release (tcp_globals.net_phone, packet_get_id(acknowledged));995 pq_release_remote(tcp_globals.net_phone, packet_get_id(acknowledged)); 993 996 } 994 997 return; … … 1006 1009 } 1007 1010 1008 int tcp_message (ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){1011 int tcp_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 1009 1012 ERROR_DECLARE; 1010 1013 … … 1019 1022 case NET_TL_RECEIVED: 1020 1023 //fibril_rwlock_read_lock(&tcp_globals.lock); 1021 if(! ERROR_OCCURRED(packet_translate (tcp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){1024 if(! ERROR_OCCURRED(packet_translate_remote(tcp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){ 1022 1025 ERROR_CODE = tcp_received_msg(IPC_GET_DEVICE(call), packet, SERVICE_TCP, IPC_GET_ERROR(call)); 1023 1026 } … … 1111 1114 fibril_rwlock_write_unlock(&lock); 1112 1115 if(res == EOK){ 1113 if (tl_get_ip_packet_dimension(tcp_globals.ip_phone, &tcp_globals.dimensions, DEVICE_INVALID_ID, &packet_dimension) == EOK){1116 if (tl_get_ip_packet_dimension(tcp_globals.ip_phone, &tcp_globals.dimensions, DEVICE_INVALID_ID, &packet_dimension) == EOK){ 1114 1117 SOCKET_SET_DATA_FRAGMENT_SIZE(answer, ((packet_dimension->content < socket_data->data_fragment_size) ? packet_dimension->content : socket_data->data_fragment_size)); 1115 1118 } … … 1565 1568 }else{ 1566 1569 if(ERROR_OCCURRED(pq_insert_after(previous, copy))){ 1567 pq_release (tcp_globals.net_phone, packet_get_id(copy));1570 pq_release_remote(tcp_globals.net_phone, packet_get_id(copy)); 1568 1571 return sending; 1569 1572 } … … 1597 1600 // adjust the pseudo header 1598 1601 if(ERROR_OCCURRED(ip_client_set_pseudo_header_data_length(socket_data->pseudo_header, socket_data->headerlen, packet_get_data_length(packet)))){ 1599 pq_release (tcp_globals.net_phone, packet_get_id(packet));1602 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 1600 1603 return NULL; 1601 1604 } … … 1604 1607 header = (tcp_header_ref) packet_get_data(packet); 1605 1608 if(! header){ 1606 pq_release (tcp_globals.net_phone, packet_get_id(packet));1609 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 1607 1610 return NULL; 1608 1611 } … … 1625 1628 // prepare the timeout 1626 1629 || ERROR_OCCURRED(tcp_prepare_timeout(tcp_timeout, socket, socket_data, sequence_number, socket_data->state, socket_data->timeout, true))){ 1627 pq_release (tcp_globals.net_phone, packet_get_id(packet));1630 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 1628 1631 return NULL; 1629 1632 } … … 1750 1753 return NO_DATA; 1751 1754 } 1752 ERROR_PROPAGATE(packet_translate (tcp_globals.net_phone, &packet, packet_id));1755 ERROR_PROPAGATE(packet_translate_remote(tcp_globals.net_phone, &packet, packet_id)); 1753 1756 1754 1757 // reply the packets … … 1757 1760 // release the packet 1758 1761 dyn_fifo_pop(&socket->received); 1759 pq_release (tcp_globals.net_phone, packet_get_id(packet));1762 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 1760 1763 // return the total length 1761 1764 return (int) length; … … 1889 1892 ERROR_PROPAGATE(tl_get_ip_packet_dimension(tcp_globals.ip_phone, &tcp_globals.dimensions, socket_data->device_id, &packet_dimension)); 1890 1893 // get a new packet 1891 *packet = packet_get_4 (tcp_globals.net_phone, TCP_HEADER_SIZE, packet_dimension->addr_len, packet_dimension->prefix, packet_dimension->suffix);1894 *packet = packet_get_4_remote(tcp_globals.net_phone, TCP_HEADER_SIZE, packet_dimension->addr_len, packet_dimension->prefix, packet_dimension->suffix); 1892 1895 if(! * packet){ 1893 1896 return ENOMEM; … … 1993 1996 1994 1997 int tcp_release_and_return(packet_t packet, int result){ 1995 pq_release (tcp_globals.net_phone, packet_get_id(packet));1998 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 1996 1999 return result; 1997 2000 } 1998 1999 #ifdef CONFIG_NETWORKING_modular2000 2001 #include <tl_standalone.h>2002 2001 2003 2002 /** Default thread for new connections. … … 2027 2026 2028 2027 /* Process the message */ 2029 int res = tl_module_message(callid, &call, &answer, &answer_count); 2028 int res = tl_module_message_standalone(callid, &call, &answer, 2029 &answer_count); 2030 2030 2031 2031 /* End if said to either by the message or the processing result */ … … 2052 2052 2053 2053 /* Start the module */ 2054 if (ERROR_OCCURRED(tl_module_start (tl_client_connection)))2054 if (ERROR_OCCURRED(tl_module_start_standalone(tl_client_connection))) 2055 2055 return ERROR_CODE; 2056 2056 … … 2058 2058 } 2059 2059 2060 #endif /* CONFIG_NETWORKING_modular */2061 2062 2060 /** @} 2063 2061 */ -
uspace/srv/net/tl/tcp/tcp.h
r24ab58b3 r14f1db0 232 232 /** IP pseudo header. 233 233 */ 234 ip_pseudo_header_refpseudo_header;234 void *pseudo_header; 235 235 /** IP pseudo header length. 236 236 */ -
uspace/srv/net/tl/tcp/tcp_module.c
r24ab58b3 r14f1db0 49 49 #include <ip_protocols.h> 50 50 #include <ip_interface.h> 51 #include <tl_ standalone.h>51 #include <tl_local.h> 52 52 53 53 #include "tcp.h" … … 65 65 * @returns Other error codes as defined for the REGISTER_ME() macro function. 66 66 */ 67 int tl_module_start(async_client_conn_t client_connection){ 67 int tl_module_start_standalone(async_client_conn_t client_connection) 68 { 68 69 ERROR_DECLARE; 69 70 ipcarg_t phonehash; 71 70 72 71 async_set_client_connection(client_connection); 73 72 tcp_globals.net_phone = net_connect_module(SERVICE_NETWORKING); 74 73 ERROR_PROPAGATE(pm_init()); 75 if(ERROR_OCCURRED(tcp_initialize(client_connection)) 76 || ERROR_OCCURRED(REGISTER_ME(SERVICE_TCP, &phonehash))){ 74 75 ipcarg_t phonehash; 76 if (ERROR_OCCURRED(tcp_initialize(client_connection)) 77 || ERROR_OCCURRED(REGISTER_ME(SERVICE_TCP, &phonehash))) { 77 78 pm_destroy(); 78 79 return ERROR_CODE; 79 80 } 80 81 81 82 async_manager(); 82 83 83 84 pm_destroy(); 84 85 return EOK; … … 93 94 * @returns Other error codes as defined for the tcp_message() function. 94 95 */ 95 int tl_module_message (ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){96 return tcp_message (callid, call, answer, answer_count);96 int tl_module_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 97 return tcp_message_standalone(callid, call, answer, answer_count); 97 98 } 98 99 -
uspace/srv/net/tl/tcp/tcp_module.h
r24ab58b3 r14f1db0 59 59 * @see IS_NET_TCP_MESSAGE() 60 60 */ 61 extern int tcp_message (ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);61 extern int tcp_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count); 62 62 63 63 #endif -
uspace/srv/net/tl/udp/udp.c
r24ab58b3 r14f1db0 48 48 #include <adt/dynamic_fifo.h> 49 49 #include <packet/packet_client.h> 50 #include <packet_remote.h> 50 51 #include <net_checksum.h> 51 52 #include <in.h> … … 63 64 #include <socket_messages.h> 64 65 #include <tl_common.h> 66 #include <tl_local.h> 67 #include <tl_interface.h> 65 68 #include <tl_messages.h> 66 69 … … 258 261 icmp_type_t type; 259 262 icmp_code_t code; 260 ip_pseudo_header_refip_header;263 void *ip_header; 261 264 struct sockaddr * src; 262 265 struct sockaddr * dest; … … 356 359 while(tmp_packet){ 357 360 next_packet = pq_detach(tmp_packet); 358 pq_release (udp_globals.net_phone, packet_get_id(tmp_packet));361 pq_release_remote(udp_globals.net_phone, packet_get_id(tmp_packet)); 359 362 tmp_packet = next_packet; 360 363 } … … 382 385 // queue the received packet 383 386 if(ERROR_OCCURRED(dyn_fifo_push(&socket->received, packet_get_id(packet), SOCKET_MAX_RECEIVED_SIZE)) 384 387 || ERROR_OCCURRED(tl_get_ip_packet_dimension(udp_globals.ip_phone, &udp_globals.dimensions, device_id, &packet_dimension))){ 385 388 return udp_release_and_return(packet, ERROR_CODE); 386 389 } … … 392 395 } 393 396 394 int udp_message (ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){397 int udp_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 395 398 ERROR_DECLARE; 396 399 … … 400 403 switch(IPC_GET_METHOD(*call)){ 401 404 case NET_TL_RECEIVED: 402 if(! ERROR_OCCURRED(packet_translate (udp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){405 if(! ERROR_OCCURRED(packet_translate_remote(udp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){ 403 406 ERROR_CODE = udp_received_msg(IPC_GET_DEVICE(call), packet, SERVICE_UDP, IPC_GET_ERROR(call)); 404 407 } … … 457 460 458 461 if(res == EOK){ 459 if (tl_get_ip_packet_dimension(udp_globals.ip_phone, &udp_globals.dimensions, DEVICE_INVALID_ID, &packet_dimension) == EOK){462 if (tl_get_ip_packet_dimension(udp_globals.ip_phone, &udp_globals.dimensions, DEVICE_INVALID_ID, &packet_dimension) == EOK){ 460 463 SOCKET_SET_DATA_FRAGMENT_SIZE(answer, packet_dimension->content); 461 464 } … … 533 536 uint16_t dest_port; 534 537 uint32_t checksum; 535 ip_pseudo_header_refip_header;538 void *ip_header; 536 539 size_t headerlen; 537 540 device_id_t device_id; … … 662 665 return NO_DATA; 663 666 } 664 ERROR_PROPAGATE(packet_translate (udp_globals.net_phone, &packet, packet_id));667 ERROR_PROPAGATE(packet_translate_remote(udp_globals.net_phone, &packet, packet_id)); 665 668 // get udp header 666 669 data = packet_get_data(packet); 667 670 if(! data){ 668 pq_release (udp_globals.net_phone, packet_id);671 pq_release_remote(udp_globals.net_phone, packet_id); 669 672 return NO_DATA; 670 673 } … … 674 677 result = packet_get_addr(packet, (uint8_t **) &addr, NULL); 675 678 if(ERROR_OCCURRED(tl_set_address_port(addr, result, ntohs(header->source_port)))){ 676 pq_release (udp_globals.net_phone, packet_id);679 pq_release_remote(udp_globals.net_phone, packet_id); 677 680 return ERROR_CODE; 678 681 } … … 689 692 // release the packet 690 693 dyn_fifo_pop(&socket->received); 691 pq_release (udp_globals.net_phone, packet_get_id(packet));694 pq_release_remote(udp_globals.net_phone, packet_get_id(packet)); 692 695 // return the total length 693 696 return (int) length; … … 695 698 696 699 int udp_release_and_return(packet_t packet, int result){ 697 pq_release (udp_globals.net_phone, packet_get_id(packet));700 pq_release_remote(udp_globals.net_phone, packet_get_id(packet)); 698 701 return result; 699 702 } 700 701 #ifdef CONFIG_NETWORKING_modular702 703 #include <tl_standalone.h>704 703 705 704 /** Default thread for new connections. … … 729 728 730 729 /* Process the message */ 731 int res = tl_module_message(callid, &call, &answer, &answer_count); 730 int res = tl_module_message_standalone(callid, &call, &answer, 731 &answer_count); 732 732 733 733 /* End if said to either by the message or the processing result */ … … 754 754 755 755 /* Start the module */ 756 if (ERROR_OCCURRED(tl_module_start (tl_client_connection)))756 if (ERROR_OCCURRED(tl_module_start_standalone(tl_client_connection))) 757 757 return ERROR_CODE; 758 758 … … 760 760 } 761 761 762 #endif /* CONFIG_NETWORKING_modular */763 764 762 /** @} 765 763 */ -
uspace/srv/net/tl/udp/udp_module.c
r24ab58b3 r14f1db0 47 47 #include <packet/packet.h> 48 48 #include <net_interface.h> 49 #include <tl_ standalone.h>49 #include <tl_local.h> 50 50 51 51 #include "udp.h" … … 63 63 * @returns Other error codes as defined for the REGISTER_ME() macro function. 64 64 */ 65 int tl_module_start (async_client_conn_t client_connection){65 int tl_module_start_standalone(async_client_conn_t client_connection){ 66 66 ERROR_DECLARE; 67 67 … … 94 94 * @returns Other error codes as defined for the udp_message() function. 95 95 */ 96 int tl_module_message (ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){97 return udp_message (callid, call, answer, answer_count);96 int tl_module_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 97 return udp_message_standalone(callid, call, answer, answer_count); 98 98 } 99 99 -
uspace/srv/net/tl/udp/udp_module.h
r24ab58b3 r14f1db0 59 59 * @see IS_NET_UDP_MESSAGE() 60 60 */ 61 extern int udp_message (ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);61 extern int udp_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count); 62 62 63 63 #endif
Note:
See TracChangeset
for help on using the changeset viewer.