Dear Zilog users.
Just yesterday I was in need to perform raw socket programming with the Zilog ZTP (version 2.3.3 on a eZ80F91).
I was thinking it would have been a very time consuming task and possibly requiring complicated recompilations of the kernel.
In the end I was succesful after modyfying a few lines of user code, so I am posting here in case anybody else could need to accomplish a similar task.
Please not that this is just my solution. If anybody from zilog would comment or give suggestions it woul be helpful.
My objective was to listen to a particular multicast ethernet frame and to send a raw multicast frame.
1. add custom multicast address filter with
| Code: |
EthMAddFunc("x01x80xC2x00x00x02"); // slow protocols
|
This configures the eZ80 to accept qualified multicast frames and enable the hash bit of the specified mac address.
2. parse incoming messages in function RxFunc called by the ethernet driver
| Code: |
/* Eventually parse raw ethernet packets */
if (pep)
{
UINT8 *buf = (UINT8 *) &pep->ethPktHeader;
if (memcmp(&buf[12], "x88x09", 2) == 0)
esmc_handler(buf);
}
|
I have put the code above just before inserting the packet in the Ethernet queue for normal processing.
In this way I have full access over the raw data.
3. send raw ethernet packets when needed
| Code: |
pkt = (unsigned char *) _eth_formatpacket ((eth_address *)dest, 0x0988, 0);
memcpy(pkt, ...);
_eth_send(50, 0);
|
Please note that the packet to be sent starts from offset 14, since the ethernet header is filled by the _eth_formatpacket function.
Cheers.
Giulio