The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lldp.c File Reference

Implements minimal client-oriented LLDP capabilities. More...

#include <stdio.h>
#include <string.h>
#include <lldp.h>
#include <server_dump.h>
Include dependency graph for lldp.c:

Go to the source code of this file.

Macros

#define DIMOF(a)   (sizeof(a)/sizeof(a[0]))
 
#define NETTLV_INITPKTOFFSET   14
 
#define NETTLV_HDRSZ   2
 

Functions

unsigned get_oui (const void *ouiptr)
 Convert the OUI given a pointer to the OUI field. More...
 
const char * get_oui_string (unsigned oui)
 Convert an Organizational-Unique-Identifier to a human-readable string. More...
 
const char * get_lldp_type_string (unsigned lldptype)
 Translate an LLDP TLV packet type into a string. More...
 
void dump_lldp_packet (const void *tlv_vpv,const void *tlv_vpendv)
 Dump an LLDP packet to stdout. More...
 

Detailed Description

Implements minimal client-oriented LLDP capabilities.

This file contains the minimal LLDP capability for a client - enough for it to be able to understand and validate a CDP packet's structure, return any particular TLV and specifically to be able to locate the chassis id and port id (which the client needs).

This file is part of the Assimilation Project.

Author
Copyright © 2011, 2012 - Alan Robertson alanr.nosp@m.@uni.nosp@m.x.sh
The Assimilation software is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Assimilation software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the Assimilation Project software. If not, see http://www.gnu.org/licenses/

Definition in file lldp.c.

Macro Definition Documentation

#define DIMOF (   a)    (sizeof(a)/sizeof(a[0]))

Definition at line 30 of file lldp.c.

Referenced by get_lldp_type_string(), and get_oui_string().

#define NETTLV_HDRSZ   2

Definition at line 33 of file lldp.c.

#define NETTLV_INITPKTOFFSET   14

Definition at line 32 of file lldp.c.

Function Documentation

void dump_lldp_packet ( const void *  tlv_vpv,
const void *  tlv_vpendv 
)

Dump an LLDP packet to stdout.

Parameters
[in]tlv_vpvPointer to the first byte of the packet
[in]tlv_vpendvPointer to the first byte past the end of the packet

Definition at line 120 of file lldp.c.

References dump_mem(), get_lldp_type_string(), get_lldptlv_body(), get_lldptlv_first(), get_lldptlv_len(), get_lldptlv_next(), get_lldptlv_type(), get_oui(), get_oui_string(), is_valid_lldp_packet(), LLDP_TLV_ORG_SPECIFIC, and oui.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

const char * get_lldp_type_string ( unsigned  lldptype)

Translate an LLDP TLV packet type into a string.

Returns
a constant string representing the name of the LLDP TLV type. This function always returns a constant string, never a malloced or static buffer string.
Parameters
[in]lldptypeLLDP TLV type

Definition at line 108 of file lldp.c.

References DIMOF, and LLDP_TLV_ORG_SPECIFIC.

Referenced by dump_lldp_packet().

Here is the caller graph for this function:

unsigned get_oui ( const void *  ouiptr)

Convert the OUI given a pointer to the OUI field.

Returns
the OUI as an unsigned.
Parameters
[in]ouiptrPointer to the first byte of an OUI field in a TLV entry

Definition at line 54 of file lldp.c.

Referenced by dump_lldp_packet().

Here is the caller graph for this function:

const char * get_oui_string ( unsigned  oui)

Convert an Organizational-Unique-Identifier to a human-readable string.

Returns
pointer to a constant string containing the OUI name if known, or a static buffer with an ASCII represention of the OUI if unknown. Although there are lots of OUIs, we know about the ones most likely to appear in an LLDP Org-Specific TLV.
Parameters
[in]ouiA (three-byte) OUI as an unsigned

Definition at line 88 of file lldp.c.

References DIMOF.

Referenced by dump_lldp_packet().

Here is the caller graph for this function:

Variable Documentation

unsigned oui

Definition at line 67 of file lldp.c.

Referenced by dump_lldp_packet().

const char* string

Definition at line 68 of file lldp.c.