Changes in uspace/srv/net/il/arp/arp.c [14f1db0:19f857a] in mainline
- File:
-
- 1 edited
-
uspace/srv/net/il/arp/arp.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/il/arp/arp.c
r14f1db0 r19f857a 43 43 #include <str.h> 44 44 #include <task.h> 45 45 46 #include <ipc/ipc.h> 46 47 #include <ipc/services.h> 47 48 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> 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" 64 64 65 65 #include "arp.h" … … 67 67 #include "arp_oc.h" 68 68 #include "arp_module.h" 69 70 71 /** ARP module name. 72 */ 73 #define NAME "arp" 69 #include "arp_messages.h" 74 70 75 71 /** ARP global data. … … 341 337 return ERROR_CODE; 342 338 } 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); 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); 345 340 } 346 341 fibril_rwlock_write_unlock(&arp_globals.lock); … … 373 368 } 374 369 375 int arp_message_standalone(ipc_callid_t callid, ipc_call_t *call, 376 ipc_call_t *answer, int *answer_count) 377 { 370 int arp_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 378 371 ERROR_DECLARE; 379 372 380 373 measured_string_ref address; 381 374 measured_string_ref translation; … … 383 376 packet_t packet; 384 377 packet_t next; 385 378 379 // printf("message %d - %d\n", IPC_GET_METHOD(*call), NET_ARP_FIRST); 386 380 *answer_count = 0; 387 switch (IPC_GET_METHOD(*call)){381 switch(IPC_GET_METHOD(*call)){ 388 382 case IPC_M_PHONE_HUNGUP: 389 383 return EOK; … … 422 416 return EOK; 423 417 case NET_IL_RECEIVED: 424 if(! ERROR_OCCURRED(packet_translate _remote(arp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){418 if(! ERROR_OCCURRED(packet_translate(arp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){ 425 419 fibril_rwlock_read_lock(&arp_globals.lock); 426 420 do{ … … 428 422 ERROR_CODE = arp_receive_message(IPC_GET_DEVICE(call), packet); 429 423 if(ERROR_CODE != 1){ 430 pq_release _remote(arp_globals.net_phone, packet_get_id(packet));424 pq_release(arp_globals.net_phone, packet_get_id(packet)); 431 425 } 432 426 packet = next; … … 438 432 return arp_mtu_changed_message(IPC_GET_DEVICE(call), IPC_GET_MTU(call)); 439 433 } 440 441 434 return ENOTSUP; 442 435 } … … 575 568 return NULL; 576 569 } 577 packet = packet_get_4 _remote(arp_globals.net_phone, device->packet_dimension.addr_len, device->packet_dimension.prefix, length, device->packet_dimension.suffix);570 packet = packet_get_4(arp_globals.net_phone, device->packet_dimension.addr_len, device->packet_dimension.prefix, length, device->packet_dimension.suffix); 578 571 if(! packet){ 579 572 return NULL; … … 581 574 header = (arp_header_ref) packet_suffix(packet, length); 582 575 if(! header){ 583 pq_release _remote(arp_globals.net_phone, packet_get_id(packet));576 pq_release(arp_globals.net_phone, packet_get_id(packet)); 584 577 return NULL; 585 578 } … … 598 591 memcpy(((uint8_t *) header) + length, target->value, target->length); 599 592 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){ 600 pq_release _remote(arp_globals.net_phone, packet_get_id(packet));593 pq_release(arp_globals.net_phone, packet_get_id(packet)); 601 594 return NULL; 602 595 } … … 625 618 } 626 619 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 connection637 * - 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 685 620 /** @} 686 621 */
Note:
See TracChangeset
for help on using the changeset viewer.
