Commit b0213b1d authored by Wesley W. Terpstra's avatar Wesley W. Terpstra

Don't cache the MAC address; it can be changed from shell.

parent 3a22075c
......@@ -58,7 +58,7 @@ static int process_arp(uint8_t* buf, int len) {
buf[ARP_OPER+0] = 0;
buf[ARP_OPER+1] = 2;
// my MAC+IP
memcpy(buf+ARP_SHA, myMAC, 6);
get_mac_addr(buf+ARP_SHA);
memcpy(buf+ARP_SPA, myIP, 4);
// his MAC+IP
memcpy(buf+ARP_THA, hisMAC, 6);
......
......@@ -28,7 +28,7 @@ void icmp_init(const char* if_name) {
/* Configure socket filter */
memset(&saddr, 0, sizeof(saddr));
strcpy(saddr.if_name, if_name);
memcpy(&saddr.mac, myMAC, 6); /* Unicast */
get_mac_addr(&saddr.mac); /* Unicast */
saddr.ethertype = htons(0x0800); /* IPv4 */
saddr.family = PTPD_SOCK_RAW_ETHERNET;
......
......@@ -3,7 +3,6 @@
#include "endpoint.h"
#include "ipv4.h"
uint8_t myMAC[6];
uint8_t myIP[4];
unsigned int ipv4_checksum(unsigned short* buf, int shorts) {
......@@ -25,7 +24,6 @@ void ipv4_init(const char* if_name, uint32_t ip) {
ip_bigendian = htonl(ip);
memcpy(myIP, &ip_bigendian, 4);
get_mac_addr(myMAC);
arp_init(if_name);
icmp_init(if_name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment