summaryrefslogtreecommitdiff
path: root/lib/route/link/macsec.c
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2016-12-15 14:41:55 +0100
committerThomas Haller <thaller@redhat.com>2016-12-15 19:41:19 +0100
commit63088d1fef1c7ffc32c2e85f20ab866d401b14f0 (patch)
tree198e416f38b1ab7a689248184a8853025a60188a /lib/route/link/macsec.c
parent729232bec2396e1fa3f6cf8e19d06b109e265526 (diff)
downloadlibnl-63088d1fef1c7ffc32c2e85f20ab866d401b14f0.tar.gz
macsec: document byte order for the SCI and port attributes
Document that the SCI is in network order while the port is in host order. Signed-off-by: Beniamino Galvani <bgalvani@redhat.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib/route/link/macsec.c')
-rw-r--r--lib/route/link/macsec.c64
1 files changed, 63 insertions, 1 deletions
diff --git a/lib/route/link/macsec.c b/lib/route/link/macsec.c
index eccfbfa3..d177236d 100644
--- a/lib/route/link/macsec.c
+++ b/lib/route/link/macsec.c
@@ -9,6 +9,18 @@
* Copyright (c) 2016 Sabrina Dubroca <sd@queasysnail.net>
*/
+/**
+ * @ingroup link
+ * @defgroup macsec MACsec
+ * MACsec link module
+ *
+ * @details
+ * \b Link Type Name: "macsec"
+ *
+ * @route_doc{link_macsec, MACsec Documentation}
+ *
+ * @{
+ */
#include <netlink-private/netlink.h>
#include <netlink/netlink.h>
#include <netlink/attr.h>
@@ -20,6 +32,7 @@
#include <linux/if_macsec.h>
+/** @cond SKIP */
#define MACSEC_ATTR_SCI (1 << 0)
#define MACSEC_ATTR_ICV_LEN (1 << 1)
#define MACSEC_ATTR_CIPHER_SUITE (1 << 2)
@@ -49,6 +62,10 @@ struct macsec_info {
uint32_t ce_mask;
};
+#define DEFAULT_ICV_LEN 16
+
+/** @endcond */
+
static struct nla_policy macsec_policy[IFLA_MACSEC_MAX+1] = {
[IFLA_MACSEC_SCI] = { .type = NLA_U64 },
[IFLA_MACSEC_ICV_LEN] = { .type = NLA_U8 },
@@ -64,8 +81,16 @@ static struct nla_policy macsec_policy[IFLA_MACSEC_MAX+1] = {
[IFLA_MACSEC_VALIDATION] = { .type = NLA_U8 },
};
-#define DEFAULT_ICV_LEN 16
+/**
+ * @name MACsec Object
+ * @{
+ */
+/**
+ * Allocate link object of type MACsec
+ *
+ * @return Allocated link object or NULL.
+ */
static int macsec_alloc(struct rtnl_link *link)
{
struct macsec_info *info;
@@ -195,7 +220,9 @@ static char *replay_protect_str(char *buf, uint8_t replay_protect, uint8_t windo
return buf;
}
+/** @cond SKIP */
#define PRINT_FLAG(buf, i, field, c) ({ if (i->field == 1) *buf++ = c; })
+/** @endcond */
static char *flags_str(char *buf, unsigned char len, struct macsec_info *info)
{
char *tmp = buf;
@@ -387,11 +414,13 @@ static void __exit macsec_exit(void)
rtnl_link_unregister_info(&macsec_info_ops);
}
+/** @cond SKIP */
#define IS_MACSEC_LINK_ASSERT(link) \
if ((link)->l_info_ops != &macsec_info_ops) { \
APPBUG("Link is not a MACsec link. set type \"macsec\" first."); \
return -NLE_OPNOTSUPP; \
}
+/** @endcond */
struct rtnl_link *rtnl_link_macsec_alloc(void)
{
@@ -408,6 +437,13 @@ struct rtnl_link *rtnl_link_macsec_alloc(void)
return link;
}
+/**
+ * Set SCI
+ * @arg link Link object
+ * @arg sci Secure Channel Identifier in network byte order
+ *
+ * @return 0 on success or a negative error code.
+ */
int rtnl_link_macsec_set_sci(struct rtnl_link *link, uint64_t sci)
{
struct macsec_info *info = link->l_info;
@@ -420,6 +456,14 @@ int rtnl_link_macsec_set_sci(struct rtnl_link *link, uint64_t sci)
return 0;
}
+/**
+ * Get SCI
+ * @arg link Link object
+ * @arg sci On return points to the Secure Channel Identifier
+ * in network byte order
+ *
+ * @return 0 on success or a negative error code.
+ */
int rtnl_link_macsec_get_sci(struct rtnl_link *link, uint64_t *sci)
{
struct macsec_info *info = link->l_info;
@@ -435,6 +479,13 @@ int rtnl_link_macsec_get_sci(struct rtnl_link *link, uint64_t *sci)
return 0;
}
+/**
+ * Set port identifier
+ * @arg link Link object
+ * @arg port Port identifier in host byte order
+ *
+ * @return 0 on success or a negative error code.
+ */
int rtnl_link_macsec_set_port(struct rtnl_link *link, uint16_t port)
{
struct macsec_info *info = link->l_info;
@@ -447,6 +498,13 @@ int rtnl_link_macsec_set_port(struct rtnl_link *link, uint16_t port)
return 0;
}
+/**
+ * Get port identifier
+ * @arg link Link object
+ * @arg port On return points to the port identifier in host byte order
+ *
+ * @return 0 on success or a negative error code.
+ */
int rtnl_link_macsec_get_port(struct rtnl_link *link, uint16_t *port)
{
struct macsec_info *info = link->l_info;
@@ -785,3 +843,7 @@ int rtnl_link_macsec_get_scb(struct rtnl_link *link, uint8_t *scb)
return 0;
}
+
+/** @} */
+
+/** @} */