Blame src/devices/tests/test-lldp.c

Packit Service 87a54e
/* SPDX-License-Identifier: GPL-2.0-or-later */
Packit 5756e2
/*
Packit 5756e2
 * Copyright (C) 2015 Red Hat, Inc.
Packit 5756e2
 */
Packit 5756e2
Packit 5756e2
#include "nm-default.h"
Packit 5756e2
Packit 5756e2
#include <fcntl.h>
Packit Service 87a54e
#include <netinet/if_ether.h>
Packit 5756e2
#include <linux/if_tun.h>
Packit 5756e2
#include <sys/ioctl.h>
Packit 5756e2
#include <sys/stat.h>
Packit 5756e2
#include <sys/types.h>
Packit 5756e2
Packit 5756e2
#include "devices/nm-lldp-listener.h"
Packit 5756e2
#include "systemd/nm-sd.h"
Packit 5756e2
Packit 5756e2
#include "platform/tests/test-common.h"
Packit 5756e2
Packit 5756e2
#include "nm-test-utils-core.h"
Packit 5756e2
Packit 5756e2
/*****************************************************************************/
Packit 5756e2
Packit 5756e2
static GVariant *
Packit Service a1bd4f
get_lldp_neighbor(GVariant *  neighbors,
Packit Service a1bd4f
                  int         chassis_id_type,
Packit Service a1bd4f
                  const char *chassis_id,
Packit Service a1bd4f
                  int         port_id_type,
Packit Service a1bd4f
                  const char *port_id)
Packit 5756e2
{
Packit Service a1bd4f
    GVariantIter iter;
Packit Service a1bd4f
    GVariant *   variant;
Packit Service a1bd4f
    GVariant *   result = NULL;
Packit Service a1bd4f
Packit Service a1bd4f
    nmtst_assert_variant_is_of_type(neighbors, G_VARIANT_TYPE("aa{sv}"));
Packit Service a1bd4f
Packit Service a1bd4f
    g_assert(chassis_id_type >= -1 && chassis_id_type <= G_MAXUINT8);
Packit Service a1bd4f
    g_assert(port_id_type >= -1 && port_id_type <= G_MAXUINT8);
Packit Service a1bd4f
Packit Service a1bd4f
    g_variant_iter_init(&iter, neighbors);
Packit Service a1bd4f
    while (g_variant_iter_next(&iter, "@a{sv}", &variant)) {
Packit Service a1bd4f
        gs_unref_variant GVariant *v_chassis_id_type = NULL;
Packit Service a1bd4f
        gs_unref_variant GVariant *v_chassis_id      = NULL;
Packit Service a1bd4f
        gs_unref_variant GVariant *v_port_id_type    = NULL;
Packit Service a1bd4f
        gs_unref_variant GVariant *v_port_id         = NULL;
Packit Service a1bd4f
Packit Service a1bd4f
        v_chassis_id_type =
Packit Service a1bd4f
            g_variant_lookup_value(variant, NM_LLDP_ATTR_CHASSIS_ID_TYPE, G_VARIANT_TYPE_UINT32);
Packit Service a1bd4f
        g_assert(v_chassis_id_type);
Packit Service a1bd4f
Packit Service a1bd4f
        v_chassis_id =
Packit Service a1bd4f
            g_variant_lookup_value(variant, NM_LLDP_ATTR_CHASSIS_ID, G_VARIANT_TYPE_STRING);
Packit Service a1bd4f
        g_assert(v_chassis_id);
Packit Service a1bd4f
Packit Service a1bd4f
        v_port_id_type =
Packit Service a1bd4f
            g_variant_lookup_value(variant, NM_LLDP_ATTR_PORT_ID_TYPE, G_VARIANT_TYPE_UINT32);
Packit Service a1bd4f
        g_assert(v_port_id_type);
Packit Service a1bd4f
Packit Service a1bd4f
        v_port_id = g_variant_lookup_value(variant, NM_LLDP_ATTR_PORT_ID, G_VARIANT_TYPE_STRING);
Packit Service a1bd4f
        g_assert(v_port_id);
Packit Service a1bd4f
Packit Service a1bd4f
        if (nm_streq(g_variant_get_string(v_chassis_id, NULL), chassis_id)
Packit Service a1bd4f
            && nm_streq(g_variant_get_string(v_port_id, NULL), port_id)
Packit Service a1bd4f
            && NM_IN_SET(chassis_id_type, -1, g_variant_get_uint32(v_chassis_id_type))
Packit Service a1bd4f
            && NM_IN_SET(port_id_type, -1, g_variant_get_uint32(v_port_id_type))) {
Packit Service a1bd4f
            g_assert(!result);
Packit Service a1bd4f
            result = variant;
Packit Service a1bd4f
        } else
Packit Service a1bd4f
            g_variant_unref(variant);
Packit Service a1bd4f
    }
Packit Service a1bd4f
Packit Service a1bd4f
    return result;
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
typedef struct {
Packit Service a1bd4f
    int    ifindex;
Packit Service a1bd4f
    int    fd;
Packit Service a1bd4f
    guint8 mac[ETH_ALEN];
Packit 5756e2
} TestRecvFixture;
Packit 5756e2
Packit 5756e2
typedef struct {
Packit Service a1bd4f
    gsize          frame_len;
Packit Service a1bd4f
    const uint8_t *frame;
Packit Service a1bd4f
    const char *   as_variant;
Packit 5756e2
} TestRecvFrame;
Packit Service a1bd4f
#define TEST_RECV_FRAME_DEFINE(name, _as_variant, ...)        \
Packit Service a1bd4f
    static const guint8        _##name##_v[] = {__VA_ARGS__}; \
Packit Service a1bd4f
    static const TestRecvFrame name          = {              \
Packit Service a1bd4f
        .as_variant = _as_variant,                   \
Packit Service a1bd4f
        .frame_len  = sizeof(_##name##_v),           \
Packit Service a1bd4f
        .frame      = _##name##_v,                   \
Packit Service a1bd4f
    }
Packit 5756e2
Packit 5756e2
typedef struct {
Packit Service a1bd4f
    guint                expected_num_called;
Packit Service a1bd4f
    gsize                frames_len;
Packit Service a1bd4f
    const TestRecvFrame *frames[10];
Packit Service a1bd4f
    void (*check)(GMainLoop *loop, NMLldpListener *listener);
Packit 5756e2
} TestRecvData;
Packit 5756e2
#define TEST_RECV_DATA_DEFINE(name, _expected_num_called, _check, ...) \
Packit Service a1bd4f
    static const TestRecvData name = {                                 \
Packit Service a1bd4f
        .expected_num_called = _expected_num_called,                   \
Packit Service a1bd4f
        .check               = _check,                                 \
Packit Service a1bd4f
        .frames_len          = NM_NARG(__VA_ARGS__),                   \
Packit Service a1bd4f
        .frames              = {__VA_ARGS__},                          \
Packit Service a1bd4f
    }
Packit 5756e2
Packit 5756e2
#define TEST_IFNAME "nm-tap-test0"
Packit 5756e2
Packit Service a1bd4f
TEST_RECV_FRAME_DEFINE(
Packit Service a1bd4f
    _test_recv_data0_frame0,
Packit Service a1bd4f
    "{'raw': <[byte 0x01, 0x80, 0xc2, 0x00, 0x00, 0x03, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x88, "
Packit Service a1bd4f
    "0xcc, 0x02, 0x07, 0x04, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x04, 0x04, 0x05, 0x31, 0x2f, "
Packit Service a1bd4f
    "0x33, 0x06, 0x02, 0x00, 0x78, 0x08, 0x04, 0x50, 0x6f, 0x72, 0x74, 0x0a, 0x03, 0x53, 0x59, "
Packit Service a1bd4f
    "0x53, 0x0c, 0x04, 0x66, 0x6f, 0x6f, 0x00, 0x00, 0x00]>, 'chassis-id-type': <uint32 4>, "
Packit Service a1bd4f
    "'chassis-id': <'00:01:02:03:04:05'>, 'port-id-type': <uint32 5>, 'port-id': <'1/3'>, "
Packit Service a1bd4f
    "'destination': <'nearest-non-tpmr-bridge'>, 'port-description': <'Port'>, 'system-name': "
Packit Service a1bd4f
    "<'SYS'>, 'system-description': <'foo'>}",
Packit Service a1bd4f
    /* Ethernet header */
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x80,
Packit Service a1bd4f
    0xc2,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x03, /* Destination MAC */
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x03,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x05,
Packit Service a1bd4f
    0x06, /* Source MAC */
Packit Service a1bd4f
    0x88,
Packit Service a1bd4f
    0xcc, /* Ethertype */
Packit Service a1bd4f
    /* LLDP mandatory TLVs */
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x07,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x02, /* Chassis: MAC, 00:01:02:03:04:05 */
Packit Service a1bd4f
    0x03,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x05,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x05,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x2f,
Packit Service a1bd4f
    0x33, /* Port: interface name, "1/3" */
Packit Service a1bd4f
    0x06,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x78, /* TTL: 120 seconds */
Packit Service a1bd4f
    /* LLDP optional TLVs */
Packit Service a1bd4f
    0x08,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x50,
Packit Service a1bd4f
    0x6f,
Packit Service a1bd4f
    0x72,
Packit Service a1bd4f
    0x74, /* Port Description: "Port" */
Packit Service a1bd4f
    0x0a,
Packit Service a1bd4f
    0x03,
Packit Service a1bd4f
    0x53,
Packit Service a1bd4f
    0x59,
Packit Service a1bd4f
    0x53, /* System Name: "SYS" */
Packit Service a1bd4f
    0x0c,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x66,
Packit Service a1bd4f
    0x6f,
Packit Service a1bd4f
    0x6f,
Packit Service a1bd4f
    0x00, /* System Description: "foo" (NULL-terminated) */
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00 /* End Of LLDPDU */
Packit 5756e2
);
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
_test_recv_data0_check_do(GMainLoop *loop, NMLldpListener *listener, const TestRecvFrame *frame)
Packit 5756e2
{
Packit Service a1bd4f
    GVariant *       neighbors, *attr;
Packit Service a1bd4f
    gs_unref_variant GVariant *neighbor = NULL;
Packit Service a1bd4f
Packit Service a1bd4f
    neighbors = nm_lldp_listener_get_neighbors(listener);
Packit Service a1bd4f
    nmtst_assert_variant_is_of_type(neighbors, G_VARIANT_TYPE("aa{sv}"));
Packit Service a1bd4f
    g_assert_cmpint(g_variant_n_children(neighbors), ==, 1);
Packit Service a1bd4f
Packit Service a1bd4f
    neighbor = get_lldp_neighbor(neighbors,
Packit Service a1bd4f
                                 SD_LLDP_CHASSIS_SUBTYPE_MAC_ADDRESS,
Packit Service a1bd4f
                                 "00:01:02:03:04:05",
Packit Service a1bd4f
                                 SD_LLDP_PORT_SUBTYPE_INTERFACE_NAME,
Packit Service a1bd4f
                                 "1/3");
Packit Service a1bd4f
    g_assert(neighbor);
Packit Service a1bd4f
    g_assert_cmpint(g_variant_n_children(neighbor), ==, 1 + 4 + 4);
Packit Service a1bd4f
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor, NM_LLDP_ATTR_RAW, G_VARIANT_TYPE_BYTESTRING);
Packit Service a1bd4f
    nmtst_assert_variant_bytestring(attr, frame->frame, frame->frame_len);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor, NM_LLDP_ATTR_PORT_DESCRIPTION, G_VARIANT_TYPE_STRING);
Packit Service a1bd4f
    nmtst_assert_variant_string(attr, "Port");
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor, NM_LLDP_ATTR_SYSTEM_NAME, G_VARIANT_TYPE_STRING);
Packit Service a1bd4f
    nmtst_assert_variant_string(attr, "SYS");
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor, NM_LLDP_ATTR_DESTINATION, G_VARIANT_TYPE_STRING);
Packit Service a1bd4f
    nmtst_assert_variant_string(attr, NM_LLDP_DEST_NEAREST_NON_TPMR_BRIDGE);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor, NM_LLDP_ATTR_SYSTEM_DESCRIPTION, G_VARIANT_TYPE_STRING);
