net: ip: net_context: AF_PACKET/SOCK_RAW/IPPROTO_RAW: set pkt family

Setting a detected packet family (ipv4 or ipv6) in net_context level
instead in lower layers for AF_PACKET/SOCK_RAW/IPPROTO_RAW type sockets
when sending data.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
This commit is contained in:
Jani Hirsimäki 2023-01-04 08:52:27 +02:00 committed by Carles Cufí
commit e92b067b7f
3 changed files with 16 additions and 30 deletions

View file

@ -667,21 +667,6 @@ static int ethernet_send(struct net_if *iface, struct net_pkt *pkt)
net_pkt_lladdr_src(pkt)->len =
sizeof(struct net_eth_addr);
ptype = dst_addr->sll_protocol;
} else if (context && net_context_get_type(context) == SOCK_RAW &&
net_context_get_proto(context) == IPPROTO_RAW) {
char type = (NET_IPV6_HDR(pkt)->vtc & 0xf0);
switch (type) {
case 0x60:
ptype = htons(NET_ETH_PTYPE_IPV6);
break;
case 0x40:
ptype = htons(NET_ETH_PTYPE_IP);
break;
default:
ret = -ENOTSUP;
goto error;
}
} else {
goto send;
}