-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: sockets: mgmt: Add AF_NET_MGMT address family support
Allow application to listen network management events using BSD socket API. Application needs to create the socket using AF_NET_MGMT address family. At this point we only support receiving network management events that the network subsystem is sending. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
- Loading branch information
1 parent
02b3826
commit c0d6831
Showing
5 changed files
with
483 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/** @file | ||
* @brief NET_MGMT socket definitions. | ||
* | ||
* Definitions for NET_MGMT socket support. | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2019 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef ZEPHYR_INCLUDE_NET_SOCKET_NET_MGMT_H_ | ||
#define ZEPHYR_INCLUDE_NET_SOCKET_NET_MGMT_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include <zephyr/types.h> | ||
#include <net/net_ip.h> | ||
#include <net/net_if.h> | ||
#include <net/net_mgmt.h> | ||
|
||
/** | ||
* @brief Socket NET_MGMT library | ||
* @defgroup socket_net_mgmt Network Core Library | ||
* @ingroup networking | ||
* @{ | ||
*/ | ||
|
||
/* Protocols of the protocol family PF_NET_MGMT */ | ||
#define NET_MGMT_EVENT_PROTO 0x01 | ||
|
||
/* Socket NET_MGMT options */ | ||
#define SOL_NET_MGMT_BASE 100 | ||
#define SOL_NET_MGMT_RAW (SOL_NET_MGMT_BASE + NET_MGMT_RAW) | ||
|
||
/** | ||
* struct sockaddr_nm - The sockaddr structure for NET_MGMT sockets | ||
* | ||
* Similar concepts are used as in Linux AF_NETLINK. The NETLINK name is not | ||
* used in order to avoid confusion between Zephyr and Linux as the | ||
* implementations are different. | ||
* | ||
* The socket domain (address family) is AF_NET_MGMT, and the type of socket | ||
* is either SOCK_RAW or SOCK_DGRAM, because this is a datagram-oriented | ||
* service. | ||
* | ||
* The protocol (protocol type) selects for which feature the socket is used. | ||
* | ||
* When used with bind(), the nm_pid field of the sockaddr_nm can be | ||
* filled with the calling thread' own id. The nm_pid serves here as the local | ||
* address of this net_mgmt socket. The application is responsible for picking | ||
* a unique 32-bit integer to fill in nm_pid. | ||
*/ | ||
struct sockaddr_nm { | ||
/** AF_NET_MGMT address family. */ | ||
sa_family_t nm_family; | ||
|
||
/** Network interface related to this address */ | ||
int nm_ifindex; | ||
|
||
/** Thread id or similar that is used to separate the different | ||
* sockets. Application can decide how the pid is constructed. | ||
*/ | ||
u32_t nm_pid; | ||
|
||
/** net_mgmt mask */ | ||
u32_t nm_mask; | ||
}; | ||
|
||
|
||
/** | ||
* Each network management message is prefixed with this header. | ||
*/ | ||
struct net_mgmt_msghdr { | ||
/** Network management version */ | ||
u32_t nm_msg_version; | ||
|
||
/** Length of the data */ | ||
u32_t nm_msg_len; | ||
|
||
/** The actual message data follows */ | ||
u8_t nm_msg[]; | ||
}; | ||
|
||
/** | ||
* Version of the message is placed to the header. Currently we have | ||
* following versions. | ||
* | ||
* Network management message versions: | ||
* | ||
* 0x0001 : The net_mgmt event info message follows directly | ||
* after the header. | ||
*/ | ||
#define NET_MGMT_SOCKET_VERSION_1 0x0001 | ||
|
||
/** | ||
* @} | ||
*/ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* ZEPHYR_INCLUDE_NET_SOCKET_NET_MGMT_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.