I am working on a project where we use Enea OSE which is a real time embedded operating system. I guess many of you are not familiar with this OS but I think you could answer my question anyway. I want to send a raw ethernet frame between 2 cards using interface "eth1" which are directly connected to oneanother by an ethernet cable (no switch or anything). The "eth1" interface is not assigned any ip-address.
I can simply declare a socket using
int s = socket(AF_INET, RAW_SOCKET, ...)
I can then bind the socket to the appropriate device interface using:
setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, "eth1", 4);
What my plan was to do, in order to send data from one card to the other, was to manually fill in a ethernet buffer array with the source and destination MAC adresses. Then send the data using sendto(....)
However the sendto routine also requires a sockaddr struct with information:
sendto(int sockfd, const void *buf, size_t len, int flags,
const struct sockaddr *dest_addr, socklen_t addrlen);
In the examples I have found on the internet uses sockaddr_in when the ip adress is known and sockaddr_ll for raw frames. However OSE does not provide the sockaddr_ll struct. However it provides the sockaddr which I dont know if I can use for raw ethernet frames?
struct sockaddr {
unsigned short sa_family; // address family, AF_xxx
char sa_data[14]; // 14 bytes of protocol address
};
I also tried to use NULL, for the sockaddr field when calling sendto(), the send fails. This brings me to my questions(s). Can I use the simple sockaddr struct to fill in the destination MAC-adress without using any IP? How would that look? (I have not seeen any code showing this). Why do we even have to provide a sockaddr struct? Doesn't the ethernet data buffer already contain this information? Finally, is what I am trying to accomplish even possible without assigning ip-addresses for the network devices?
I am aware of what I am trying to do seems peculiar but there is a reason for it :) I would be really glad if you would show me how to accomplish this without having to use the sockaddr_ll struct.