Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/il/arp/arp.c

    r14f1db0 r19f857a  
    4343#include <str.h>
    4444#include <task.h>
     45
    4546#include <ipc/ipc.h>
    4647#include <ipc/services.h>
    4748
    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"
    6464
    6565#include "arp.h"
     
    6767#include "arp_oc.h"
    6868#include "arp_module.h"
    69 
    70 
    71 /** ARP module name.
    72  */
    73 #define NAME  "arp"
     69#include "arp_messages.h"
    7470
    7571/** ARP global data.
     
    341337                        return ERROR_CODE;
    342338                }
    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);
    345340        }
    346341        fibril_rwlock_write_unlock(&arp_globals.lock);
     
    373368}
    374369
    375 int arp_message_standalone(ipc_callid_t callid, ipc_call_t *call,
    376     ipc_call_t *answer, int *answer_count)
    377 {
     370int arp_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
    378371        ERROR_DECLARE;
    379        
     372
    380373        measured_string_ref address;
    381374        measured_string_ref translation;
     
    383376        packet_t packet;
    384377        packet_t next;
    385        
     378
     379//      printf("message %d - %d\n", IPC_GET_METHOD(*call), NET_ARP_FIRST);
    386380        *answer_count = 0;
    387         switch (IPC_GET_METHOD(*call)) {
     381        switch(IPC_GET_METHOD(*call)){
    388382                case IPC_M_PHONE_HUNGUP:
    389383                        return EOK;
     
    422416                        return EOK;
    423417                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)))){
    425419                                fibril_rwlock_read_lock(&arp_globals.lock);
    426420                                do{
     
    428422                                        ERROR_CODE = arp_receive_message(IPC_GET_DEVICE(call), packet);
    429423                                        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));
    431425                                        }
    432426                                        packet = next;
     
    438432                        return arp_mtu_changed_message(IPC_GET_DEVICE(call), IPC_GET_MTU(call));
    439433        }
    440        
    441434        return ENOTSUP;
    442435}
     
    575568                return NULL;
    576569        }
    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);
    578571        if(! packet){
    579572                return NULL;
     
    581574        header = (arp_header_ref) packet_suffix(packet, length);
    582575        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));
    584577                return NULL;
    585578        }
     
    598591        memcpy(((uint8_t *) header) + length, target->value, target->length);
    599592        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));
    601594                return NULL;
    602595        }
     
    625618}
    626619
    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 
    685620/** @}
    686621 */
Note: See TracChangeset for help on using the changeset viewer.