Hi Richard,
To receive Ethernet frames with a specific Ether Type you have to register this protocol type on an Ethernet channel using the ENET_open function. Example:
if ((ENET_open((RTCS_get_enet_handle (MQX1588_ihandle)), 0x88F7, MQX1588_Recv_L2_1588, MQX1588_ihandle)) != ENET_OK)
{
TGT_printf("Registering an EtherType value for IEEE 1588 (0x88 0xF7) protocol failed.\n");
}
--------------------------------------------------
MQX1588_Recv_L2_1588 function then handles all received Eth. frames with 0x88F7 type.
As for sending, you have to create the frame (DST_MAC, SRC_MAC, EthType, Data) first, then create the pcb and finally use ENET_send_raw function for sending the packet. Example:
typedef struct {
uint_8 DST[6];
uint_8 SRC[6];
uint_8 ETHTYPE[2];
uint_8 DATA[50];
} FRAME, * FRAME_PTR;
--------------------------------------
PCB_PTR pcb_ptr;
uchar_ptr mem_ptr;
FRAME_PTR packet_ptr;
mem_ptr = _mem_alloc_zero(sizeof(PCB)+sizeof(PCB_FRAGMENT)+sizeof(FRAME));
if (mem_ptr==NULL) {
return FALSE;
}
pcb_ptr = (PCB_PTR) mem_ptr;
packet_ptr = (FRAME_PTR)&mem_ptr[sizeof(PCB)+sizeof(PCB_FRAGMENT)];
memcpy( phy_packet_ptr->DST [0], MY_FRAME, sizeof(MY_FRAME));
pcb_ptr->FREE = free_pcb;
pcb_ptr->FRAG[0].LENGTH = sizeof(FRAME);
pcb_ptr->FRAG[0].FRAGMENT = (uchar_ptr)packet_ptr;
if((ENET_send_raw(RTCS_get_enet_handle (ipcfg_get_ihandle(portHandle->device_number)), pcb_ptr)) == ENET_OK)
return TRUE;
else
return FALSE;
------------------------------------------
Regards
MichalP