Changes in uspace/srv/net/il/arp/arp.c [19f857a:14f1db0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/il/arp/arp.c
r19f857a r14f1db0 43 43 #include <str.h> 44 44 #include <task.h> 45 46 45 #include <ipc/ipc.h> 47 46 #include <ipc/services.h> 48 47 49 #include "../../err.h" 50 #include "../../messages.h" 51 #include "../../modules.h" 52 53 #include "../../include/byteorder.h" 54 #include "../../include/device.h" 55 #include "../../include/arp_interface.h" 56 #include "../../include/nil_interface.h" 57 #include "../../include/protocol_map.h" 58 59 #include "../../structures/measured_strings.h" 60 #include "../../structures/packet/packet.h" 61 #include "../../structures/packet/packet_client.h" 62 63 #include "../il_messages.h" 48 #include <net_err.h> 49 #include <net_messages.h> 50 #include <net_modules.h> 51 #include <net_byteorder.h> 52 #include <net_device.h> 53 #include <arp_interface.h> 54 #include <nil_interface.h> 55 #include <protocol_map.h> 56 #include <adt/measured_strings.h> 57 #include <packet/packet.h> 58 #include <packet/packet_client.h> 59 #include <packet_remote.h> 60 #include <il_messages.h> 61 #include <il_interface.h> 62 #include <il_local.h> 63 #include <arp_messages.h> 64 64 65 65 #include "arp.h" … … 67 67 #include "arp_oc.h" 68 68 #include "arp_module.h" 69 #include "arp_messages.h" 69 70 71 /** ARP module name. 72 */ 73 #define NAME "arp" 70 74 71 75 /** ARP global data. … … 337 341 return ERROR_CODE; 338 342 } 339 printf("New device registered:\n\tid\t= %d\n\ttype\t= 0x%x\n\tservice\t= %d\n\tproto\t= %d\n", device->device_id, device->hardware, device->service, protocol); 343 printf("%s: Device registered (id: %d, type: 0x%x, service: %d, proto: %d)\n", 344 NAME, device->device_id, device->hardware, device->service, protocol); 340 345 } 341 346 fibril_rwlock_write_unlock(&arp_globals.lock); … … 368 373 } 369 374 370 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 { 371 378 ERROR_DECLARE; 372 379 373 380 measured_string_ref address; 374 381 measured_string_ref translation; … … 376 383 packet_t packet; 377 384 packet_t next; 378 379 // printf("message %d - %d\n", IPC_GET_METHOD(*call), NET_ARP_FIRST); 385 380 386 *answer_count = 0; 381 switch (IPC_GET_METHOD(*call)){387 switch (IPC_GET_METHOD(*call)) { 382 388 case IPC_M_PHONE_HUNGUP: 383 389 return EOK; … … 416 422 return EOK; 417 423 case NET_IL_RECEIVED: 418 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)))){ 419 425 fibril_rwlock_read_lock(&arp_globals.lock); 420 426 do{ … … 422 428 ERROR_CODE = arp_receive_message(IPC_GET_DEVICE(call), packet); 423 429 if(ERROR_CODE != 1){ 424 pq_release (arp_globals.net_phone, packet_get_id(packet));430 pq_release_remote(arp_globals.net_phone, packet_get_id(packet)); 425 431 } 426 432 packet = next; … … 432 438 return arp_mtu_changed_message(IPC_GET_DEVICE(call), IPC_GET_MTU(call)); 433 439 } 440 434 441 return ENOTSUP; 435 442 } … … 568 575 return NULL; 569 576 } 570 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); 571 578 if(! packet){ 572 579 return NULL; … … 574 581 header = (arp_header_ref) packet_suffix(packet, length); 575 582 if(! header){ 576 pq_release (arp_globals.net_phone, packet_get_id(packet));583 pq_release_remote(arp_globals.net_phone, packet_get_id(packet)); 577 584 return NULL; 578 585 } … … 591 598 memcpy(((uint8_t *) header) + length, target->value, target->length); 592 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){ 593 pq_release (arp_globals.net_phone, packet_get_id(packet));600 pq_release_remote(arp_globals.net_phone, packet_get_id(packet)); 594 601 return NULL; 595 602 } … … 618 625 } 619 626 627 /** Default thread for new connections. 628 * 629 * @param[in] iid The initial message identifier. 630 * @param[in] icall The initial message call structure. 631 * 632 */ 633 static void il_client_connection(ipc_callid_t iid, ipc_call_t * icall) 634 { 635 /* 636 * Accept the connection 637 * - Answer the first IPC_M_CONNECT_ME_TO call. 638 */ 639 ipc_answer_0(iid, EOK); 640 641 while(true) { 642 ipc_call_t answer; 643 int answer_count; 644 645 /* Clear the answer structure */ 646 refresh_answer(&answer, &answer_count); 647 648 /* Fetch the next message */ 649 ipc_call_t call; 650 ipc_callid_t callid = async_get_call(&call); 651 652 /* Process the message */ 653 int res = il_module_message_standalone(callid, &call, &answer, 654 &answer_count); 655 656 /* End if said to either by the message or the processing result */ 657 if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP)) 658 return; 659 660 /* Answer the message */ 661 answer_call(callid, res, &answer, answer_count); 662 } 663 } 664 665 /** Starts the module. 666 * 667 * @param argc The count of the command line arguments. Ignored parameter. 668 * @param argv The command line parameters. Ignored parameter. 669 * 670 * @returns EOK on success. 671 * @returns Other error codes as defined for each specific module start function. 672 * 673 */ 674 int main(int argc, char *argv[]) 675 { 676 ERROR_DECLARE; 677 678 /* Start the module */ 679 if (ERROR_OCCURRED(il_module_start_standalone(il_client_connection))) 680 return ERROR_CODE; 681 682 return EOK; 683 } 684 620 685 /** @} 621 686 */
Note:
See TracChangeset
for help on using the changeset viewer.