Packit Service a1bd4f
    nmtst_assert_variant_string(attr, "foo");
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
_test_recv_data0_check(GMainLoop *loop, NMLldpListener *listener)
Packit 5756e2
{
Packit Service a1bd4f
    _test_recv_data0_check_do(loop, listener, &_test_recv_data0_frame0);
Packit 5756e2
}
Packit 5756e2
Packit Service a1bd4f
TEST_RECV_DATA_DEFINE(_test_recv_data0, 1, _test_recv_data0_check, &_test_recv_data0_frame0);
Packit Service a1bd4f
TEST_RECV_DATA_DEFINE(_test_recv_data0_twice,
Packit Service a1bd4f
                      1,
Packit Service a1bd4f
                      _test_recv_data0_check,
Packit Service a1bd4f
                      &_test_recv_data0_frame0,
Packit Service a1bd4f
                      &_test_recv_data0_frame0);
Packit Service a1bd4f
Packit Service a1bd4f
TEST_RECV_FRAME_DEFINE(
Packit Service a1bd4f
    _test_recv_data1_frame0,
Packit Service a1bd4f
    /* lldp.detailed.pcap from
Packit Service a1bd4f
     * https://wiki.wireshark.org/SampleCaptures#Link_Layer_Discovery_Protocol_.28LLDP.29 */
Packit Service a1bd4f
    "{'raw': <[byte 0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e, 0x00, 0x01, 0x30, 0xf9, 0xad, 0xa0, 0x88, "
Packit Service a1bd4f
    "0xcc, 0x02, 0x07, 0x04, 0x00, 0x01, 0x30, 0xf9, 0xad, 0xa0, 0x04, 0x04, 0x05, 0x31, 0x2f, "
Packit Service a1bd4f
    "0x31, 0x06, 0x02, 0x00, 0x78, 0x08, 0x17, 0x53, 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30, "
Packit Service a1bd4f
    "0x30, 0x2d, 0x34, 0x38, 0x2d, 0x50, 0x6f, 0x72, 0x74, 0x20, 0x31, 0x30, 0x30, 0x31, 0x00, "
Packit Service a1bd4f
    "0x0a, 0x0d, 0x53, 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30, 0x30, 0x2d, 0x34, 0x38, 0x00, "
Packit Service a1bd4f
    "0x0c, 0x4c, 0x53, 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30, 0x30, 0x2d, 0x34, 0x38, 0x20, "
Packit Service a1bd4f
    "0x2d, 0x20, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x37, 0x2e, 0x34, 0x65, 0x2e, "
Packit Service a1bd4f
    "0x31, 0x20, 0x28, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x20, 0x35, 0x29, 0x20, 0x62, 0x79, 0x20, "
Packit Service a1bd4f
    "0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x20, "
Packit Service a1bd4f
    "0x30, 0x35, 0x2f, 0x32, 0x37, 0x2f, 0x30, 0x35, 0x20, 0x30, 0x34, 0x3a, 0x35, 0x33, 0x3a, "
Packit Service a1bd4f
    "0x31, 0x31, 0x00, 0x0e, 0x04, 0x00, 0x14, 0x00, 0x14, 0x10, 0x0e, 0x07, 0x06, 0x00, 0x01, "
Packit Service a1bd4f
    "0x30, 0xf9, 0xad, 0xa0, 0x02, 0x00, 0x00, 0x03, 0xe9, 0x00, 0xfe, 0x07, 0x00, 0x12, 0x0f, "
Packit Service a1bd4f
    "0x02, 0x07, 0x01, 0x00, 0xfe, 0x09, 0x00, 0x12, 0x0f, 0x01, 0x03, 0x6c, 0x00, 0x00, 0x10, "
Packit Service a1bd4f
    "0xfe, 0x09, 0x00, 0x12, 0x0f, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x00, 0x12, "
Packit Service a1bd4f
    "0x0f, 0x04, 0x05, 0xf2, 0xfe, 0x06, 0x00, 0x80, 0xc2, 0x01, 0x01, 0xe8, 0xfe, 0x07, 0x00, "
Packit Service a1bd4f
    "0x80, 0xc2, 0x02, 0x01, 0x00, 0x00, 0xfe, 0x16, 0x00, 0x80, 0xc2, 0x03, 0x01, 0xe8, 0x0f, "
Packit Service a1bd4f
    "0x76, 0x32, 0x2d, 0x30, 0x34, 0x38, 0x38, 0x2d, 0x30, 0x33, 0x2d, 0x30, 0x35, 0x30, 0x35, "
Packit Service a1bd4f
    "0xfe, 0x05, 0x00, 0x80, 0xc2, 0x04, 0x00, 0x00, 0x00]>, 'chassis-id-type': <uint32 4>, "
Packit Service a1bd4f
    "'chassis-id': <'00:01:30:F9:AD:A0'>, 'port-id-type': <uint32 5>, 'port-id': <'1/1'>, "
Packit Service a1bd4f
    "'destination': <'nearest-bridge'>, 'port-description': <'Summit300-48-Port 1001'>, "
Packit Service a1bd4f
    "'system-name': <'Summit300-48'>, 'system-description': <'Summit300-48 - Version 7.4e.1 (Build "
Packit Service a1bd4f
    "5) by Release_Master 05/27/05 04:53:11'>, 'system-capabilities': <uint32 20>, "
Packit Service a1bd4f
    "'management-addresses': <[{'address-subtype': <uint32 6>, 'address': <[byte 0x00, 0x01, 0x30, "
Packit Service a1bd4f
    "0xf9, 0xad, 0xa0]>, 'interface-number-subtype': <uint32 2>, 'interface-number': 
Packit Service a1bd4f
    "1001>}]>, 'ieee-802-1-pvid': <uint32 488>, 'ieee-802-1-ppvid': <uint32 0>, "
Packit Service a1bd4f
    "'ieee-802-1-ppvid-flags': <uint32 1>, 'ieee-802-1-ppvids': <[{'ppvid': <uint32 0>, 'flags': "
Packit Service a1bd4f
    "<uint32 1>}]>, 'ieee-802-1-vid': <uint32 488>, 'ieee-802-1-vlan-name': <'v2-0488-03-0505'>, "
Packit Service a1bd4f
    "'ieee-802-1-vlans': <[{'vid': <uint32 488>, 'name': <'v2-0488-03-0505'>}]>, "
Packit Service a1bd4f
    "'ieee-802-3-mac-phy-conf': <{'autoneg': <uint32 3>, 'pmd-autoneg-cap': <uint32 27648>, "
Packit Service a1bd4f
    "'operational-mau-type': <uint32 16>}>, 'ieee-802-3-power-via-mdi': <{'mdi-power-support': "
Packit Service a1bd4f
    "<uint32 7>, 'pse-power-pair': <uint32 1>, 'power-class': <uint32 0>}>, "
Packit Service a1bd4f
    "'ieee-802-3-max-frame-size': <uint32 1522>}",
Packit Service a1bd4f
    /* ethernet header */
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x80,
Packit Service a1bd4f
    0xc2,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x0e, /* destination mac */
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0xf9,
Packit Service a1bd4f
    0xad,
Packit Service a1bd4f
    0xa0, /* source mac */
Packit Service a1bd4f
    0x88,
Packit Service a1bd4f
    0xcc, /* ethernet type */
Packit Service a1bd4f
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x07,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x30, /* Chassis Subtype */
Packit Service a1bd4f
    0xf9,
Packit Service a1bd4f
    0xad,
Packit Service a1bd4f
    0xa0,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x05,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x2f,
Packit Service a1bd4f
    0x31, /* Port Subtype */
Packit Service a1bd4f
    0x06,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x78, /* Time To Live */
Packit Service a1bd4f
    0x08,
Packit Service a1bd4f
    0x17,
Packit Service a1bd4f
    0x53,
Packit Service a1bd4f
    0x75,
Packit Service a1bd4f
    0x6d,
Packit Service a1bd4f
    0x6d, /* Port Description */
Packit Service a1bd4f
    0x69,
Packit Service a1bd4f
    0x74,
Packit Service a1bd4f
    0x33,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x2d,
Packit Service a1bd4f
    0x34,
Packit Service a1bd4f
    0x38,
Packit Service a1bd4f
    0x2d,
Packit Service a1bd4f
    0x50,
Packit Service a1bd4f
    0x6f,
Packit Service a1bd4f
    0x72,
Packit Service a1bd4f
    0x74,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x0a,
Packit Service a1bd4f
    0x0d,
Packit Service a1bd4f
    0x53,
Packit Service a1bd4f
    0x75,
Packit Service a1bd4f
    0x6d,
Packit Service a1bd4f
    0x6d, /* System Name */
Packit Service a1bd4f
    0x69,
Packit Service a1bd4f
    0x74,
Packit Service a1bd4f
    0x33,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x2d,
Packit Service a1bd4f
    0x34,
Packit Service a1bd4f
    0x38,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x0c,
Packit Service a1bd4f
    0x4c,
Packit Service a1bd4f
    0x53,
Packit Service a1bd4f
    0x75,
Packit Service a1bd4f
    0x6d,
Packit Service a1bd4f
    0x6d, /* System Description */
Packit Service a1bd4f
    0x69,
Packit Service a1bd4f
    0x74,
Packit Service a1bd4f
    0x33,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x2d,
Packit Service a1bd4f
    0x34,
Packit Service a1bd4f
    0x38,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x2d,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x56,
Packit Service a1bd4f
    0x65,
Packit Service a1bd4f
    0x72,
Packit Service a1bd4f
    0x73,
Packit Service a1bd4f
    0x69,
Packit Service a1bd4f
    0x6f,
Packit Service a1bd4f
    0x6e,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x37,
Packit Service a1bd4f
    0x2e,
Packit Service a1bd4f
    0x34,
Packit Service a1bd4f
    0x65,
Packit Service a1bd4f
    0x2e,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x28,
Packit Service a1bd4f
    0x42,
Packit Service a1bd4f
    0x75,
Packit Service a1bd4f
    0x69,
Packit Service a1bd4f
    0x6c,
Packit Service a1bd4f
    0x64,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x35,
Packit Service a1bd4f
    0x29,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x62,
Packit Service a1bd4f
    0x79,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x52,
Packit Service a1bd4f
    0x65,
Packit Service a1bd4f
    0x6c,
Packit Service a1bd4f
    0x65,
Packit Service a1bd4f
    0x61,
Packit Service a1bd4f
    0x73,
Packit Service a1bd4f
    0x65,
Packit Service a1bd4f
    0x5f,
Packit Service a1bd4f
    0x4d,
Packit Service a1bd4f
    0x61,
Packit Service a1bd4f
    0x73,
Packit Service a1bd4f
    0x74,
Packit Service a1bd4f
    0x65,
Packit Service a1bd4f
    0x72,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x35,
Packit Service a1bd4f
    0x2f,
Packit Service a1bd4f
    0x32,
Packit Service a1bd4f
    0x37,
Packit Service a1bd4f
    0x2f,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x35,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x34,
Packit Service a1bd4f
    0x3a,
Packit Service a1bd4f
    0x35,
Packit Service a1bd4f
    0x33,
Packit Service a1bd4f
    0x3a,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x0e,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x14,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x14, /* Capabilities */
Packit Service a1bd4f
    0x10,
Packit Service a1bd4f
    0x0e,
Packit Service a1bd4f
    0x07,
Packit Service a1bd4f
    0x06,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x01, /* Management Address */
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0xf9,
Packit Service a1bd4f
    0xad,
Packit Service a1bd4f
    0xa0,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x03,
Packit Service a1bd4f
    0xe9,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0xfe,
Packit Service a1bd4f
    0x07,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x12,
Packit Service a1bd4f
    0x0f,
Packit Service a1bd4f
    0x02, /* IEEE 802.3 - Power Via MDI */
Packit Service a1bd4f
    0x07,
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0xfe,
Packit Service a1bd4f
    0x09,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x12,
Packit Service a1bd4f
    0x0f,
Packit Service a1bd4f
    0x01, /* IEEE 802.3 - MAC/PHY Configuration/Status */
Packit Service a1bd4f
    0x03,
Packit Service a1bd4f
    0x6c,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x10,
Packit Service a1bd4f
    0xfe,
Packit Service a1bd4f
    0x09,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x12,
Packit Service a1bd4f
    0x0f,
Packit Service a1bd4f
    0x03, /* IEEE 802.3 - Link Aggregation */
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0xfe,
Packit Service a1bd4f
    0x06,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x12,
Packit Service a1bd4f
    0x0f,
Packit Service a1bd4f
    0x04, /* IEEE 802.3 - Maximum Frame Size */
Packit Service a1bd4f
    0x05,
Packit Service a1bd4f
    0xf2,
Packit Service a1bd4f
    0xfe,
Packit Service a1bd4f
    0x06,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x80,
Packit Service a1bd4f
    0xc2,
Packit Service a1bd4f
    0x01, /* IEEE 802.1 - Port VLAN ID */
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0xe8,
Packit Service a1bd4f
    0xfe,
Packit Service a1bd4f
    0x07,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x80,
Packit Service a1bd4f
    0xc2,
Packit Service a1bd4f
    0x02, /* IEEE 802.1 - Port and Protocol VLAN ID */
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0xfe,
Packit Service a1bd4f
    0x16,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x80,
Packit Service a1bd4f
    0xc2,
Packit Service a1bd4f
    0x03, /* IEEE 802.1 - VLAN Name */
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0xe8,
Packit Service a1bd4f
    0x0f,
Packit Service a1bd4f
    0x76,
Packit Service a1bd4f
    0x32,
Packit Service a1bd4f
    0x2d,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x34,
Packit Service a1bd4f
    0x38,
Packit Service a1bd4f
    0x38,
Packit Service a1bd4f
    0x2d,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x33,
Packit Service a1bd4f
    0x2d,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x35,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x35,
Packit Service a1bd4f
    0xfe,
Packit Service a1bd4f
    0x05,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x80,
Packit Service a1bd4f
    0xc2,
Packit Service a1bd4f
    0x04, /* IEEE 802.1 - Protocol Identity */
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00 /* End of LLDPDU */
Packit 5756e2
);
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
_test_recv_data1_check(GMainLoop *loop, NMLldpListener *listener)
Packit 5756e2
{
Packit Service a1bd4f
    GVariant *       neighbors, *attr, *child;
Packit Service a1bd4f
    gs_unref_variant GVariant *neighbor = NULL;
Packit Service a1bd4f
    guint                      v_uint   = 0;
Packit Service a1bd4f
    const char *               v_str    = NULL;
Packit Service a1bd4f
Packit Service a1bd4f
    neighbors = nm_lldp_listener_get_neighbors(listener);
Packit Service a1bd4f
    nmtst_assert_variant_is_of_type(neighbors, G_VARIANT_TYPE("aa{sv}"));
Packit Service a1bd4f
    g_assert_cmpint(g_variant_n_children(neighbors), ==, 1);
Packit Service a1bd4f
Packit Service a1bd4f
    neighbor = get_lldp_neighbor(neighbors,
Packit Service a1bd4f
                                 SD_LLDP_CHASSIS_SUBTYPE_MAC_ADDRESS,
Packit Service a1bd4f
                                 "00:01:30:F9:AD:A0",
Packit Service a1bd4f
                                 SD_LLDP_PORT_SUBTYPE_INTERFACE_NAME,
Packit Service a1bd4f
                                 "1/1");
Packit Service a1bd4f
    g_assert(neighbor);
Packit Service a1bd4f
    g_assert_cmpint(g_variant_n_children(neighbor), ==, 1 + 4 + 16);
Packit Service a1bd4f
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor, NM_LLDP_ATTR_RAW, G_VARIANT_TYPE_BYTESTRING);
Packit Service a1bd4f
    nmtst_assert_variant_bytestring(attr,
Packit Service a1bd4f
                                    _test_recv_data1_frame0.frame,
Packit Service a1bd4f
                                    _test_recv_data1_frame0.frame_len);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor, NM_LLDP_ATTR_DESTINATION, G_VARIANT_TYPE_STRING);
