diff options
| author | Michael Biebl <biebl@debian.org> | 2016-04-12 17:33:05 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2016-04-12 17:33:05 +0200 |
| commit | 288a08a3672a89a9bfdb8354b6863cc039759fc2 (patch) | |
| tree | 351ac159de25507ba7eeab003153dabb1c6652a2 /shared | |
| parent | 2bfb3eb7d0323e69affca154395f51d8b577414d (diff) | |
Imported Upstream version 1.1.94 upstream/1.1.94
Diffstat (limited to 'shared')
| -rw-r--r-- | shared/nm-macros-internal.h | 4 | ||||
| -rw-r--r-- | shared/nm-test-utils.h | 75 | ||||
| -rw-r--r-- | shared/nm-version-macros.h | 2 |
3 files changed, 79 insertions, 2 deletions
diff --git a/shared/nm-macros-internal.h b/shared/nm-macros-internal.h index 41762318..384bca66 100644 --- a/shared/nm-macros-internal.h +++ b/shared/nm-macros-internal.h @@ -26,7 +26,9 @@ /********************************************************/ -#define nm_auto(fcn) __attribute ((cleanup(fcn))) +#define _nm_packed __attribute__ ((packed)) + +#define nm_auto(fcn) __attribute__ ((cleanup(fcn))) /** * nm_auto_free: diff --git a/shared/nm-test-utils.h b/shared/nm-test-utils.h index 25032457..b792a69c 100644 --- a/shared/nm-test-utils.h +++ b/shared/nm-test-utils.h @@ -782,6 +782,34 @@ nmtst_get_rand_int (void) return g_rand_int (nmtst_get_rand ()); } +inline static gpointer +nmtst_rand_buf (GRand *rand, gpointer buffer, gsize buffer_length) +{ + guint32 v; + guint8 *b = buffer; + + if (!buffer_length) + return buffer; + + g_assert (buffer); + + if (!rand) + rand = nmtst_get_rand (); + + for (; buffer_length >= sizeof (guint32); buffer_length -= sizeof (guint32), b += sizeof (guint32)) { + v = g_rand_int (rand); + memcpy (b, &v, sizeof (guint32)); + } + if (buffer_length > 0) { + v = g_rand_int (rand); + do { + *(b++) = v & 0xFF; + v >>= 8; + } while (--buffer_length > 0); + } + return buffer; +} + inline static void * nmtst_rand_perm (GRand *rand, void *dst, const void *src, gsize elmt_size, gsize n_elmt) { @@ -1151,11 +1179,54 @@ _nmtst_assert_resolve_relative_path_equals (const char *f1, const char *f2, cons #ifdef __NETWORKMANAGER_PLATFORM_H__ +inline static NMPlatformIP4Address * +nmtst_platform_ip4_address (const char *address, const char *peer_address, guint plen) +{ + static NMPlatformIP4Address addr; + + g_assert (plen <= 32); + + memset (&addr, 0, sizeof (addr)); + addr.address = nmtst_inet4_from_string (address); + if (peer_address) + addr.peer_address = nmtst_inet4_from_string (peer_address); + else + addr.peer_address = addr.address; + addr.plen = plen; + + return &addr; +} + +inline static NMPlatformIP4Address * +nmtst_platform_ip4_address_full (const char *address, const char *peer_address, guint plen, + int ifindex, NMIPConfigSource source, guint32 timestamp, + guint32 lifetime, guint32 preferred, guint32 flags, + const char *label) +{ + NMPlatformIP4Address *addr = nmtst_platform_ip4_address (address, peer_address, plen); + + G_STATIC_ASSERT (IFNAMSIZ == sizeof (addr->label)); + g_assert (!label || strlen (label) < IFNAMSIZ); + + addr->ifindex = ifindex; + addr->source = source; + addr->timestamp = timestamp; + addr->lifetime = lifetime; + addr->preferred = preferred; + addr->n_ifa_flags = flags; + if (label) + g_strlcpy (addr->label, label, sizeof (addr->label)); + + return addr; +} + inline static NMPlatformIP6Address * nmtst_platform_ip6_address (const char *address, const char *peer_address, guint plen) { static NMPlatformIP6Address addr; + g_assert (plen <= 128); + memset (&addr, 0, sizeof (addr)); addr.address = *nmtst_inet6_from_string (address); addr.peer_address = *nmtst_inet6_from_string (peer_address); @@ -1186,6 +1257,8 @@ nmtst_platform_ip4_route (const char *network, guint plen, const char *gateway) { static NMPlatformIP4Route route; + g_assert (plen <= 32); + memset (&route, 0, sizeof (route)); route.network = nmtst_inet4_from_string (network); route.plen = plen; @@ -1218,6 +1291,8 @@ nmtst_platform_ip6_route (const char *network, guint plen, const char *gateway) { static NMPlatformIP6Route route; + nm_assert (plen <= 128); + memset (&route, 0, sizeof (route)); route.network = *nmtst_inet6_from_string (network); route.plen = plen; diff --git a/shared/nm-version-macros.h b/shared/nm-version-macros.h index 8ac9b12a..b96b6c87 100644 --- a/shared/nm-version-macros.h +++ b/shared/nm-version-macros.h @@ -45,7 +45,7 @@ * Evaluates to the micro version number of NetworkManager which this source * compiled against. */ -#define NM_MICRO_VERSION (93) +#define NM_MICRO_VERSION (94) /** * NM_CHECK_VERSION: |