lldp.h revision 2
82d05588933a3c765aa8518fe455d6477d640b99Mark Andrews/*
339d2a4d4b3b2e0be9e43afec6e84fe468edfaeeAutomatic Updater * CDDL HEADER START
a7038d1a0513c8e804937ebc95fc9cb3a46c04f5Mark Andrews *
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * The contents of this file are subject to the terms of the
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * Common Development and Distribution License (the "License").
82d05588933a3c765aa8518fe455d6477d640b99Mark Andrews * You may not use this file except in compliance with the License.
82d05588933a3c765aa8518fe455d6477d640b99Mark Andrews *
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * or http://www.opensolaris.org/os/licensing.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * See the License for the specific language governing permissions
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * and limitations under the License.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews *
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * When distributing Covered Code, include this CDDL HEADER in each
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * If applicable, add the following below this CDDL HEADER, with the
82d05588933a3c765aa8518fe455d6477d640b99Mark Andrews * fields enclosed by brackets "[]" replaced with your own identifying
82d05588933a3c765aa8518fe455d6477d640b99Mark Andrews * information: Portions Copyright [yyyy] [name of copyright owner]
339d2a4d4b3b2e0be9e43afec6e84fe468edfaeeAutomatic Updater *
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence * CDDL HEADER END
82d05588933a3c765aa8518fe455d6477d640b99Mark Andrews */
82d05588933a3c765aa8518fe455d6477d640b99Mark Andrews
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews/*
29747dfe5e073a299b3681e01f5c55540f8bfed7Mark Andrews * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein */
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews#ifndef _LLDP_H
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews#define _LLDP_H
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews
904a5734375869ffb504ed8cde6b68cafadb6d64Bob Halley/*
904a5734375869ffb504ed8cde6b68cafadb6d64Bob Halley * WARNING
82d05588933a3c765aa8518fe455d6477d640b99Mark Andrews *
904a5734375869ffb504ed8cde6b68cafadb6d64Bob Halley * The interfaces defined in this file are private to the implementation
904a5734375869ffb504ed8cde6b68cafadb6d64Bob Halley * of Solaris and are subject to change at any time without notice.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Applications using these interfaces may fail to run on future releases.
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews */
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews#ifdef __cplusplus
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrewsextern "C" {
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence#endif
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence#include <sys/types.h>
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence
4478cd2fa8b4bfd72db5a04aa2733605ca641d0fBob Halley/*
b4d8192d210290112e07b0e22b491c45c50ba696Evan Hunt * Multicast addresses used by LLDP agents. These MAC addresses define the
b4d8192d210290112e07b0e22b491c45c50ba696Evan Hunt * transmission scope of the LLDPDU packets sent.
b4d8192d210290112e07b0e22b491c45c50ba696Evan Hunt */
b4d8192d210290112e07b0e22b491c45c50ba696Evan Hunt#define LLDP_GROUP_ADDRESS { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e }
b4d8192d210290112e07b0e22b491c45c50ba696Evan Hunt#define LLDP_NEAREST_NONTPMR_BRIDGE_MCAST_ADDR \
b4d8192d210290112e07b0e22b491c45c50ba696Evan Hunt { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x03 }
b4d8192d210290112e07b0e22b491c45c50ba696Evan Hunt#define LLDP_CUSTOMER_BRIDGE_MCAST_ADDR \
b4d8192d210290112e07b0e22b491c45c50ba696Evan Hunt { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 }
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence/* LLDP Agent operation modes */
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrencetypedef enum lldp_admin_status_e {
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence LLDP_MODE_UNKNOWN,
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein LLDP_MODE_TXONLY,
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence LLDP_MODE_RXONLY,
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence LLDP_MODE_RXTX,
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence LLDP_MODE_DISABLE
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein} lldp_admin_status_t;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrencetypedef enum {
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence LLDP_TLVTYPE_END,
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence LLDP_TLVTYPE_CHASSIS_ID,
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence LLDP_TLVTYPE_PORT_ID,
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence LLDP_TLVTYPE_TTL,
82d05588933a3c765aa8518fe455d6477d640b99Mark Andrews LLDP_TLVTYPE_PORT_DESC,
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews LLDP_TLVTYPE_SYS_NAME,
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews LLDP_TLVTYPE_SYS_DESC,
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews LLDP_TLVTYPE_SYS_CAPAB,
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews LLDP_TLVTYPE_MGMT_ADDR,
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence /* types 9-126 are reserved */
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence LLDP_TLVTYPE_RESERVED,
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein LLDP_ORGSPECIFIC_TLVTYPE = 127
6a8832f784bd53aa6afbda22f6187cea6490e1e1Andreas Gustafsson} lldp_tlv_type_t;
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeintypedef enum {
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein LLDP_CHASSIS_ID_CHASSIS_COMPONENT = 1,
2680c1bb61f5b8084ab023dc11057c3350ecf0cfAndreas Gustafsson LLDP_CHASSIS_ID_IFALIAS,
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence LLDP_CHASSIS_ID_PORT_COMPONENT,
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein LLDP_CHASSIS_ID_MACADDRESS,
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews LLDP_CHASSIS_ID_IPADDRESS,
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews LLDP_CHASSIS_ID_IFNAME,
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein LLDP_CHASSIS_ID_LOCAL
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews} lldp_chassis_subtype_t;
8eaa2ef5664889df5a0855b667f6d8845cd95b50Mark Andrews
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrencetypedef enum {
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence LLDP_PORT_ID_IFALIAS = 1, /* RFC 2863 - DisplayString */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein LLDP_PORT_ID_PORT_COMPONENT, /* RFC 4133 - DisplayString */
2680c1bb61f5b8084ab023dc11057c3350ecf0cfAndreas Gustafsson LLDP_PORT_ID_MACADDRESS, /* IEEE Std 802 */
2680c1bb61f5b8084ab023dc11057c3350ecf0cfAndreas Gustafsson LLDP_PORT_ID_IPADDRESS, /* IPv4 or IPv6 address */
2680c1bb61f5b8084ab023dc11057c3350ecf0cfAndreas Gustafsson LLDP_PORT_ID_IFNAME, /* RFC 2863 - DisaplayString */
904a5734375869ffb504ed8cde6b68cafadb6d64Bob Halley LLDP_PORT_ID_AGENT_CICRUITID, /* RFC 3046 - NumericString */
904a5734375869ffb504ed8cde6b68cafadb6d64Bob Halley LLDP_PORT_ID_LOCAL /* alpha-numeric string */
82d05588933a3c765aa8518fe455d6477d640b99Mark Andrews} lldp_port_subtype_t;
#define LLDP_SYSCAPAB_OTHER 0x0001
#define LLDP_SYSCAPAB_REPEATER 0x0002
#define LLDP_SYSCAPAB_MACBRIDGE 0x0004
#define LLDP_SYSCAPAB_WLAN_AP 0x0008
#define LLDP_SYSCAPAB_ROUTER 0x0010
#define LLDP_SYSCAPAB_TELEPHONE 0x0020
#define LLDP_SYSCAPAB_DOCSIS_CDEV 0x0040
#define LLDP_SYSCAPAB_STATION_ONLY 0x0080
#define LLDP_SYSCAPAB_CVLAN 0x0100
#define LLDP_SYSCAPAB_SVLAN 0x0200
#define LLDP_SYSCAPAB_TPMR 0x0400
/* Change this number if we add/remove capabilities */
#define LLDP_MAX_SYSCAPAB_TYPE 11
#define LLDP_TLV_TYPE(typelen) ((ntohs(*(uint16_t *)(void *)typelen)) >> 9)
#define LLDP_TLV_LEN(typelen) ((ntohs(*(uint16_t *)(void *)typelen)) & 0x01ff)
#define LLDP_TLVHDR_SZ (sizeof (uint16_t))
#define LLDP_ORGSPECHDR_SZ (sizeof (uint32_t))
#define LLDP_OUI_LEN 3
#define LLDP_ORGTLV_OUI(ouistype) \
(ntohl(*(uint32_t *)(void *)(ouistype)) >> 8)
#define LLDP_ORGTLV_STYPE(ouistype) \
(ntohl(*(uint32_t *)(void *)(ouistype)) & 0x000000FF)
#define LLDP_802dot1_OUI 0x0080C2
#define LLDP_802dot3_OUI 0x00120F
#define LLDP_MED_OUI 0x0012BB
#define LLDP_ORACLE_OUI 0x0003BA
/* IEEE 802.1 Organizationally Specific TLV Subtypes */
#define LLDP_802dot1OUI_PVID_SUBTYPE 1
#define LLDP_802dot1OUI_PPVID_SUBTYPE 2
#define LLDP_802dot1OUI_VLAN_NAME_SUBTYPE 3
#define LLDP_802dot1OUI_PROTOCOLID_SUBTYPE 4
#define LLDP_802dot1OUI_LINK_AGGR_SUBTYPE 7
#define LLDP_802dot1OUI_ETSCFG_SUBTYPE 9
#define LLDP_802dot1OUI_ETSRECO_SUBTYPE 10
#define LLDP_802dot1OUI_PFC_SUBTYPE 11
#define LLDP_802dot1OUI_APPLN_SUBTYPE 12
/* Subtype TBA by IEEE */
#define LLDP_802dot1OUI_EVB_SUBTYPE 13
/* IEEE 802.3 Organizationally Specific TLV Subtypes */
#define LLDP_802dot3OUI_MACPHYS_SUBTYPE 1
#define LLDP_802dot3OUI_POWVIAMDI_SUBTYPE 2
#define LLDP_802dot3OUI_MAXFRAMESZ_SUBTYPE 4
/* Oracle OUI subtype */
#define LLDP_ORACLEOUI_VNIC_SUBTYPE 1
#define LLDP_MAX_PORTIDLEN 255
#define LLDP_MAX_CHASSISIDLEN 255
#define LLDP_MAX_MSAPLEN \
(LLDP_MAX_PORTIDLEN + LLDP_MAX_CHASSISIDLEN)
#define LLDP_MAX_PORTIDSTRLEN 512 /* octets represented as string */
#define LLDP_MAX_CHASSISIDSTRLEN 512 /* octets represented as string */
#define LLDP_MAX_MSAPSTRLEN 1024
#define LLDP_MAX_PORTDESCLEN 256 /* includes NUL terminating char */
#define LLDP_MAX_SYSNAMELEN 256 /* includes NUL terminating char */
#define LLDP_MAX_SYSDESCLEN 256
#define LLDP_MAX_VLANNAMELEN 33 /* includes NUL terminating char */
#define LLDP_MAX_VNICNAMELEN 33 /* includes NUL terminating char */
#define LLDP_MIN_VNICTLV_LEN 12
#define LLDP_MAX_VNICTLV_LEN 266
#define LLDP_MGMTADDR_ADDRLEN 31
#define LLDP_MGMTADDR_OIDLEN 128
#define LLDP_STRSIZE 256
#define LLDP_MAX_PDULEN 1500
/* variaous ianaAddressFamilyNumbers from (www.iana.org) */
#define LLDP_MGMTADDR_TYPE_IPV4 0x1
#define LLDP_MGMTADDR_TYPE_IPV6 0x2
#define LLDP_MGMTADDR_TYPE_ALL802 0x6
#define LLDP_MGMTADDR_IFTYPE_UNKNOWN 0x1
#define LLDP_MGMTADDR_IFTYPE_IFINDEX 0x2
#define LLDP_MGMTADDR_IFTYPE_SYSPORT 0x3
typedef struct lldp_tlv_s {
uint8_t lt_type;
uint16_t lt_len;
uint8_t *lt_value;
} lldp_tlv_t;
typedef struct lldp_chassid_s {
uint8_t lc_subtype;
uint_t lc_cidlen;
uint8_t lc_cid[LLDP_MAX_CHASSISIDLEN];
} lldp_chassisid_t;
typedef struct lldp_portid_s {
uint8_t lp_subtype;
uint_t lp_pidlen;
uint8_t lp_pid[LLDP_MAX_PORTIDLEN];
} lldp_portid_t;
typedef struct lldp_syscapab_s {
uint16_t ls_sup_syscapab;
uint16_t ls_enab_syscapab;
} lldp_syscapab_t;
typedef struct lldp_vlan_info_s {
uint16_t lvi_vid;
uint8_t lvi_vlen;
char lvi_name[LLDP_MAX_VLANNAMELEN];
} lldp_vlan_info_t;
typedef struct lldp_vnic_info_s {
uint32_t lvni_linkid;
uint16_t lvni_vid;
lldp_portid_t lvni_portid;
char lvni_name[LLDP_MAX_VNICNAMELEN];
} lldp_vnic_info_t;
typedef struct lldp_aggr_s {
uint8_t la_status;
uint32_t la_id;
} lldp_aggr_t;
typedef struct lldp_pfc_s {
boolean_t lp_willing;
boolean_t lp_mbc;
uint8_t lp_cap;
uint8_t lp_enable;
} lldp_pfc_t;
typedef struct lldp_appln_s {
uint8_t la_pri;
uint8_t la_sel;
uint16_t la_id;
} lldp_appln_t;
typedef struct lldp_evb_s {
uint8_t le_mode;
boolean_t le_bgid;
boolean_t le_sgid;
uint8_t le_r;
uint8_t le_rte;
boolean_t le_rol_rwd; /* TRUE -> remote, FALSE -> local */
uint8_t le_rwd;
boolean_t le_rol_rka; /* TRUE -> remote, FALSE -> local */
uint8_t le_rka;
boolean_t le_rrcap;
boolean_t le_rrctr;
boolean_t le_rrreq;
uint8_t le_rrstat;
} lldp_evb_t;
#define LLDP_EVB_UNKNOWN 0
#define LLDP_EVB_BRIDGE 1
#define LLDP_EVB_STATION 2
#define LLDP_EVB_MODE(mrlrwd) (mrlrwd) >> 6
#define LLDP_EVB_ROL_RWD(mrlrwd) ((mrlrwd) & 0x20) >> 5
#define LLDP_EVB_RWD(mrlrwd) (mrlrwd) & 0x1F
#define LLDP_EVB_R(rrte) (rrte) >> 5
#define LLDP_EVB_RTE(rrte) (rrte) & 0x1F
#define LLDP_EVB_ROL_RKA(rolrka) ((rolrka) & 0x20) >> 5
#define LLDP_EVB_RKA(rolrka) (rolrka) & 0x1F
#define LLDP_EVBB_BGID(bcap) (bcap) & 0x4
#define LLDP_EVBB_RRCAP(bcap) (bcap) & 0x2
#define LLDP_EVBB_RRCTR(bcap) (bcap) & 0x1
#define LLDP_EVBS_SGID(scap) (scap) & 0x8
#define LLDP_EVBS_RRREQ(scap) (scap) & 0x4
#define LLDP_EVBS_RRSTAT(scap) (scap) & 0x3
#define LLDP_EVB_TLVLEN 5 /* 5-bytes */
typedef struct lldp_ets_s {
boolean_t le_willing; /* only for config TLV */
boolean_t le_cbs; /* only for config TLV */
uint8_t le_ntcs; /* only for config TLV */
uint8_t le_pat[8]; /* Priority Assignment Table */
uint8_t le_bat[8]; /* Bandwidth Assignment Table */
uint8_t le_tsa[8]; /* TSA Assignment Table */
} lldp_ets_t;
/* ETS configuration/recommendation TLV information string length */
#define LLDP_ETS_INFOSTR_LEN 25
/* ETS Transmission selection algorithm */
#define LLDP_TSA_ETS 2
#define LLDP_AGGR_CAPABLE 0x1
#define LLDP_AGGR_MEMBER 0x2
typedef struct lldp_mgmtaddr_s {
uint8_t lm_subtype;
uint8_t lm_addrlen;
uint8_t lm_addr[LLDP_MGMTADDR_ADDRLEN];
uint8_t lm_iftype;
uint32_t lm_ifnumber;
uint8_t lm_oidlen;
uint8_t lm_oid[LLDP_MGMTADDR_OIDLEN];
} lldp_mgmtaddr_t;
/* DCBX Types */
typedef enum dcbx_protocol_type_s {
DCBX_TYPE_PFC = 1,
DCBX_TYPE_APPLICATION,
DCBX_TYPE_ETS
} dcbx_protocol_type_t;
/* DCB Application TLV Selector Field types */
#define DCB_APPLICATION_SF_ETHERTYPE 0x01
#define DCB_APPLICATION_SF_TCP_SCTP 0x02
#define DCB_APPLICATION_SF_UDP_DCCP 0x03
#define DCB_APPLICATION_SF_TCP_SCTP_UDP_DCCP 0x04
#define DCBX_FCOE_APPLICATION_ID1 0x8906
#define DCBX_FCOE_APPLICATION_ID2 0x8914
#define DCBX_FCOE_APPLICATION_SF DCB_APPLICATION_SF_ETHERTYPE
#ifdef __cplusplus
}
#endif
#endif /* _LLDP_H */