Packit Service a1bd4f
    nmtst_assert_variant_string(attr, NM_LLDP_DEST_NEAREST_BRIDGE);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    /* unsupported: Time To Live */
Packit Service a1bd4f
Packit Service a1bd4f
    /* Port Description */
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor, NM_LLDP_ATTR_PORT_DESCRIPTION, G_VARIANT_TYPE_STRING);
Packit Service a1bd4f
    nmtst_assert_variant_string(attr, "Summit300-48-Port 1001");
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    /* System Name */
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor, NM_LLDP_ATTR_SYSTEM_NAME, G_VARIANT_TYPE_STRING);
Packit Service a1bd4f
    nmtst_assert_variant_string(attr, "Summit300-48");
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    /* System Description */
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor, NM_LLDP_ATTR_SYSTEM_DESCRIPTION, G_VARIANT_TYPE_STRING);
Packit Service a1bd4f
    nmtst_assert_variant_string(
Packit Service a1bd4f
        attr,
Packit Service a1bd4f
        "Summit300-48 - Version 7.4e.1 (Build 5) by Release_Master 05/27/05 04:53:11");
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    /* Capabilities */
Packit Service a1bd4f
    attr =
Packit Service a1bd4f
        g_variant_lookup_value(neighbor, NM_LLDP_ATTR_SYSTEM_CAPABILITIES, G_VARIANT_TYPE_UINT32);
