|
The Assimilation Monitoring Project
|
Implements minimal client-oriented CDP capabilities. More...

Go to the source code of this file.
Macros | |
| #define | CDP_OVERHEAD 22 |
| Number of bytes before the CDP packet itself starts. More... | |
| #define | CDP_VERSSZ 1 |
| Size of the CDP version object in a CDP packet. More... | |
| #define | CDP_TTLSZ 1 |
| Size of the Time to Live (TTL) object in a CDP packet. More... | |
| #define | CDP_CKSUMSZ 2 |
| Size of the checksum object in a CDP packet. More... | |
| #define | CDPINITHDRSZ (CDP_OVERHEAD+CDP_VERSSZ+CDP_TTLSZ+CDP_CKSUMSZ) /* 26 */ |
| Start of the TLV (type, length, value) portion of a CDP packet. More... | |
| #define | CDPTLV_TYPESZ 2 |
| Size of the type element in the CDP TLV triple. More... | |
| #define | CDPTLV_LENSZ 2 |
| Size of the length element in a CDP TLV. More... | |
| #define | CDPTLV_TYPELENSZ (CDPTLV_TYPESZ+CDPTLV_LENSZ) /* 4 */ |
| Overhead - offset to the beginning of the CDP TLV Value. More... | |
Functions | |
| WINEXPORT gboolean | is_valid_cdp_packet (const void *packet, const void *pktend) |
| Check to see if this is a valid CDP packet. More... | |
| WINEXPORT guint8 | get_cdp_vers (const void *pktptr, const void *pktend) |
| Return the CDP protocol version for this packet. More... | |
| WINEXPORT guint8 | get_cdp_ttl (const void *pktptr, const void *pktend) |
| Return the time to live for this CDP packet. More... | |
| WINEXPORT guint16 | get_cdp_cksum (const void *pktptr, const void *pktend) |
| Return the 16-bit checksum for this CDP packet. More... | |
| WINEXPORT guint16 | get_cdptlv_type (const void *tlv_vp, const void *pktend) |
| Return type from the given TLV triplet in a CDP packet. More... | |
| WINEXPORT gsize | get_cdptlv_len (const void *tlv_vp, const void *pktend) |
| Return size of the given TLV triplet. More... | |
| WINEXPORT gsize | get_cdptlv_vlen (const void *tlv_vp, const void *pktend) |
| Return length of the value blob int a given TLV triplet in a CDP packet - value size only. More... | |
| WINEXPORT const void * | get_cdptlv_body (const void *tlv_vp, const void *pktend) |
| Return the body (value) blob of a CDP TLV triplet. More... | |
| WINEXPORT const void * | get_cdptlv_first (const void *pkt, const void *pktend) |
| Return the first CDP TLV triple in a CDP packet. More... | |
| WINEXPORT const void * | get_cdptlv_next (const void *tlv_vp, const void *tlv_vpend) |
| Locate the next CDP TLV triple (iterator). More... | |
| WINEXPORT const void * | get_cdp_chassis_id (gconstpointer packet, gssize *idlength, gconstpointer pktend) |
| Get the chassis ID associated with this CDP packet. More... | |
| WINEXPORT const void * | get_cdp_port_id (gconstpointer packet, gssize *idlength, gconstpointer pktend) |
| get the port ID associated with this CDP packet More... | |
Implements minimal client-oriented CDP capabilities.
This file contains the minimal CDP 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.
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 cdp_min.c.
| WINEXPORT const void* get_cdp_chassis_id | ( | gconstpointer | packet, |
| gssize * | idlength, | ||
| gconstpointer | pktend | ||
| ) |
Get the chassis ID associated with this CDP packet.
| [in] | packet | Pointer to a the start of a CDP packet |
| [out] | idlength | length of chassis id |
| [in] | pktend | Pointer of first byte past end of CDP packet |
Definition at line 261 of file cdp_min.c.
References CDP_TLV_DEVID, get_cdptlv_body(), get_cdptlv_first(), get_cdptlv_next(), get_cdptlv_type(), and get_cdptlv_vlen().

| WINEXPORT guint16 get_cdp_cksum | ( | const void * | pktptr, |
| const void * | pktend | ||
| ) |
Return the 16-bit checksum for this CDP packet.
The checksum is not part of the TLVs, so the input pointer is to the CDP packet not the first TLV in the packet.
| [in] | pktptr | Pointer to beginning of CDP packet |
| [in] | pktend | Pointer of first byte past end of CDP packet |
Definition at line 163 of file cdp_min.c.
References CDP_OVERHEAD, and tlv_get_guint16().
Referenced by dump_cdp_packet().


| WINEXPORT const void* get_cdp_port_id | ( | gconstpointer | packet, |
| gssize * | idlength, | ||
| gconstpointer | pktend | ||
| ) |
get the port ID associated with this CDP packet
| [in] | packet | Pointer to a the start of a CDP packet |
| [out] | idlength | length of chassis id |
| [in] | pktend | Pointer of first byte past end of CDP packet |
Definition at line 282 of file cdp_min.c.
References CDP_TLV_PORTID, get_cdptlv_body(), get_cdptlv_first(), get_cdptlv_next(), get_cdptlv_type(), and get_cdptlv_vlen().

