|
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) |
|
static int | lldp_applies (struct settings *settings __unused, const struct setting *setting) |
| Check applicability of LLDP setting. More...
|
|
static int | lldp_fetch (struct settings *settings, struct setting *setting, void *buf, size_t len) |
| Fetch value of LLDP setting. More...
|
|
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. More...
|
|
static int | lldp_probe (struct net_device *netdev, void *priv) |
| Create LLDP settings block. More...
|
|
static void | lldp_remove (struct net_device *netdev __unused, void *priv) |
| Remove LLDP settings block. More...
|
|
Link Layer Discovery Protocol.
Definition in file lldp.c.
Fetch value of LLDP setting.
- Parameters
-
settings | Settings block |
setting | Setting to fetch |
buf | Buffer to fill with setting data |
len | Length of buffer |
- Return values
-
len | Length of setting data, or negative error |
Definition at line 81 of file lldp.c.
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;
struct eth_slow_tlv_header tlv
TLV header.
size_t len
Length of LLDP data.
#define ENOENT
No such file or directory.
uint64_t tag
Setting tag, if applicable.
#define LLDP_TLV_LEN(type_len)
Extract LLDP TLV length.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define container_of(ptr, type, field)
Get containing structure.
#define LLDP_TYPE_END
End of LLDP data unit.
const struct setting_type * type
Setting type.
uint32_t high
High 32 bits of address.
#define LLDP_TLV_TYPE(type_len)
Extract LLDP TLV type.
uint8_t data[48]
Additional event data.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
References container_of, data, lldp_settings::data, DBGC, DBGC2, DBGC2_HDA, DBGC_HDA, ENOENT, high, htonl, len, lldp_settings::len, LLDP_TLV_LEN, LLDP_TLV_TYPE, LLDP_TYPE_END, memcmp(), memcpy(), lldp_settings::name, ntohs, raw, setting::tag, tlv, and setting::type.
static int lldp_rx |
( |
struct io_buffer * |
iobuf, |
|
|
struct net_device * |
netdev, |
|
|
const void * |
ll_dest, |
|
|
const void * |
ll_source, |
|
|
unsigned int flags |
__unused |
|
) |
| |
|
static |
Process LLDP packet.
- Parameters
-
iobuf | I/O buffer |
netdev | Network device |
ll_dest | Link-layer destination address |
ll_source | Link-layer source address |
flags | Packet flags |
- Return values
-
Definition at line 203 of file lldp.c.
230 DBGC2 ( lldpset,
"LLDP %s src %s ",
struct arbelprm_rc_send_wqe rc
size_t len
Length of LLDP data.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
#define ENOMEM
Not enough space.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * netdev_priv(struct net_device *netdev, struct net_driver *driver)
Get network device driver private data.
static struct net_device * netdev
static void(* free)(struct refcnt *refcnt))
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
void * malloc(size_t size)
Allocate memory.
void * data
Start of data.
uint8_t data[48]
Additional event data.
const char *(* ntoa)(const void *ll_addr)
Transcribe link-layer address.
#define NULL
NULL pointer (VOID *)
struct ll_protocol * ll_protocol
Link-layer protocol.
References data, io_buffer::data, lldp_settings::data, DBGC2, DBGC2_HDA, ENOMEM, free, free_iob(), iob_len(), len, lldp_settings::len, net_device::ll_protocol, malloc(), memcpy(), lldp_settings::name, netdev, netdev_priv(), ll_protocol::ntoa, NULL, and rc.
static int lldp_probe |
( |
struct net_device * |
netdev, |
|
|
void * |
priv |
|
) |
| |
|
static |
Create LLDP settings block.
- Parameters
-
netdev | Network device |
priv | Private data |
- Return values
-
Definition at line 258 of file lldp.c.
271 DBGC ( lldpset,
"LLDP %s could not register settings: %s\n",
275 DBGC ( lldpset,
"LLDP %s registered\n", lldpset->
name );
struct arbelprm_rc_send_wqe rc
void unregister_settings(struct settings *settings)
Unregister settings block.
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.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static struct net_device * netdev
struct settings settings
Settings interface.
char * strerror(int errno)
Retrieve string representation of error number.
struct refcnt refcnt
Reference counter.
char name[NETDEV_NAME_LEN]
Name of this network device.
static struct tlan_private * priv
int register_settings(struct settings *settings, struct settings *parent, const char *name)
Register settings block.
#define LLDP_SETTINGS_NAME
LLDP settings block name.
static const struct settings_scope lldp_settings_scope
LLDP settings scope.
#define NULL
NULL pointer (VOID *)
static struct settings_operations lldp_settings_operations
LLDP settings operations.
References assert(), lldp_settings::data, DBGC, LLDP_SETTINGS_NAME, lldp_settings_operations, lldp_settings_scope, lldp_settings::name, net_device::name, netdev, netdev_settings(), NULL, priv, rc, net_device::refcnt, register_settings(), lldp_settings::settings, settings_init(), strerror(), and unregister_settings().