Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset f9d3dd4 in mainline


Ignore:
Timestamp:
2012-02-27T21:16:56Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
3d016ac
Parents:
1cc8b42
Message:

Translate IP to MAC addresses based on received ARP requests.

Location:
uspace/srv/ethip
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/ethip/Makefile

    r1cc8b42 rf9d3dd4  
    3232SOURCES = \
    3333        arp.c \
     34        atrans.c \
    3435        ethip.c \
    3536        ethip_nic.c \
  • uspace/srv/ethip/arp.c

    r1cc8b42 rf9d3dd4  
    4141
    4242#include "arp.h"
     43#include "atrans.h"
    4344#include "ethip.h"
    4445#include "ethip_nic.h"
     
    6970                if (laddr != NULL) {
    7071                        log_msg(LVL_DEBUG, "Request on my address");
     72
     73                        (void) atrans_add(&packet.sender_proto_addr,
     74                            &packet.sender_hw_addr);
    7175
    7276                        reply.opcode = aop_reply;
  • uspace/srv/ethip/ethip.c

    r1cc8b42 rf9d3dd4  
    4646
    4747#include "arp.h"
     48#include "atrans.h"
    4849#include "ethip.h"
    4950#include "ethip_nic.h"
     
    172173        void *data;
    173174        size_t size;
     175        mac48_addr_t dest_mac_addr;
    174176        int rc;
    175177
    176178        log_msg(LVL_DEBUG, "ethip_send()");
    177179
    178         frame.dest.addr = 0xdeeedeeedeee;
     180        rc = atrans_lookup(&sdu->ldest, &dest_mac_addr);
     181        if (rc != EOK) {
     182                log_msg(LVL_WARN, "Failed to look up IP address 0x%" PRIx32,
     183                    sdu->ldest.ipv4);
     184                return rc;
     185        }
     186
     187        frame.dest      = dest_mac_addr;
    179188        frame.src       = nic->mac_addr;
    180189        frame.etype_len = ETYPE_IP;
  • uspace/srv/ethip/ethip.h

    r1cc8b42 rf9d3dd4  
    109109} arp_eth_packet_t;
    110110
     111/** Address translation table element */
     112typedef struct {
     113        link_t atrans_list;
     114        iplink_srv_addr_t ip_addr;
     115        mac48_addr_t mac_addr;
     116} ethip_atrans_t;
     117
    111118extern int ethip_iplink_init(ethip_nic_t *);
    112119extern int ethip_received(iplink_srv_t *, void *, size_t);
Note: See TracChangeset for help on using the changeset viewer.