Packit Service a1bd4f
    nmtst_assert_variant_uint32(attr, 20);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    /* Management Address */
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor,
Packit Service a1bd4f
                                  NM_LLDP_ATTR_MANAGEMENT_ADDRESSES,
Packit Service a1bd4f
                                  G_VARIANT_TYPE("aa{sv}"));
Packit Service a1bd4f
    g_assert(attr);
Packit Service a1bd4f
    g_assert_cmpuint(g_variant_n_children(attr), ==, 1);
Packit Service a1bd4f
    child = g_variant_get_child_value(attr, 0);
Packit Service a1bd4f
    g_assert(child);
Packit Service a1bd4f
    g_assert(g_variant_lookup(child, "interface-number", "u", &v_uint));
Packit Service a1bd4f
    g_assert_cmpint(v_uint, ==, 1001);
Packit Service a1bd4f
    g_assert(g_variant_lookup(child, "interface-number-subtype", "u", &v_uint));
Packit Service a1bd4f
    g_assert_cmpint(v_uint, ==, 2);
Packit Service a1bd4f
    g_assert(g_variant_lookup(child, "address-subtype", "u", &v_uint));
Packit Service a1bd4f
    g_assert_cmpint(v_uint, ==, 6);
Packit Service a1bd4f
    nm_clear_g_variant(&child);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    /* IEEE 802.3 - Power Via MDI */
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor,
Packit Service a1bd4f
                                  NM_LLDP_ATTR_IEEE_802_3_POWER_VIA_MDI,
Packit Service a1bd4f
                                  G_VARIANT_TYPE_VARDICT);
Packit Service a1bd4f
    g_assert(attr);
Packit Service a1bd4f
    g_assert(g_variant_lookup(attr, "mdi-power-support", "u", &v_uint));
Packit Service a1bd4f
    g_assert_cmpint(v_uint, ==, 7);
Packit Service a1bd4f
    g_assert(g_variant_lookup(attr, "pse-power-pair", "u", &v_uint));
Packit Service a1bd4f
    g_assert_cmpint(v_uint, ==, 1);
Packit Service a1bd4f
    g_assert(g_variant_lookup(attr, "power-class", "u", &v_uint));
Packit Service a1bd4f
    g_assert_cmpint(v_uint, ==, 0);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    /* IEEE 802.3 - MAC/PHY Configuration/Status */
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor,
Packit Service a1bd4f
                                  NM_LLDP_ATTR_IEEE_802_3_MAC_PHY_CONF,
Packit Service a1bd4f
                                  G_VARIANT_TYPE_VARDICT);
Packit Service a1bd4f
    g_assert(attr);
Packit Service a1bd4f
    g_assert(g_variant_lookup(attr, "autoneg", "u", &v_uint));
Packit Service a1bd4f
    g_assert_cmpint(v_uint, ==, 3);
Packit Service a1bd4f
    g_assert(g_variant_lookup(attr, "pmd-autoneg-cap", "u", &v_uint));
Packit Service a1bd4f
    g_assert_cmpint(v_uint, ==, 0x6c00);
Packit Service a1bd4f
    g_assert(g_variant_lookup(attr, "operational-mau-type", "u", &v_uint));
Packit Service a1bd4f
    g_assert_cmpint(v_uint, ==, 16);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    /* unsupported: IEEE 802.3 - Link Aggregation */
Packit Service a1bd4f
Packit Service a1bd4f
    /* Maximum Frame Size */
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor,
Packit Service a1bd4f
                                  NM_LLDP_ATTR_IEEE_802_3_MAX_FRAME_SIZE,
Packit Service a1bd4f
                                  G_VARIANT_TYPE_UINT32);
Packit Service a1bd4f
    nmtst_assert_variant_uint32(attr, 1522);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    /* IEEE 802.1 - Port VLAN ID */
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor, NM_LLDP_ATTR_IEEE_802_1_PVID, G_VARIANT_TYPE_UINT32);
Packit Service a1bd4f
    nmtst_assert_variant_uint32(attr, 488);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    /* IEEE 802.1 - Port and Protocol VLAN ID */
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor, NM_LLDP_ATTR_IEEE_802_1_PPVID, G_VARIANT_TYPE_UINT32);
Packit Service a1bd4f
    nmtst_assert_variant_uint32(attr, 0);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor,
Packit Service a1bd4f
                                  NM_LLDP_ATTR_IEEE_802_1_PPVID_FLAGS,
Packit Service a1bd4f
                                  G_VARIANT_TYPE_UINT32);
