Skip to content
Permalink
Browse files

net: sockets: packet: Register handler for AF_PACKET

Use the automatic registration of AF_PACKET type sockets.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information...
jukkar committed Feb 7, 2019
1 parent 61f4597 commit b3cd478a5f0dd37165f70cef7fd437f7e005b513
@@ -151,12 +151,6 @@ int z_impl_zsock_socket(int family, int type, int proto)
return sock_family->handler(family, type, proto);
}

#if defined(CONFIG_NET_SOCKETS_PACKET)
if (family == AF_PACKET) {
return zpacket_socket(family, type, proto);
}
#endif

#if defined(CONFIG_NET_SOCKETS_CAN)
if (family == AF_CAN) {
return zcan_socket(family, type, proto);
@@ -47,7 +47,6 @@ struct socket_op_vtable {
const void *optval, socklen_t optlen);
};

int zpacket_socket(int family, int type, int proto);
int zcan_socket(int family, int type, int proto);

#endif /* _SOCKETS_INTERNAL_H_ */
@@ -36,17 +36,12 @@ static inline int k_fifo_wait_non_empty(struct k_fifo *fifo, int32_t timeout)
return k_poll(events, ARRAY_SIZE(events), timeout);
}

int zpacket_socket(int family, int type, int proto)
static int zpacket_socket(int family, int type, int proto)
{
struct net_context *ctx;
int fd;
int ret;

if (type != SOCK_RAW || proto != ETH_P_ALL) {
errno = -EOPNOTSUPP;
return -1;
}

fd = z_reserve_fd();
if (fd < 0) {
return -1;
@@ -341,3 +336,14 @@ static const struct socket_op_vtable packet_sock_fd_op_vtable = {
.getsockopt = packet_sock_getsockopt_vmeth,
.setsockopt = packet_sock_setsockopt_vmeth,
};

static bool packet_is_supported(int family, int type, int proto)
{
if (type != SOCK_RAW || proto != ETH_P_ALL) {
return false;
}

return true;
}

NET_SOCKET_REGISTER(af_packet, AF_PACKET, packet_is_supported, zpacket_socket);

0 comments on commit b3cd478

Please sign in to comment.
You can’t perform that action at this time.