From edd5cf1a3ca5cf43955976bb83d9fcc142969a55 Mon Sep 17 00:00:00 2001 From: Javier Arteaga Date: Sat, 28 Jul 2018 14:54:33 +0200 Subject: [PATCH] platform: rename instances of Wireguard to WireGuard Respect WireGuard canonical capitalization on identifiers. As per discussion on: https://github.com/NetworkManager/NetworkManager/pull/162 --- libnm-core/nm-core-types-internal.h | 6 +++--- src/platform/nm-linux-platform.c | 30 ++++++++++++++--------------- src/platform/nm-platform.c | 12 ++++++------ src/platform/nm-platform.h | 12 ++++++------ src/platform/nmp-object.c | 28 +++++++++++++-------------- src/platform/nmp-object.h | 10 +++++----- 6 files changed, 49 insertions(+), 49 deletions(-) diff --git a/libnm-core/nm-core-types-internal.h b/libnm-core/nm-core-types-internal.h index d7dce9521e..7ab0f59455 100644 --- a/libnm-core/nm-core-types-internal.h +++ b/libnm-core/nm-core-types-internal.h @@ -35,7 +35,7 @@ typedef struct { NMIPAddr ip; guint8 family; guint8 mask; -} NMWireguardAllowedIP; +} NMWireGuardAllowedIP; #define NM_WG_PUBLIC_KEY_LEN 32 #define NM_WG_SYMMETRIC_KEY_LEN 32 @@ -53,8 +53,8 @@ typedef struct { guint64 rx_bytes, tx_bytes; gsize allowedips_len; - NMWireguardAllowedIP *allowedips; -} NMWireguardPeer; + NMWireGuardAllowedIP *allowedips; +} NMWireGuardPeer; #define _NM_IP_TUNNEL_FLAG_ALL_IP6TNL \ ( NM_IP_TUNNEL_FLAG_IP6_IGN_ENCAP_LIMIT \ diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 42bde9dbd0..fd0210bb0d 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -1847,7 +1847,7 @@ _parse_lnk_vxlan (const char *kind, struct nlattr *info_data) /*****************************************************************************/ -/* Context to build a NMPObjectLnkWireguard instance. +/* Context to build a NMPObjectLnkWireGuard instance. * GArray wrappers are discarded after processing all netlink messages. */ struct _wireguard_device_buf { NMPObject *obj; @@ -1865,9 +1865,9 @@ _wireguard_update_from_allowedips_nla (struct _wireguard_device_buf *buf, [WGALLOWEDIP_A_CIDR_MASK] = { .type = NLA_U8 }, }; struct nlattr *tba[WGALLOWEDIP_A_MAX + 1]; - NMWireguardPeer *peer = &g_array_index (buf->peers, NMWireguardPeer, buf->peers->len - 1); - NMWireguardAllowedIP *allowedip; - NMWireguardAllowedIP new_allowedip = {0}; + NMWireGuardPeer *peer = &g_array_index (buf->peers, NMWireGuardPeer, buf->peers->len - 1); + NMWireGuardAllowedIP *allowedip; + NMWireGuardAllowedIP new_allowedip = {0}; int addr_len; int ret; @@ -1876,7 +1876,7 @@ _wireguard_update_from_allowedips_nla (struct _wireguard_device_buf *buf, goto errout; g_array_append_val (buf->allowedips, new_allowedip); - allowedip = &g_array_index (buf->allowedips, NMWireguardAllowedIP, buf->allowedips->len - 1); + allowedip = &g_array_index (buf->allowedips, NMWireGuardAllowedIP, buf->allowedips->len - 1); peer->allowedips_len++; if (tba[WGALLOWEDIP_A_FAMILY]) @@ -1920,9 +1920,9 @@ _wireguard_update_from_peers_nla (struct _wireguard_device_buf *buf, [WGPEER_A_ALLOWEDIPS] = { .type = NLA_NESTED }, }; struct nlattr *tbp[WGPEER_A_MAX + 1]; - NMWireguardPeer * const last = buf->peers->len ? &g_array_index (buf->peers, NMWireguardPeer, buf->peers->len - 1) : NULL; - NMWireguardPeer *peer; - NMWireguardPeer new_peer = {0}; + NMWireGuardPeer * const last = buf->peers->len ? &g_array_index (buf->peers, NMWireGuardPeer, buf->peers->len - 1) : NULL; + NMWireGuardPeer *peer; + NMWireGuardPeer new_peer = {0}; int ret; if (nla_parse_nested (tbp, WGPEER_A_MAX, peer_attr, peer_policy)) { @@ -1943,7 +1943,7 @@ _wireguard_update_from_peers_nla (struct _wireguard_device_buf *buf, /* otherwise, start a new peer */ g_array_append_val (buf->peers, new_peer); - peer = &g_array_index (buf->peers, NMWireguardPeer, buf->peers->len - 1); + peer = &g_array_index (buf->peers, NMWireGuardPeer, buf->peers->len - 1); nla_memcpy (&peer->public_key, tbp[WGPEER_A_PUBLIC_KEY], sizeof (peer->public_key)); @@ -2000,7 +2000,7 @@ _wireguard_get_device_cb (struct nl_msg *msg, void *arg) }; struct _wireguard_device_buf *buf = arg; struct nlattr *tbd[WGDEVICE_A_MAX + 1]; - NMPlatformLnkWireguard *props = &buf->obj->lnk_wireguard; + NMPlatformLnkWireGuard *props = &buf->obj->lnk_wireguard; struct nlmsghdr *nlh = nlmsg_hdr (msg); int ret; @@ -6513,8 +6513,8 @@ _wireguard_get_link_properties (NMPlatform *platform, const NMPlatformLink *link nm_auto_nlmsg struct nl_msg *msg = NULL; struct _wireguard_device_buf buf = { .obj = obj, - .peers = g_array_new (FALSE, FALSE, sizeof (NMWireguardPeer)), - .allowedips = g_array_new (FALSE, FALSE, sizeof (NMWireguardAllowedIP)), + .peers = g_array_new (FALSE, FALSE, sizeof (NMWireGuardPeer)), + .allowedips = g_array_new (FALSE, FALSE, sizeof (NMWireGuardAllowedIP)), }; struct nl_cb cb = { .valid_cb = _wireguard_get_device_cb, @@ -6548,15 +6548,15 @@ _wireguard_get_link_properties (NMPlatform *platform, const NMPlatformLink *link /* have each peer point to its own chunk of the allowedips buffer */ for (i = 0, j = 0; i < buf.peers->len; i++) { - NMWireguardPeer *p = &g_array_index (buf.peers, NMWireguardPeer, i); - p->allowedips = &g_array_index (buf.allowedips, NMWireguardAllowedIP, j); + NMWireGuardPeer *p = &g_array_index (buf.peers, NMWireGuardPeer, i); + p->allowedips = &g_array_index (buf.allowedips, NMWireGuardAllowedIP, j); j += p->allowedips_len; } /* drop the wrapper (but also the buffer if no peer points to it) */ g_array_free (buf.allowedips, buf.peers->len ? FALSE : TRUE); obj->_lnk_wireguard.peers_len = buf.peers->len; - obj->_lnk_wireguard.peers = (NMWireguardPeer *) g_array_free (buf.peers, FALSE); + obj->_lnk_wireguard.peers = (NMWireGuardPeer *) g_array_free (buf.peers, FALSE); return TRUE; diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 174d863637..22af971505 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -1968,7 +1968,7 @@ nm_platform_link_get_lnk_vxlan (NMPlatform *self, int ifindex, const NMPlatformL return _link_get_lnk (self, ifindex, NM_LINK_TYPE_VXLAN, out_link); } -const NMPlatformLnkWireguard * +const NMPlatformLnkWireGuard * nm_platform_link_get_lnk_wireguard (NMPlatform *self, int ifindex, const NMPlatformLink **out_link) { return _link_get_lnk (self, ifindex, NM_LINK_TYPE_WIREGUARD, out_link); @@ -5506,7 +5506,7 @@ nm_platform_lnk_vxlan_to_string (const NMPlatformLnkVxlan *lnk, char *buf, gsize } const char * -nm_platform_wireguard_peer_to_string (const NMWireguardPeer *peer, char *buf, gsize len) +nm_platform_wireguard_peer_to_string (const NMWireGuardPeer *peer, char *buf, gsize len) { gs_free char *public_b64 = NULL; char s_address[INET6_ADDRSTRLEN] = {0}; @@ -5555,7 +5555,7 @@ nm_platform_wireguard_peer_to_string (const NMWireguardPeer *peer, char *buf, gs for (i = 0; i < peer->allowedips_len; i++) { - NMWireguardAllowedIP *allowedip = &peer->allowedips[i]; + NMWireGuardAllowedIP *allowedip = &peer->allowedips[i]; const char *ret; ret = inet_ntop (allowedip->family, &allowedip->ip, s_address, sizeof(s_address)); @@ -5571,7 +5571,7 @@ nm_platform_wireguard_peer_to_string (const NMWireguardPeer *peer, char *buf, gs } const char * -nm_platform_lnk_wireguard_to_string (const NMPlatformLnkWireguard *lnk, char *buf, gsize len) +nm_platform_lnk_wireguard_to_string (const NMPlatformLnkWireGuard *lnk, char *buf, gsize len) { gs_free char *public_b64 = NULL; guint8 nonzero_key = 0; @@ -6489,7 +6489,7 @@ nm_platform_lnk_vxlan_cmp (const NMPlatformLnkVxlan *a, const NMPlatformLnkVxlan } void -nm_platform_lnk_wireguard_hash_update (const NMPlatformLnkWireguard *obj, NMHashState *h) +nm_platform_lnk_wireguard_hash_update (const NMPlatformLnkWireGuard *obj, NMHashState *h) { nm_hash_update_vals (h, obj->listen_port, @@ -6499,7 +6499,7 @@ nm_platform_lnk_wireguard_hash_update (const NMPlatformLnkWireguard *obj, NMHash } int -nm_platform_lnk_wireguard_cmp (const NMPlatformLnkWireguard *a, const NMPlatformLnkWireguard *b) +nm_platform_lnk_wireguard_cmp (const NMPlatformLnkWireGuard *a, const NMPlatformLnkWireGuard *b) { NM_CMP_SELF (a, b); NM_CMP_FIELD (a, b, listen_port); diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 7e49e064a9..bbc9fccabc 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -757,7 +757,7 @@ typedef struct { guint8 public_key[NM_WG_PUBLIC_KEY_LEN]; guint16 listen_port; guint32 fwmark; -} NMPlatformLnkWireguard; +} NMPlatformLnkWireGuard; typedef enum { NM_PLATFORM_LINK_DUPLEX_UNKNOWN, @@ -1254,7 +1254,7 @@ const NMPlatformLnkSit *nm_platform_link_get_lnk_sit (NMPlatform *self, int ifin const NMPlatformLnkTun *nm_platform_link_get_lnk_tun (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); const NMPlatformLnkVlan *nm_platform_link_get_lnk_vlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); const NMPlatformLnkVxlan *nm_platform_link_get_lnk_vxlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); -const NMPlatformLnkWireguard *nm_platform_link_get_lnk_wireguard (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); +const NMPlatformLnkWireGuard *nm_platform_link_get_lnk_wireguard (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); NMPlatformError nm_platform_link_vlan_add (NMPlatform *self, const char *name, @@ -1449,7 +1449,7 @@ const char *nm_platform_lnk_sit_to_string (const NMPlatformLnkSit *lnk, char *bu const char *nm_platform_lnk_tun_to_string (const NMPlatformLnkTun *lnk, char *buf, gsize len); const char *nm_platform_lnk_vlan_to_string (const NMPlatformLnkVlan *lnk, char *buf, gsize len); const char *nm_platform_lnk_vxlan_to_string (const NMPlatformLnkVxlan *lnk, char *buf, gsize len); -const char *nm_platform_lnk_wireguard_to_string (const NMPlatformLnkWireguard *lnk, char *buf, gsize len); +const char *nm_platform_lnk_wireguard_to_string (const NMPlatformLnkWireGuard *lnk, char *buf, gsize len); const char *nm_platform_ip4_address_to_string (const NMPlatformIP4Address *address, char *buf, gsize len); const char *nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address, char *buf, gsize len); const char *nm_platform_ip4_route_to_string (const NMPlatformIP4Route *route, char *buf, gsize len); @@ -1464,7 +1464,7 @@ const char *nm_platform_vlan_qos_mapping_to_string (const char *name, char *buf, gsize len); -const char *nm_platform_wireguard_peer_to_string (const NMWireguardPeer *peer, +const char *nm_platform_wireguard_peer_to_string (const NMWireGuardPeer *peer, char *buf, gsize len); @@ -1479,7 +1479,7 @@ int nm_platform_lnk_sit_cmp (const NMPlatformLnkSit *a, const NMPlatformLnkSit * int nm_platform_lnk_tun_cmp (const NMPlatformLnkTun *a, const NMPlatformLnkTun *b); int nm_platform_lnk_vlan_cmp (const NMPlatformLnkVlan *a, const NMPlatformLnkVlan *b); int nm_platform_lnk_vxlan_cmp (const NMPlatformLnkVxlan *a, const NMPlatformLnkVxlan *b); -int nm_platform_lnk_wireguard_cmp (const NMPlatformLnkWireguard *a, const NMPlatformLnkWireguard *b); +int nm_platform_lnk_wireguard_cmp (const NMPlatformLnkWireGuard *a, const NMPlatformLnkWireGuard *b); int nm_platform_ip4_address_cmp (const NMPlatformIP4Address *a, const NMPlatformIP4Address *b); int nm_platform_ip6_address_cmp (const NMPlatformIP6Address *a, const NMPlatformIP6Address *b); @@ -1516,7 +1516,7 @@ void nm_platform_lnk_sit_hash_update (const NMPlatformLnkSit *obj, NMHashState * void nm_platform_lnk_tun_hash_update (const NMPlatformLnkTun *obj, NMHashState *h); void nm_platform_lnk_vlan_hash_update (const NMPlatformLnkVlan *obj, NMHashState *h); void nm_platform_lnk_vxlan_hash_update (const NMPlatformLnkVxlan *obj, NMHashState *h); -void nm_platform_lnk_wireguard_hash_update (const NMPlatformLnkWireguard *obj, NMHashState *h); +void nm_platform_lnk_wireguard_hash_update (const NMPlatformLnkWireGuard *obj, NMHashState *h); void nm_platform_qdisc_hash_update (const NMPlatformQdisc *obj, NMHashState *h); void nm_platform_tfilter_hash_update (const NMPlatformTfilter *obj, NMHashState *h); diff --git a/src/platform/nmp-object.c b/src/platform/nmp-object.c index fa84b4edce..431fc2b124 100644 --- a/src/platform/nmp-object.c +++ b/src/platform/nmp-object.c @@ -348,14 +348,14 @@ _vlan_xgress_qos_mappings_cpy (guint *dst_n_map, static void _wireguard_peers_hash_update (gsize n_peers, - const NMWireguardPeer *peers, + const NMWireGuardPeer *peers, NMHashState *h) { gsize i, j; nm_hash_update_val (h, n_peers); for (i = 0; i < n_peers; i++) { - const NMWireguardPeer *p = &peers[i]; + const NMWireGuardPeer *p = &peers[i]; nm_hash_update (h, p->public_key, sizeof (p->public_key)); nm_hash_update (h, p->preshared_key, sizeof (p->preshared_key)); @@ -376,7 +376,7 @@ _wireguard_peers_hash_update (gsize n_peers, g_assert_not_reached (); for (j = 0; j < p->allowedips_len; j++) { - const NMWireguardAllowedIP *ip = &p->allowedips[j]; + const NMWireGuardAllowedIP *ip = &p->allowedips[j]; nm_hash_update_vals (h, ip->family, ip->mask); @@ -392,14 +392,14 @@ _wireguard_peers_hash_update (gsize n_peers, static int _wireguard_peers_cmp (gsize n_peers, - const NMWireguardPeer *p1, - const NMWireguardPeer *p2) + const NMWireGuardPeer *p1, + const NMWireGuardPeer *p2) { gsize i, j; for (i = 0; i < n_peers; i++) { - const NMWireguardPeer *a = &p1[i]; - const NMWireguardPeer *b = &p2[i]; + const NMWireGuardPeer *a = &p1[i]; + const NMWireGuardPeer *b = &p2[i]; NM_CMP_FIELD (a, b, last_handshake_time.tv_sec); NM_CMP_FIELD (a, b, last_handshake_time.tv_nsec); @@ -419,8 +419,8 @@ _wireguard_peers_cmp (gsize n_peers, g_assert_not_reached (); for (j = 0; j < a->allowedips_len; j++) { - const NMWireguardAllowedIP *aip = &a->allowedips[j]; - const NMWireguardAllowedIP *bip = &b->allowedips[j]; + const NMWireGuardAllowedIP *aip = &a->allowedips[j]; + const NMWireGuardAllowedIP *bip = &b->allowedips[j]; NM_CMP_FIELD (aip, bip, family); NM_CMP_FIELD (aip, bip, mask); @@ -439,9 +439,9 @@ _wireguard_peers_cmp (gsize n_peers, static void _wireguard_peers_cpy (gsize *dst_n_peers, - NMWireguardPeer **dst_peers, + NMWireGuardPeer **dst_peers, gsize src_n_peers, - const NMWireguardPeer *src_peers) + const NMWireGuardPeer *src_peers) { if (src_n_peers == 0) { g_clear_pointer (dst_peers, g_free); @@ -876,7 +876,7 @@ _vt_cmd_obj_to_string_lnk_wireguard (const NMPObject *obj, NMPObjectToStringMode obj->_lnk_wireguard.peers_len); for (i = 0; i < obj->_lnk_wireguard.peers_len; i++) { - const NMWireguardPeer *peer = &obj->_lnk_wireguard.peers[i]; + const NMWireGuardPeer *peer = &obj->_lnk_wireguard.peers[i]; nm_platform_wireguard_peer_to_string (peer, b, buf_size); l = strlen (b); b += l; @@ -3066,8 +3066,8 @@ const NMPClass _nmp_classes[NMP_OBJECT_TYPE_MAX] = { [NMP_OBJECT_TYPE_LNK_WIREGUARD - 1] = { .parent = DEDUP_MULTI_OBJ_CLASS_INIT(), .obj_type = NMP_OBJECT_TYPE_LNK_WIREGUARD, - .sizeof_data = sizeof (NMPObjectLnkWireguard), - .sizeof_public = sizeof (NMPlatformLnkWireguard), + .sizeof_data = sizeof (NMPObjectLnkWireGuard), + .sizeof_public = sizeof (NMPlatformLnkWireGuard), .obj_type_name = "wireguard", .lnk_link_type = NM_LINK_TYPE_WIREGUARD, .cmd_obj_hash_update = _vt_cmd_obj_hash_update_lnk_wireguard, diff --git a/src/platform/nmp-object.h b/src/platform/nmp-object.h index 2923708f15..ba63a3a34e 100644 --- a/src/platform/nmp-object.h +++ b/src/platform/nmp-object.h @@ -219,11 +219,11 @@ typedef struct { } NMPObjectLnkVxlan; typedef struct { - NMPlatformLnkWireguard _public; + NMPlatformLnkWireGuard _public; gsize peers_len; - NMWireguardPeer *peers; -} NMPObjectLnkWireguard; + NMWireGuardPeer *peers; +} NMPObjectLnkWireGuard; typedef struct { NMPlatformIP4Address _public; @@ -290,8 +290,8 @@ struct _NMPObject { NMPlatformLnkVxlan lnk_vxlan; NMPObjectLnkVxlan _lnk_vxlan; - NMPlatformLnkWireguard lnk_wireguard; - NMPObjectLnkWireguard _lnk_wireguard; + NMPlatformLnkWireGuard lnk_wireguard; + NMPObjectLnkWireGuard _lnk_wireguard; NMPlatformIPAddress ip_address; NMPlatformIPXAddress ipx_address;