83 void *buf,
size_t len ) {
100 unsigned int tlv_type_len;
101 unsigned int tlv_type;
102 unsigned int tlv_len;
107 tag_type = ( tag_low >> 24 );
108 tag_index = ( tag_low >> 16 );
109 tag_offset = ( tag_low >> 8 );
110 tag_length = ( tag_low >> 0 );
113 match_len = tag_offset;
114 if ( match_len >
sizeof ( tag_prefix ) )
115 match_len =
sizeof ( tag_prefix );
116 if ( ! tag_prefix.high )
118 match = &tag_prefix.raw[
sizeof ( tag_prefix ) - match_len ];
121 for (
data = lldpset->
data, remaining = lldpset->
len ; remaining ;
122 data += tlv_len, remaining -= tlv_len ) {
125 if ( remaining <
sizeof ( *
tlv ) ) {
126 DBGC ( lldpset,
"LLDP %s underlength TLV header\n",
132 data +=
sizeof ( *tlv );
133 remaining -=
sizeof ( *tlv );
134 tlv_type_len =
ntohs (
tlv->type_len );
139 if ( remaining < tlv_len ) {
140 DBGC ( lldpset,
"LLDP %s underlength TLV value\n",
145 DBGC2 ( lldpset,
"LLDP %s found type %d:\n",
146 lldpset->
name, tlv_type );
150 if ( tlv_type != tag_type )
154 if ( tlv_len < match_len )
164 if ( tlv_len < tag_offset )
167 tlv_len -= tag_offset;
172 &setting_type_string );
176 if ( tag_length && ( tlv_len > tag_length ) )
177 tlv_len = tag_length;
204 const void *ll_dest,
const void *ll_source,
230 DBGC2 ( lldpset,
"LLDP %s src %s ",
271 DBGC ( lldpset,
"LLDP %s could not register settings: %s\n",
275 DBGC ( lldpset,
"LLDP %s registered\n", lldpset->
name );
296 DBGC ( lldpset,
"LLDP %s unregistered\n", lldpset->
name );
struct eth_slow_tlv_header tlv
TLV header.
struct arbelprm_rc_send_wqe rc
const char * name
Protocol name.
size_t len
Length of LLDP data.
void unregister_settings(struct settings *settings)
Unregister settings block.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
static int lldp_probe(struct net_device *netdev, void *priv)
Create LLDP settings block.
#define ENOENT
No such file or directory.
A network upper-layer driver.
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
static void settings_init(struct settings *settings, struct settings_operations *op, struct refcnt *refcnt, const struct settings_scope *default_scope)
Initialise a settings block.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint64_t tag
Setting tag, if applicable.
#define LLDP_TLV_LEN(type_len)
Extract LLDP TLV length.
#define ENOMEM
Not enough space.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static int lldp_rx(struct io_buffer *iobuf, struct net_device *netdev, const void *ll_dest, const void *ll_source, unsigned int flags __unused)
Process LLDP packet.
static void lldp_remove(struct net_device *netdev __unused, void *priv)
Remove LLDP settings block.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
void * netdev_priv(struct net_device *netdev, struct net_driver *driver)
Get network device driver private data.
#define __unused
Declare a variable or data structure as unused.
#define LLDP_TYPE_END
End of LLDP data unit.
static struct net_device * netdev
const struct setting_type * type
Setting type.
static int lldp_fetch(struct settings *settings, struct setting *setting, void *buf, size_t len)
Fetch value of LLDP setting.
Link Layer Discovery Protocol.
uint32_t high
High 32 bits of address.
struct settings settings
Settings interface.
char * strerror(int errno)
Retrieve string representation of error number.
struct refcnt refcnt
Reference counter.
static void(* free)(struct refcnt *refcnt))
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Settings block operations.
void * malloc(size_t size)
Allocate memory.
static int lldp_applies(struct settings *settings __unused, const struct setting *setting)
Check applicability of LLDP setting.
A network-layer protocol.
Network device management.
char name[NETDEV_NAME_LEN]
Name of this network device.
static struct tlan_private * priv
void * data
Start of data.
#define LLDP_TLV_TYPE(type_len)
Extract LLDP TLV type.
uint8_t data[48]
Additional event data.
const char *(* ntoa)(const void *ll_addr)
Transcribe link-layer address.
int(* applies)(struct settings *settings, const struct setting *setting)
Check applicability of setting.
int register_settings(struct settings *settings, struct settings *parent, const char *name)
Register settings block.
#define LLDP_SETTINGS_NAME
LLDP settings block name.
const struct settings_scope * scope
Setting scope (or NULL)
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
static const struct settings_scope lldp_settings_scope
LLDP settings scope.
#define NULL
NULL pointer (VOID *)
struct net_protocol lldp_protocol __net_protocol
LLDP protocol.
struct ll_protocol * ll_protocol
Link-layer protocol.
static struct settings_operations lldp_settings_operations
LLDP settings operations.
struct net_driver lldp_driver __net_driver
LLDP driver.