Packit Service a1bd4f
    nmtst_assert_variant_uint32(attr, 1);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    /* new PPVID attributes */
Packit Service a1bd4f
    attr =
Packit Service a1bd4f
        g_variant_lookup_value(neighbor, NM_LLDP_ATTR_IEEE_802_1_PPVIDS, G_VARIANT_TYPE("aa{sv}"));
Packit Service a1bd4f
    g_assert_cmpuint(g_variant_n_children(attr), ==, 1);
Packit Service a1bd4f
    child = g_variant_get_child_value(attr, 0);
Packit Service a1bd4f
    g_assert(child);
Packit Service a1bd4f
    g_assert(g_variant_lookup(child, "ppvid", "u", &v_uint));
Packit Service a1bd4f
    g_assert_cmpint(v_uint, ==, 0);
Packit Service a1bd4f
    g_assert(g_variant_lookup(child, "flags", "u", &v_uint));
Packit Service a1bd4f
    g_assert_cmpint(v_uint, ==, 1);
Packit Service a1bd4f
    nm_clear_g_variant(&child);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    /* IEEE 802.1 - VLAN Name */
Packit Service a1bd4f
    attr =
Packit Service a1bd4f
        g_variant_lookup_value(neighbor, NM_LLDP_ATTR_IEEE_802_1_VLAN_NAME, G_VARIANT_TYPE_STRING);
Packit Service a1bd4f
    nmtst_assert_variant_string(attr, "v2-0488-03-0505");
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
    attr = g_variant_lookup_value(neighbor, NM_LLDP_ATTR_IEEE_802_1_VID, G_VARIANT_TYPE_UINT32);
Packit Service a1bd4f
    nmtst_assert_variant_uint32(attr, 488);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    /* new VLAN attributes */
Packit Service a1bd4f
    attr =
Packit Service a1bd4f
        g_variant_lookup_value(neighbor, NM_LLDP_ATTR_IEEE_802_1_VLANS, G_VARIANT_TYPE("aa{sv}"));
Packit Service a1bd4f
    g_assert_cmpuint(g_variant_n_children(attr), ==, 1);
Packit Service a1bd4f
    child = g_variant_get_child_value(attr, 0);
Packit Service a1bd4f
    g_assert(child);
Packit Service a1bd4f
    g_assert(g_variant_lookup(child, "vid", "u", &v_uint));
Packit Service a1bd4f
    g_assert_cmpint(v_uint, ==, 488);
Packit Service a1bd4f
    g_assert(g_variant_lookup(child, "name", "&s", &v_str));
Packit Service a1bd4f
    g_assert_cmpstr(v_str, ==, "v2-0488-03-0505");
Packit Service a1bd4f
    nm_clear_g_variant(&child);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit Service a1bd4f
Packit Service a1bd4f
    /* unsupported: IEEE 802.1 - Protocol Identity */
