|
Hi again :)
This is great news guys, the Ethernet driver is now able to send and receive Ethernet frames :)
That's basically all we need an Ethernet driver to be able to do !
Multicast isn't implemented, statistics about number of rx and tx framed, errors and collisions are not either yet !
But it does work under qemu and on real hardware on the Milkymist One board :)
I have done a simple sample application that configures the network interface of RTEMS with these settings :
IP address statically set : 192.168.101.100
netmask : 255.255.255.0
Default gateway : 192.168.101.254
So i start the network and just send an UDP packet to 4.2.2.1:1234 with "toto" as payload :)
FYI RTEMS is using the BSD network stack which works really well and has similar functionality than Linux's one. It even has the same "packet structure" idea in order not to copy data over and over when passing a packet from a network stack layer to another (BSD uses struct mbuff and Linux uses struct skbuff)
So the code of the sample looks like that :
char string[] = "toto"; // The string we want to send over the network to 4.2.2.1:1234
struct sockaddr_in farAddr;
int sock, ret;
rtems_bsdnet_initialize_network(); // initializes network stack, network driver and set ip address, default gateway and such
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock == -1)
perror("socket:");
else
printf("socket:OK\n");
memset(&farAddr, 0, sizeof farAddr);
farAddr.sin_addr.s_addr = htonl(inet_addr("4.2.2.1"));
farAddr.sin_port = htons(1234);
farAddr.sin_family = AF_INET;
ret = sendto(sock, string, strlen(string), 0, (struct sockaddr *)&farAddr, sizeof farAddr); // we send the UDP packet to 4.2.2.1:1234
if (ret == -1)
perror("sendto:");
else
printf("sendto:OK\n");
This code is very portable since it uses socket API over BSD network stack, it can run on Linux or BSD (or even MAC OS i guess ...)
The only thing that you would have to remove is the rtems_bsdnet_initialize_network(); since it's not usually the application's job to set-up the network configuration :)
Here is a wireshark capture screenshot of the networking sample application i just described :

Have fun !
|