Visible to Intel only — GUID: mwh1416946958407
Ixiasoft
Visible to Intel only — GUID: mwh1416946958407
Ixiasoft
11.4.3.4.1. Prototype for get_mac_addr()
int get_mac_addr(NET net, unsigned char mac_addr[6]);
You must implement the get_mac_addr() function to assign the MAC address to the mac_addr argument. Leave the net argument untouched.
The prototype for get_mac_addr() is in the header file <iniche path><iniche path>/inc/alt_iniche_dev.h. The NET structure is defined in the <iniche path>/src/h/net.h file.
For demonstration purposes only, the MAC address is stored at address CUSTOM_MAC_ADDR in this example. There is no error checking in this example. In a real application, if there is an error, get_mac_addr() must return -1.
An Implementation of get_mac_addr()
#include <alt_iniche_dev.h>
#include "includes.h"
#include "ipport.h"
#include "tcpport.h"
#include <io.h>
int get_mac_addr(NET net, unsigned char mac_addr[6])
{
int ret_code = -1;
/* Read the 6-byte MAC address from wherever it is stored */
mac_addr[0] = IORD_8DIRECT(CUSTOM_MAC_ADDR, 4);
mac_addr[1] = IORD_8DIRECT(CUSTOM_MAC_ADDR, 5);
mac_addr[2] = IORD_8DIRECT(CUSTOM_MAC_ADDR, 6);
mac_addr[3] = IORD_8DIRECT(CUSTOM_MAC_ADDR, 7);
mac_addr[4] = IORD_8DIRECT(CUSTOM_MAC_ADDR, 8);
mac_addr[5] = IORD_8DIRECT(CUSTOM_MAC_ADDR, 9);
ret_code = ERR_OK;
return ret_code;
}