mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
socket: added some checks for the local and remote addresses
This commit is contained in:
parent
8cab5cde96
commit
2651181900
1 changed files with 16 additions and 0 deletions
|
@ -155,6 +155,22 @@ int socket_start(struct node *n)
|
|||
struct sockaddr_in *sin = (struct sockaddr_in *) &s->local;
|
||||
struct sockaddr_ll *sll = (struct sockaddr_ll *) &s->local;
|
||||
int ret;
|
||||
|
||||
/* Some checks on the addresses */
|
||||
if (s->local.sa.sa_family != s->remote.sa.sa_family)
|
||||
error("Address families of local and remote must match!");
|
||||
|
||||
if (s->layer == SOCKET_LAYER_IP) {
|
||||
if (ntohs(s->local.sin.sin_port) != ntohs(s->remote.sin.sin_port))
|
||||
error("IP protocol numbers of local and remote must match!");
|
||||
}
|
||||
else if(s->layer == SOCKET_LAYER_ETH) {
|
||||
if (ntohs(s->local.sll.sll_protocol) != ntohs(s->remote.sll.sll_protocol))
|
||||
error("Ethertypes of local and remote must match!");
|
||||
|
||||
if (ntohs(s->local.sll.sll_protocol) <= 0x5DC)
|
||||
error("Ethertype must be large than %d or it is interpreted as an IEEE802.3 length field!", 0x5DC);
|
||||
}
|
||||
|
||||
/* Create socket */
|
||||
switch (s->layer) {
|
||||
|
|
Loading…
Add table
Reference in a new issue