mirror of
https://github.com/ep00ch/lwip-contrib-mac.git
synced 2024-07-07 20:29:04 +00:00
Changed MAC address settings of win32 port (MAC address to use has to be defined in lwipcfg_msvc.h)
This commit is contained in:
parent
73f3e94486
commit
2977846356
@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Additional settings for the win32 port.
|
||||
* Copy this to lwipcfg_msvc.h and make the config changes you need.
|
||||
*/
|
||||
|
||||
/* configuration for this port */
|
||||
|
||||
@ -7,6 +11,10 @@
|
||||
#define LWIP_PORT_INIT_GW(addr) IP4_ADDR((addr), 192,168,1,1)
|
||||
#define LWIP_PORT_INIT_NETMASK(addr) IP4_ADDR((addr), 255,255,255,0)
|
||||
|
||||
/* remember to change this MAC address to suit your needs!
|
||||
the last octet will be increased by netif->num for each netif */
|
||||
#define LWIP_MAC_ADDR_BASE {0x00,0x01,0x02,0x03,0x04,0x05}
|
||||
|
||||
/* configuration for applications */
|
||||
|
||||
#define LWIP_DNS_APP 0
|
||||
|
@ -190,7 +190,7 @@ init_adapter(int adapter_num, char *mac_addr, input_fn input, void *arg)
|
||||
ppacket_oid_data->Oid = OID_GEN_VENDOR_DESCRIPTION;
|
||||
ppacket_oid_data->Length = PACKET_OID_DATA_SIZE;
|
||||
if (PacketRequest(pa->lpAdapter, FALSE, ppacket_oid_data)) {
|
||||
printf("USE: %s\n", ppacket_oid_data->Data);
|
||||
printf("USE: %s", ppacket_oid_data->Data);
|
||||
}
|
||||
/* get the MAC address of the selected adapter */
|
||||
ppacket_oid_data->Oid = OID_802_3_PERMANENT_ADDRESS;
|
||||
@ -206,7 +206,7 @@ init_adapter(int adapter_num, char *mac_addr, input_fn input, void *arg)
|
||||
/* copy the MAC address to the user supplied buffer, also */
|
||||
memcpy(mac_addr, ðaddr, ETHARP_HWADDR_LEN);
|
||||
}
|
||||
printf("MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", ethaddr[0], ethaddr[1], ethaddr[2],
|
||||
printf(" [MAC: %02X:%02X:%02X:%02X:%02X:%02X]\n", ethaddr[0], ethaddr[1], ethaddr[2],
|
||||
ethaddr[3], ethaddr[4], ethaddr[5]);
|
||||
/* some more adapter settings */
|
||||
PacketSetBuff(pa->lpAdapter, PACKET_ADAPTER_BUFSIZE);
|
||||
|
@ -115,20 +115,21 @@ void ethernetif_process_input(void *arg, void *packet, int len);
|
||||
static void
|
||||
low_level_init(struct netif *netif)
|
||||
{
|
||||
char mac_addr[ETHARP_HWADDR_LEN];
|
||||
char adapter_mac_addr[ETHARP_HWADDR_LEN];
|
||||
char my_mac_addr[ETHARP_HWADDR_LEN] = LWIP_MAC_ADDR_BASE;
|
||||
|
||||
/* Do whatever else is needed to initialize interface. */
|
||||
if ((netif->state = init_adapter(PACKET_LIB_ADAPTER_NR, mac_addr,
|
||||
if ((netif->state = init_adapter(PACKET_LIB_ADAPTER_NR, adapter_mac_addr,
|
||||
ethernetif_process_input, netif)) == NULL) {
|
||||
printf("ERROR initializing network adapter %d!\n", PACKET_LIB_ADAPTER_NR);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Prepare MAC addr: increase the last octet so that lwIP netif has a similar but different MAC addr */
|
||||
memcpy(&netif->hwaddr, mac_addr, ETHARP_HWADDR_LEN);
|
||||
/* change the MAC address to a unique value
|
||||
so that multiple ethernetifs are supported */
|
||||
netif->hwaddr[ETHARP_HWADDR_LEN - 1] += 1 + netif->num;
|
||||
my_mac_addr[ETHARP_HWADDR_LEN - 1] += netif->num;
|
||||
/* Copy MAC addr */
|
||||
memcpy(&netif->hwaddr, my_mac_addr, ETHARP_HWADDR_LEN);
|
||||
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("pktif: eth_addr %02X%02X%02X%02X%02X%02X\n",netif->hwaddr[0],netif->hwaddr[1],netif->hwaddr[2],netif->hwaddr[3],netif->hwaddr[4],netif->hwaddr[5]));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user