Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12618 Discussions

Iniche stack - how found MAC address from IP

Honored Contributor II

I'm using Nios II system to provide ethernet services (like ICMP, ARP etc. etc.) to an video over IP design. I'm using the uCOS II system with Nichestack.  

My video to IP transmitter (hardware design) needs to known the MAC address of the receiver interface. Since the user didn't specify the MAC address but only the IP address, I need to find the MAC address from the IP.  

I'm a newbie with uCOS and Nichestack. 

How I can implement a function that search for IP in the ARP table and if doesn't exist make and ARP request and send back the MAC address? I can use some existing functions? 

0 Kudos
2 Replies
Honored Contributor II

Review the source in et_arp.c You'll need to write your own function to extract the MAC from the ARP table, but functions exist for sending the ARP request. 


The ARP table is in 

struct arptabent arp_table;
0 Kudos
Honored Contributor II


I've implemented a function that parse the ARP table up to find correspondance between my IP and IP contained in ARP table, then I extract the relative MAC address. 


//parse arp_table to find matching specified IP <-> IP in ARP table and then readback MAC address 

for (i=0; i<= MAXARPS; i++) 

if (arp_table.t_pro_addr ==invert_addr_byte_order(udp_ip_tx_config[0].ipdestaddress)) 

mac_found = 1; 

mac_addr[0] = arp_table.t_phy_addr[0]; 

MAC_addr[1] = arp_table.t_phy_addr[1]; 

mac_addr[2] = arp_table.t_phy_addr[2]; 

MAC_addr[3] = arp_table.t_phy_addr[3]; 

mac_addr[4] = arp_table.t_phy_addr[4]; 

MAC_addr[5] = arp_table[i].t_phy_addr[5]; 

0 Kudos