| WINEXPORT guint8 get_cdp_ttl | ( | const void * | pktptr, |
| const void * | pktend | ||
| ) |
Return the time to live for this CDP packet.
The TTL is not part of the TLVs in a CDP packet.
| [in] | pktptr | Pointer to beginning of the CDP packet |
| [in] | pktend | Pointer of first byte past end of CDP packet |
Definition at line 153 of file cdp_min.c.
References CDP_OVERHEAD, and tlv_get_guint8().
Referenced by dump_cdp_packet(), get_cdptlv_first(), and is_valid_cdp_packet().


| WINEXPORT guint8 get_cdp_vers | ( | const void * | pktptr, |
| const void * | pktend | ||
| ) |
Return the CDP protocol version for this packet.
This is normally 2. The CDP protocol version is not part of the TLVs in a CDP packet.
| [in] | pktptr | Pointer to beginning of the CDP packet |
| [in] | pktend | Pointer of first byte past end of CDP packet |
Definition at line 142 of file cdp_min.c.
References CDP_OVERHEAD, and tlv_get_guint8().
Referenced by dump_cdp_packet(), get_cdptlv_first(), and is_valid_cdp_packet().


| WINEXPORT const void* get_cdptlv_body | ( | const void * | tlv_vp, |
| const void * | pktend | ||
| ) |
Return the body (value) blob of a CDP TLV triplet.
| [in] | tlv_vp | Should be the a CDP TLV object from get_cdbtlv_first() or get_cdp_tlv_next(), etc. |
| [in] | pktend | Pointer of first byte past end of CDP packet |
Definition at line 206 of file cdp_min.c.
References CDPTLV_TYPELENSZ.
Referenced by dump_cdp_packet(), get_cdp_chassis_id(), and get_cdp_port_id().

| WINEXPORT const void* get_cdptlv_first | ( | const void * | pkt, |
| const void * | pktend | ||
| ) |
Return the first CDP TLV triple in a CDP packet.
| [in] | pkt | Pointer to start of CDP packet |
| [in] | pktend | First byte after the last CDP packet byte |
Definition at line 217 of file cdp_min.c.
References CDPINITHDRSZ, CDPTLV_TYPELENSZ, get_cdp_ttl(), get_cdp_vers(), and get_cdptlv_len().
Referenced by dump_cdp_packet(), get_cdp_chassis_id(), get_cdp_port_id(), and is_valid_cdp_packet().


| WINEXPORT gsize get_cdptlv_len | ( | const void * | tlv_vp, |
| const void * | pktend | ||
| ) |
Return size of the given TLV triplet.
| [in] | tlv_vp | Should be the a CDP TLV object from get_cdbtlv_first or get_cdp_tlv_next, etc. |
| [in] | pktend | Pointer of first byte past end of CDP packet |
Definition at line 183 of file cdp_min.c.
References tlv_get_guint16().
Referenced by get_cdptlv_first(), get_cdptlv_next(), get_cdptlv_vlen(), and is_valid_cdp_packet().


| WINEXPORT const void* get_cdptlv_next | ( | const void * | tlv_vp, |
| const void * | tlv_vpend | ||
| ) |
Locate the next CDP TLV triple (iterator).
| [in] | tlv_vp | Pointer to first byte of current TLV triple |
| [in] | tlv_vpend | First byte after the last CDP packet byte |
Definition at line 239 of file cdp_min.c.
References CDPTLV_TYPELENSZ, and get_cdptlv_len().
Referenced by dump_cdp_packet(), get_cdp_chassis_id(), and get_cdp_port_id().


| WINEXPORT guint16 get_cdptlv_type | ( | const void * | tlv_vp, |
| const void * | pktend | ||
| ) |
Return type from the given TLV triplet in a CDP packet.
| [in] | tlv_vp | Should be the a CDP TLV object from get_cdbtlv_first or get_cdp_tlv_next, etc. |
| [in] | pktend | Pointer of first byte past end of CDP packet |
Definition at line 173 of file cdp_min.c.
References tlv_get_guint16().
Referenced by dump_cdp_packet(), get_cdp_chassis_id(), get_cdp_port_id(), and is_valid_cdp_packet().


| WINEXPORT gsize get_cdptlv_vlen | ( | const void * | tlv_vp, |
| const void * | pktend | ||
| ) |
Return length of the value blob int a given TLV triplet in a CDP packet - value size only.
| [in] | tlv_vp | Should be the a CDP TLV object from get_cdbtlv_first(), or get_cdp_tlv_next(), etc. |
| [in] | pktend | Pointer of first byte past end of CDP packet |
Definition at line 194 of file cdp_min.c.
References CDPTLV_TYPELENSZ, and get_cdptlv_len().
Referenced by dump_cdp_packet(), get_cdp_chassis_id(), and get_cdp_port_id().


| WINEXPORT gboolean is_valid_cdp_packet | ( | const void * | packet, |
| const void * | pktend | ||
| ) |
Check to see if this is a valid CDP packet.
We validate that it is completely well-formed, and not dangerous to process to the best of our knowledge - watching especially for buffer-overrun type issues in the structure of the packet.
| [in] | packet | Start of CDP packet |
| [in] | pktend | First byte after the last CDP packet byte |
Definition at line 93 of file cdp_min.c.
References CDPTLV_TYPELENSZ, DIMOF, get_cdp_ttl(), get_cdp_vers(), get_cdptlv_first(), get_cdptlv_len(), and get_cdptlv_type().
Referenced by cma.AssimCclasses.SwitchDiscovery::decode_discovery(), dump_cdp_packet(), and main().