Packit 5756e2
}
Packit 5756e2
Packit Service a1bd4f
TEST_RECV_DATA_DEFINE(_test_recv_data1, 1, _test_recv_data1_check, &_test_recv_data1_frame0);
Packit Service a1bd4f
Packit Service a1bd4f
TEST_RECV_FRAME_DEFINE(
Packit Service a1bd4f
    _test_recv_data2_frame0_ttl1,
Packit Service a1bd4f
    "{'raw': <[byte 0x01, 0x80, 0xc2, 0x00, 0x00, 0x03, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x88, "
Packit Service a1bd4f
    "0xcc, 0x02, 0x07, 0x04, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x04, 0x04, 0x05, 0x31, 0x2f, "
Packit Service a1bd4f
    "0x33, 0x06, 0x02, 0x00, 0x01, 0x08, 0x04, 0x50, 0x6f, 0x72, 0x74, 0x0a, 0x03, 0x53, 0x59, "
Packit Service a1bd4f
    "0x53, 0x0c, 0x04, 0x66, 0x6f, 0x6f, 0x00, 0x00, 0x00]>, 'chassis-id-type': <uint32 4>, "
Packit Service a1bd4f
    "'chassis-id': <'00:01:02:03:04:05'>, 'port-id-type': <uint32 5>, 'port-id': <'1/3'>, "
Packit Service a1bd4f
    "'destination': <'nearest-non-tpmr-bridge'>, 'port-description': <'Port'>, 'system-name': "
Packit Service a1bd4f
    "<'SYS'>, 'system-description': <'foo'>}",
Packit Service a1bd4f
    /* Ethernet header */
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x80,
Packit Service a1bd4f
    0xc2,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x03, /* Destination MAC */
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x03,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x05,
Packit Service a1bd4f
    0x06, /* Source MAC */
Packit Service a1bd4f
    0x88,
Packit Service a1bd4f
    0xcc, /* Ethertype */
Packit Service a1bd4f
    /* LLDP mandatory TLVs */
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x07,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x02, /* Chassis: MAC, 00:01:02:03:04:05 */
Packit Service a1bd4f
    0x03,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x05,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x05,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x2f,
Packit Service a1bd4f
    0x33, /* Port: interface name, "1/3" */
Packit Service a1bd4f
    0x06,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x01, /* TTL: 1 seconds */
Packit Service a1bd4f
    /* LLDP optional TLVs */
Packit Service a1bd4f
    0x08,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x50,
Packit Service a1bd4f
    0x6f,
Packit Service a1bd4f
    0x72,
Packit Service a1bd4f
    0x74, /* Port Description: "Port" */
Packit Service a1bd4f
    0x0a,
Packit Service a1bd4f
    0x03,
Packit Service a1bd4f
    0x53,
Packit Service a1bd4f
    0x59,
Packit Service a1bd4f
    0x53, /* System Name: "SYS" */
Packit Service a1bd4f
    0x0c,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x66,
Packit Service a1bd4f
    0x6f,
Packit Service a1bd4f
    0x6f,
Packit Service a1bd4f
    0x00, /* System Description: "foo" (NULL-terminated) */
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00 /* End Of LLDPDU */
Packit 5756e2
);
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
_test_recv_data2_ttl1_check(GMainLoop *loop, NMLldpListener *listener)
Packit 5756e2
{
Packit Service a1bd4f
    gulong    notify_id;
Packit Service a1bd4f
    GVariant *neighbors;
Packit Service a1bd4f
Packit Service a1bd4f
    _test_recv_data0_check_do(loop, listener, &_test_recv_data2_frame0_ttl1);
Packit Service a1bd4f
Packit Service a1bd4f
    /* wait for signal. */
Packit Service a1bd4f
    notify_id = g_signal_connect(listener,
Packit Service a1bd4f
                                 "notify::" NM_LLDP_LISTENER_NEIGHBORS,
Packit Service a1bd4f
                                 nmtst_main_loop_quit_on_notify,
Packit Service a1bd4f
                                 loop);
Packit Service a1bd4f
    if (!nmtst_main_loop_run(loop, 5000))
Packit Service a1bd4f
        g_assert_not_reached();
Packit Service a1bd4f
    nm_clear_g_signal_handler(listener, &notify_id);
Packit Service a1bd4f
Packit Service a1bd4f
    neighbors = nm_lldp_listener_get_neighbors(listener);
Packit Service a1bd4f
    nmtst_assert_variant_is_of_type(neighbors, G_VARIANT_TYPE("aa{sv}"));
Packit Service a1bd4f
    g_assert_cmpint(g_variant_n_children(neighbors), ==, 0);
Packit 5756e2
}
Packit 5756e2
Packit Service a1bd4f
TEST_RECV_DATA_DEFINE(_test_recv_data2_ttl1,
Packit Service a1bd4f
                      1,
Packit Service a1bd4f
                      _test_recv_data2_ttl1_check,
Packit Service a1bd4f
                      &_test_recv_data2_frame0_ttl1);
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
_test_recv_fixture_setup(TestRecvFixture *fixture, gconstpointer user_data)
Packit 5756e2
{
Packit Service a1bd4f
    const NMPlatformLink *link;
Packit Service a1bd4f
    nm_auto_close int     fd = -1;
Packit Service a1bd4f
Packit Service a1bd4f
    fd = open("/dev/net/tun", O_RDWR | O_CLOEXEC);
Packit Service a1bd4f
    if (fd == -1) {
Packit Service a1bd4f
        g_test_skip("Unable to open /dev/net/tun");
Packit Service a1bd4f
        fixture->ifindex = 0;
Packit Service a1bd4f
        return;
Packit Service a1bd4f
    }
Packit Service a1bd4f
Packit Service a1bd4f
    if (nmtst_get_rand_bool()) {
Packit Service a1bd4f
        const NMPlatformLnkTun lnk = {
Packit Service a1bd4f
            .type        = IFF_TAP,
Packit Service a1bd4f
            .pi          = FALSE,
Packit Service a1bd4f
            .vnet_hdr    = FALSE,
Packit Service a1bd4f
            .multi_queue = FALSE,
Packit Service a1bd4f
            .persist     = FALSE,
Packit Service a1bd4f
        };
Packit Service a1bd4f
Packit Service a1bd4f
        nm_close(nm_steal_fd(&fd));
Packit Service a1bd4f
Packit Service a1bd4f
        link = nmtstp_link_tun_add(NM_PLATFORM_GET, FALSE, TEST_IFNAME, &lnk, &fd;;
Packit Service a1bd4f
        g_assert(link);
Packit Service a1bd4f
        nmtstp_link_set_updown(NM_PLATFORM_GET, -1, link->ifindex, TRUE);
Packit Service a1bd4f
        link = nmtstp_assert_wait_for_link(NM_PLATFORM_GET, TEST_IFNAME, NM_LINK_TYPE_TUN, 0);
Packit Service a1bd4f
    } else {
Packit Service a1bd4f
        int          s;
Packit Service a1bd4f
        struct ifreq ifr = {};
Packit Service 87a54e
        int          r;
Packit Service a1bd4f
Packit Service a1bd4f
        ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
Packit Service a1bd4f
        nm_utils_ifname_cpy(ifr.ifr_name, TEST_IFNAME);
Packit Service 87a54e
Packit Service 87a54e
        r = ioctl(fd, TUNSETIFF, &ifr);
Packit Service 87a54e
        if (r != 0) {
Packit Service 87a54e
            g_assert_cmpint(errno, ==, 0);
Packit Service 87a54e
            g_assert_cmpint(r, ==, 0);
Packit Service 87a54e
        }
Packit Service a1bd4f
Packit Service a1bd4f
        /* Bring the interface up */
Packit Service a1bd4f
        s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
Packit Service a1bd4f
        g_assert(s >= 0);
Packit Service 87a54e
Packit Service a1bd4f
        ifr.ifr_flags |= IFF_UP;
Packit Service 87a54e
        r = ioctl(s, SIOCSIFFLAGS, &ifr);
Packit Service 87a54e
        if (r != 0) {
Packit Service 87a54e
            g_assert_cmpint(errno, ==, 0);
Packit Service 87a54e
            g_assert_cmpint(r, ==, 0);
Packit Service 87a54e
        }
Packit Service 87a54e
Packit Service a1bd4f
        nm_close(s);
Packit Service a1bd4f
Packit Service a1bd4f
        link = nmtstp_assert_wait_for_link(NM_PLATFORM_GET, TEST_IFNAME, NM_LINK_TYPE_TUN, 100);
Packit Service a1bd4f
    }
Packit Service a1bd4f
Packit Service a1bd4f
    fixture->ifindex = link->ifindex;
Packit Service a1bd4f
    fixture->fd      = nm_steal_fd(&fd;;
Packit Service a1bd4f
    memcpy(fixture->mac, link->l_address.data, ETH_ALEN);
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
typedef struct {
Packit Service a1bd4f
    int num_called;
Packit 5756e2
} TestRecvCallbackInfo;
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
lldp_neighbors_changed(NMLldpListener *lldp_listener, GParamSpec *pspec, gpointer user_data)
Packit 5756e2
{
Packit Service a1bd4f
    TestRecvCallbackInfo *info = user_data;
Packit 5756e2
Packit Service a1bd4f
    info->num_called++;
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
test_recv(TestRecvFixture *fixture, gconstpointer user_data)
Packit 5756e2
{
Packit Service a1bd4f
    const TestRecvData *data                 = user_data;
Packit Service a1bd4f
    gs_unref_object NMLldpListener *listener = NULL;
Packit Service a1bd4f
    GMainLoop *                     loop;
Packit Service a1bd4f
    TestRecvCallbackInfo            info = {};
Packit Service a1bd4f
    gsize                           i_frames;
Packit Service a1bd4f
    gulong                          notify_id;
Packit Service a1bd4f
    GError *                        error = NULL;
Packit Service a1bd4f
    guint                           sd_id;
Packit 5756e2
Packit Service a1bd4f
    if (fixture->ifindex == 0) {
Packit Service a1bd4f
        g_test_skip("Tun device not available");
Packit Service a1bd4f
        return;
Packit Service a1bd4f
    }
Packit 5756e2
Packit Service a1bd4f
    listener = nm_lldp_listener_new();
Packit Service a1bd4f
    g_assert(listener != NULL);
Packit Service a1bd4f
    g_assert(nm_lldp_listener_start(listener, fixture->ifindex, &error));
Packit Service a1bd4f
    g_assert_no_error(error);
Packit 5756e2
Packit Service a1bd4f
    notify_id = g_signal_connect(listener,
Packit Service a1bd4f
                                 "notify::" NM_LLDP_LISTENER_NEIGHBORS,
Packit Service a1bd4f
                                 (GCallback) lldp_neighbors_changed,
Packit Service a1bd4f
                                 &info;;
Packit Service a1bd4f
    loop      = g_main_loop_new(NULL, FALSE);
Packit Service a1bd4f
    sd_id     = nm_sd_event_attach_default();
Packit 5756e2
Packit Service a1bd4f
    for (i_frames = 0; i_frames < data->frames_len; i_frames++) {
Packit Service a1bd4f
        const TestRecvFrame *f = data->frames[i_frames];
Packit 5756e2
Packit Service a1bd4f
        g_assert(write(fixture->fd, f->frame, f->frame_len) == f->frame_len);
Packit Service a1bd4f
    }
Packit 5756e2
Packit Service a1bd4f
    if (nmtst_main_loop_run(loop, 500))
Packit Service a1bd4f
        g_assert_not_reached();
Packit 5756e2
Packit Service a1bd4f
    g_assert_cmpint(info.num_called, ==, data->expected_num_called);
Packit 5756e2
Packit Service a1bd4f
    nm_clear_g_signal_handler(listener, &notify_id);
Packit 5756e2
Packit Service a1bd4f
    data->check(loop, listener);
Packit 5756e2
Packit Service a1bd4f
    nm_clear_g_source(&sd_id);
Packit Service a1bd4f
    nm_clear_pointer(&loop, g_main_loop_unref);
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
_test_recv_fixture_teardown(TestRecvFixture *fixture, gconstpointer user_data)
Packit 5756e2
{
Packit Service a1bd4f
    if (fixture->ifindex)
Packit Service a1bd4f
        nm_platform_link_delete(NM_PLATFORM_GET, fixture->ifindex);
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
/*****************************************************************************/
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
test_parse_frames(gconstpointer test_data)
Packit 5756e2
{
Packit Service a1bd4f
    const TestRecvFrame *frame            = test_data;
Packit Service a1bd4f
    gs_unref_variant GVariant *v_neighbor = NULL;
Packit Service a1bd4f
    gs_unref_variant GVariant *attr       = NULL;
Packit Service a1bd4f
    gs_free char *             as_variant = NULL;
Packit 5756e2
Packit Service a1bd4f
    v_neighbor = nmtst_lldp_parse_from_raw(frame->frame, frame->frame_len);
Packit Service a1bd4f
    g_assert(v_neighbor);
Packit 5756e2
Packit Service a1bd4f
    attr = g_variant_lookup_value(v_neighbor, NM_LLDP_ATTR_RAW, G_VARIANT_TYPE_BYTESTRING);
Packit Service a1bd4f
    nmtst_assert_variant_bytestring(attr, frame->frame, frame->frame_len);
Packit Service a1bd4f
    nm_clear_g_variant(&attr);
Packit 5756e2
Packit Service a1bd4f
    as_variant = g_variant_print(v_neighbor, TRUE);
Packit Service a1bd4f
    g_assert(as_variant);
Packit Service a1bd4f
    g_assert_cmpstr(frame->as_variant, ==, as_variant);
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
/*****************************************************************************/
Packit 5756e2
Packit Service a1bd4f
TEST_RECV_FRAME_DEFINE(
Packit Service a1bd4f
    _test_parse_frames_3,
Packit Service a1bd4f
    /* https://github.com/the-tcpdump-group/tcpdump/blob/c4f8796bf8bec740621a360eded236d8991ea00f/tests/lldp_mudurl.pcap */
Packit Service a1bd4f
    "{'raw': <[byte 0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e, 0x00, 0x23, 0x54, 0xc2, 0x57, 0x02, 0x88, "
Packit Service a1bd4f
    "0xcc, 0x02, 0x07, 0x04, 0x00, 0x23, 0x54, 0xc2, 0x57, 0x02, 0x04, 0x07, 0x03, 0x00, 0x23, "
Packit Service a1bd4f
    "0x54, 0xc2, 0x57, 0x02, 0x06, 0x02, 0x00, 0x78, 0x0a, 0x1c, 0x75, 0x70, 0x73, 0x74, 0x61, "
Packit Service a1bd4f
    "0x69, 0x72, 0x73, 0x2e, 0x6f, 0x66, 0x63, 0x6f, 0x75, 0x72, 0x73, 0x65, 0x69, 0x6d, 0x72, "
Packit Service a1bd4f
    "0x69, 0x67, 0x68, 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x0c, 0x5c, 0x55, 0x62, 0x75, 0x6e, 0x74, "
Packit Service a1bd4f
    "0x75, 0x20, 0x31, 0x34, 0x2e, 0x30, 0x34, 0x2e, 0x35, 0x20, 0x4c, 0x54, 0x53, 0x20, 0x4c, "
Packit Service a1bd4f
    "0x69, 0x6e, 0x75, 0x78, 0x20, 0x33, 0x2e, 0x31, 0x33, 0x2e, 0x30, 0x2d, 0x31, 0x30, 0x36, "
Packit Service a1bd4f
    "0x2d, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x20, 0x23, 0x31, 0x35, 0x33, 0x2d, 0x55, "
Packit Service a1bd4f
    "0x62, 0x75, 0x6e, 0x74, 0x75, 0x20, 0x53, 0x4d, 0x50, 0x20, 0x54, 0x75, 0x65, 0x20, 0x44, "
Packit Service a1bd4f
    "0x65, 0x63, 0x20, 0x36, 0x20, 0x31, 0x35, 0x3a, 0x34, 0x35, 0x3a, 0x31, 0x33, 0x20, 0x55, "
Packit Service a1bd4f
    "0x54, 0x43, 0x20, 0x32, 0x30, 0x31, 0x36, 0x20, 0x69, 0x36, 0x38, 0x36, 0x0e, 0x04, 0x00, "
Packit Service a1bd4f
    "0x9c, 0x00, 0x08, 0x10, 0x0c, 0x05, 0x01, 0x3e, 0x0c, 0xad, 0x72, 0x02, 0x00, 0x00, 0x00, "
Packit Service a1bd4f
    "0x02, 0x00, 0x10, 0x18, 0x11, 0x02, 0x20, 0x01, 0x08, 0xa8, 0x10, 0x06, 0x00, 0x04, 0x02, "
Packit Service a1bd4f
    "0x23, 0x54, 0xff, 0xfe, 0xc2, 0x57, 0x02, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x04, "
Packit Service a1bd4f
    "0x65, 0x74, 0x68, 0x30, 0xfe, 0x09, 0x00, 0x12, 0x0f, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, "
Packit Service a1bd4f
    "0xfe, 0x09, 0x00, 0x12, 0x0f, 0x01, 0x03, 0xec, 0xc3, 0x00, 0x10, 0xfe, 0x40, 0x00, 0x00, "
Packit Service a1bd4f
    "0x5e, 0x01, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x69, 0x6d, 0x72, 0x69, 0x67, "
Packit Service a1bd4f
    "0x68, 0x74, 0x2e, 0x6d, 0x75, 0x64, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, "
Packit Service a1bd4f
    "0x63, 0x6f, 0x6d, 0x2f, 0x2e, 0x77, 0x65, 0x6c, 0x6c, 0x2d, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, "
Packit Service a1bd4f
    "0x2f, 0x6d, 0x75, 0x64, 0x2f, 0x76, 0x31, 0x2f, 0x76, 0x6f, 0x6d, 0x69, 0x74, 0x76, 0x32, "
Packit Service a1bd4f
    "0x2e, 0x30, 0x00, 0x00]>, 'chassis-id-type': <uint32 4>, 'chassis-id': <'00:23:54:C2:57:02'>, "
Packit Service a1bd4f
    "'port-id-type': <uint32 3>, 'port-id': <'00:23:54:C2:57:02'>, 'destination': "
Packit Service a1bd4f
    "<'nearest-bridge'>, 'port-description': <'eth0'>, 'system-name': "
Packit Service a1bd4f
    "<'upstairs.ofcourseimright.com'>, 'system-description': <'Ubuntu 14.04.5 LTS Linux "
Packit Service a1bd4f
    "3.13.0-106-generic #153-Ubuntu SMP Tue Dec 6 15:45:13 UTC 2016 i686'>, 'system-capabilities': "
Packit Service a1bd4f
    "<uint32 156>, 'management-addresses': <[{'address-subtype': <uint32 1>, 'address': <[byte "
Packit Service a1bd4f
    "0x3e, 0x0c, 0xad, 0x72]>, 'interface-number-subtype': <uint32 2>, 'interface-number': 
Packit Service a1bd4f
    "2>}, {'address-subtype': <uint32 2>, 'address': <[byte 0x20, 0x01, 0x08, 0xa8, 0x10, 0x06, "
Packit Service a1bd4f
    "0x00, 0x04, 0x02, 0x23, 0x54, 0xff, 0xfe, 0xc2, 0x57, 0x02]>, 'interface-number-subtype': "
Packit Service a1bd4f
    "<uint32 2>, 'interface-number': <uint32 2>}]>, 'ieee-802-3-mac-phy-conf': <{'autoneg': "
Packit Service a1bd4f
    "<uint32 3>, 'pmd-autoneg-cap': <uint32 60611>, 'operational-mau-type': <uint32 16>}>, "
Packit Service a1bd4f
    "'mud-url': <'https://imright.mud.example.com/.well-known/mud/v1/vomitv2.0'>}",
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x80,
Packit Service a1bd4f
    0xc2,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x0e, /* ethernet destination */
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x23,
Packit Service a1bd4f
    0x54,
Packit Service a1bd4f
    0xc2,
Packit Service a1bd4f
    0x57,
Packit Service a1bd4f
    0x02, /* ethernet source */
Packit Service a1bd4f
    0x88,
Packit Service a1bd4f
    0xcc, /* ethernet type */
Packit Service a1bd4f
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x07,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x23,
Packit Service a1bd4f
    0x54,
Packit Service a1bd4f
    0xc2,
Packit Service a1bd4f
    0x57,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x07,
Packit Service a1bd4f
    0x03,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x23,
Packit Service a1bd4f
    0x54,
Packit Service a1bd4f
    0xc2,
Packit Service a1bd4f
    0x57,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x06,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x78,
Packit Service a1bd4f
    0x0a,
Packit Service a1bd4f
    0x1c,
Packit Service a1bd4f
    0x75,
Packit Service a1bd4f
    0x70,
Packit Service a1bd4f
    0x73,
Packit Service a1bd4f
    0x74,
Packit Service a1bd4f
    0x61,
Packit Service a1bd4f
    0x69,
Packit Service a1bd4f
    0x72,
Packit Service a1bd4f
    0x73,
Packit Service a1bd4f
    0x2e,
Packit Service a1bd4f
    0x6f,
Packit Service a1bd4f
    0x66,
Packit Service a1bd4f
    0x63,
Packit Service a1bd4f
    0x6f,
Packit Service a1bd4f
    0x75,
Packit Service a1bd4f
    0x72,
Packit Service a1bd4f
    0x73,
Packit Service a1bd4f
    0x65,
Packit Service a1bd4f
    0x69,
Packit Service a1bd4f
    0x6d,
Packit Service a1bd4f
    0x72,
Packit Service a1bd4f
    0x69,
Packit Service a1bd4f
    0x67,
Packit Service a1bd4f
    0x68,
Packit Service a1bd4f
    0x74,
Packit Service a1bd4f
    0x2e,
Packit Service a1bd4f
    0x63,
Packit Service a1bd4f
    0x6f,
Packit Service a1bd4f
    0x6d,
Packit Service a1bd4f
    0x0c,
Packit Service a1bd4f
    0x5c,
Packit Service a1bd4f
    0x55,
Packit Service a1bd4f
    0x62,
Packit Service a1bd4f
    0x75,
Packit Service a1bd4f
    0x6e,
Packit Service a1bd4f
    0x74,
Packit Service a1bd4f
    0x75,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x34,
Packit Service a1bd4f
    0x2e,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x34,
Packit Service a1bd4f
    0x2e,
Packit Service a1bd4f
    0x35,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x4c,
Packit Service a1bd4f
    0x54,
Packit Service a1bd4f
    0x53,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x4c,
Packit Service a1bd4f
    0x69,
Packit Service a1bd4f
    0x6e,
Packit Service a1bd4f
    0x75,
Packit Service a1bd4f
    0x78,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x33,
Packit Service a1bd4f
    0x2e,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x33,
Packit Service a1bd4f
    0x2e,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x2d,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x36,
Packit Service a1bd4f
    0x2d,
Packit Service a1bd4f
    0x67,
Packit Service a1bd4f
    0x65,
Packit Service a1bd4f
    0x6e,
Packit Service a1bd4f
    0x65,
Packit Service a1bd4f
    0x72,
Packit Service a1bd4f
    0x69,
Packit Service a1bd4f
    0x63,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x23,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x35,
Packit Service a1bd4f
    0x33,
Packit Service a1bd4f
    0x2d,
Packit Service a1bd4f
    0x55,
Packit Service a1bd4f
    0x62,
Packit Service a1bd4f
    0x75,
Packit Service a1bd4f
    0x6e,
Packit Service a1bd4f
    0x74,
Packit Service a1bd4f
    0x75,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x53,
Packit Service a1bd4f
    0x4d,
Packit Service a1bd4f
    0x50,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x54,
Packit Service a1bd4f
    0x75,
Packit Service a1bd4f
    0x65,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x44,
Packit Service a1bd4f
    0x65,
Packit Service a1bd4f
    0x63,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x36,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x35,
Packit Service a1bd4f
    0x3a,
Packit Service a1bd4f
    0x34,
Packit Service a1bd4f
    0x35,
Packit Service a1bd4f
    0x3a,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x33,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x55,
Packit Service a1bd4f
    0x54,
Packit Service a1bd4f
    0x43,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x32,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x36,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x69,
Packit Service a1bd4f
    0x36,
Packit Service a1bd4f
    0x38,
Packit Service a1bd4f
    0x36,
Packit Service a1bd4f
    0x0e,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x9c,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x08,
Packit Service a1bd4f
    0x10,
Packit Service a1bd4f
    0x0c,
Packit Service a1bd4f
    0x05,
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x3e,
Packit Service a1bd4f
    0x0c,
Packit Service a1bd4f
    0xad,
Packit Service a1bd4f
    0x72,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x10,
Packit Service a1bd4f
    0x18,
Packit Service a1bd4f
    0x11,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x20,
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x08,
Packit Service a1bd4f
    0xa8,
Packit Service a1bd4f
    0x10,
Packit Service a1bd4f
    0x06,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x23,
Packit Service a1bd4f
    0x54,
Packit Service a1bd4f
    0xff,
Packit Service a1bd4f
    0xfe,
Packit Service a1bd4f
    0xc2,
Packit Service a1bd4f
    0x57,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x02,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x08,
Packit Service a1bd4f
    0x04,
Packit Service a1bd4f
    0x65,
Packit Service a1bd4f
    0x74,
Packit Service a1bd4f
    0x68,
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0xfe,
Packit Service a1bd4f
    0x09,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x12,
Packit Service a1bd4f
    0x0f,
Packit Service a1bd4f
    0x03,
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0xfe,
Packit Service a1bd4f
    0x09,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x12,
Packit Service a1bd4f
    0x0f,
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x03,
Packit Service a1bd4f
    0xec,
Packit Service a1bd4f
    0xc3,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x10,
Packit Service a1bd4f
    0xfe,
Packit Service a1bd4f
    0x40,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x5e,
Packit Service a1bd4f
    0x01,
Packit Service a1bd4f
    0x68,
Packit Service a1bd4f
    0x74,
Packit Service a1bd4f
    0x74,
Packit Service a1bd4f
    0x70,
Packit Service a1bd4f
    0x73,
Packit Service a1bd4f
    0x3a,
Packit Service a1bd4f
    0x2f,
Packit Service a1bd4f
    0x2f,
Packit Service a1bd4f
    0x69,
Packit Service a1bd4f
    0x6d,
Packit Service a1bd4f
    0x72,
Packit Service a1bd4f
    0x69,
Packit Service a1bd4f
    0x67,
Packit Service a1bd4f
    0x68,
Packit Service a1bd4f
    0x74,
Packit Service a1bd4f
    0x2e,
Packit Service a1bd4f
    0x6d,
Packit Service a1bd4f
    0x75,
Packit Service a1bd4f
    0x64,
Packit Service a1bd4f
    0x2e,
Packit Service a1bd4f
    0x65,
Packit Service a1bd4f
    0x78,
Packit Service a1bd4f
    0x61,
Packit Service a1bd4f
    0x6d,
Packit Service a1bd4f
    0x70,
Packit Service a1bd4f
    0x6c,
Packit Service a1bd4f
    0x65,
Packit Service a1bd4f
    0x2e,
Packit Service a1bd4f
    0x63,
Packit Service a1bd4f
    0x6f,
Packit Service a1bd4f
    0x6d,
Packit Service a1bd4f
    0x2f,
Packit Service a1bd4f
    0x2e,
Packit Service a1bd4f
    0x77,
Packit Service a1bd4f
    0x65,
Packit Service a1bd4f
    0x6c,
Packit Service a1bd4f
    0x6c,
Packit Service a1bd4f
    0x2d,
Packit Service a1bd4f
    0x6b,
Packit Service a1bd4f
    0x6e,
Packit Service a1bd4f
    0x6f,
Packit Service a1bd4f
    0x77,
Packit Service a1bd4f
    0x6e,
Packit Service a1bd4f
    0x2f,
Packit Service a1bd4f
    0x6d,
Packit Service a1bd4f
    0x75,
Packit Service a1bd4f
    0x64,
Packit Service a1bd4f
    0x2f,
Packit Service a1bd4f
    0x76,
Packit Service a1bd4f
    0x31,
Packit Service a1bd4f
    0x2f,
Packit Service a1bd4f
    0x76,
Packit Service a1bd4f
    0x6f,
Packit Service a1bd4f
    0x6d,
Packit Service a1bd4f
    0x69,
Packit Service a1bd4f
    0x74,
Packit Service a1bd4f
    0x76,
Packit Service a1bd4f
    0x32,
Packit Service a1bd4f
    0x2e,
Packit Service a1bd4f
Packit Service a1bd4f
    0x30,
Packit Service a1bd4f
    0x00,
Packit Service a1bd4f
    0x00, /* ethernet trailer */
Packit 5756e2
);
Packit 5756e2
Packit 5756e2
/*****************************************************************************/
Packit 5756e2
Packit 5756e2
NMTstpSetupFunc const _nmtstp_setup_platform_func = nm_linux_platform_setup;
Packit 5756e2
Packit 5756e2
void
Packit Service a1bd4f
_nmtstp_init_tests(int *argc, char ***argv)
Packit 5756e2
{
Packit Service a1bd4f
    nmtst_init_assert_logging(argc, argv, "WARN", "ALL");
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
void
Packit Service a1bd4f
_nmtstp_setup_tests(void)
Packit 5756e2
{
Packit 5756e2
#define _TEST_ADD_RECV(testpath, testdata) \
Packit Service a1bd4f
    g_test_add(testpath,                   \
Packit Service a1bd4f
               TestRecvFixture,            \
Packit Service a1bd4f
               testdata,                   \
Packit Service a1bd4f
               _test_recv_fixture_setup,   \
Packit Service a1bd4f
               test_recv,                  \
Packit Service a1bd4f
               _test_recv_fixture_teardown)
Packit Service a1bd4f
    _TEST_ADD_RECV("/lldp/recv/0", &_test_recv_data0);
Packit Service a1bd4f
    _TEST_ADD_RECV("/lldp/recv/0_twice", &_test_recv_data0_twice);
Packit Service a1bd4f
    _TEST_ADD_RECV("/lldp/recv/1", &_test_recv_data1);
Packit Service a1bd4f
    _TEST_ADD_RECV("/lldp/recv/2_ttl1", &_test_recv_data2_ttl1);
Packit Service a1bd4f
Packit Service a1bd4f
    g_test_add_data_func("/lldp/parse-frames/0", &_test_recv_data0_frame0, test_parse_frames);
Packit Service a1bd4f
    g_test_add_data_func("/lldp/parse-frames/1", &_test_recv_data1_frame0, test_parse_frames);
Packit Service a1bd4f
    g_test_add_data_func("/lldp/parse-frames/2", &_test_recv_data2_frame0_ttl1, test_parse_frames);
Packit Service a1bd4f
    g_test_add_data_func("/lldp/parse-frames/3", &_test_parse_frames_3, test_parse_frames);
Packit 5756e2
}