libliteeth/udp: add udp_set_ip and udp_set_mac functions

This commit is contained in:
Aleksandra Swierkowska 2021-01-13 18:14:50 +01:00
parent 1ce194007b
commit fc6b02d0da
2 changed files with 16 additions and 3 deletions

View File

@ -166,6 +166,18 @@ static void send_packet(void)
static unsigned char my_mac[6];
static unsigned int my_ip;
void udp_set_ip(unsigned int ip)
{
my_ip = ip;
}
void udp_set_mac(const unsigned char *macaddr)
{
int i;
for(i=0;i<6;i++)
my_mac[i] = macaddr[i];
}
/* ARP cache - one entry only */
static unsigned char cached_mac[6];
static unsigned int cached_ip;
@ -420,9 +432,8 @@ void udp_start(const unsigned char *macaddr, unsigned int ip)
ethmac_sram_reader_ev_pending_write(ETHMAC_EV_SRAM_READER);
ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);
for(i=0;i<6;i++)
my_mac[i] = macaddr[i];
my_ip = ip;
udp_set_ip(ip);
udp_set_mac(macaddr);
cached_ip = 0;
for(i=0;i<6;i++)

View File

@ -10,6 +10,8 @@
typedef void (*udp_callback)(unsigned int src_ip, unsigned short src_port, unsigned short dst_port, void *data, unsigned int length);
void udp_set_ip(unsigned int ip);
void udp_set_mac(const unsigned char *macaddr);
void udp_start(const unsigned char *macaddr, unsigned int ip);
int udp_arp_resolve(unsigned int ip);
void *udp_get_tx_buffer(void);