lldpd 的简单总结

背景

现在调试IP话机的时候,客户使用了LLDP信息来协商VLAN字段的信息,经过研究,最终选定了lldpd开源程序作为lldpd的解析程序,但是网上的资料比较分散,现在我将查找的LLDP资料整合一下,方便查阅。

下载lldpd

git clone https://github.com/lldpd/lldpd.git

编译

export TOOLCHAIN=xxx/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64
export TARGET=armv7a-linux-androideabi
export API=30
# DO NOT TOUCH BELOW
export AR=$TOOLCHAIN/bin/llvm-ar
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
export LD=$TOOLCHAIN/bin/ld
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
export STRIP=$TOOLCHAIN/bin/llvm-strip
export AS=$CC
./autogen.sh
mkdir -p build && cd build
../configure \
    --host=$TARGET \
    --with-sysroot=$TOOLCHAIN/sysroot \
    --prefix=/system \
    --sbindir=/system/bin \
    --runstatedir=/data/misc/lldp \
    --with-privsep-user=root \
    --with-privsep-group=root \
    PKG_CONFIG=/bin/false
make
make install DESTDIR=$PWD/install

在安卓中配置成服务

在 /vendor/etc/init/找一个合适的rc文件,添加如下

service lldpd /vendor/bin/lldpd -d -M 3
    class late_start
    user root
    group root
    seclabel u:r:lldpd:s0

lldpd 配置

参考 https://manpages.org/lldpcli/8
新建 /etc/lldpd.d/lldp.conf
其中设置参数可以总结如下

# Try all commands.
# Keep those commands in the same order as the one in the manual page.

show neighbors details hidden
show neighbors summary
show neighbors ports eth0 details
show configuration
show chassis details
show statistics
show statistics summary
show statistics ports eth0
configure system hostname Batman
unconfigure system hostname
configure system description Batman
unconfigure system description
configure system platform Batman
unconfigure system platform
configure system interface pattern *
unconfigure system interface pattern
configure system interface description
unconfigure system interface description
configure system interface promiscuous
unconfigure system interface promiscuous
configure system ip management pattern *
unconfigure system ip management pattern
configure system max-neighbors 16
configure lldp portidsubtype ifname
configure lldp portidsubtype macaddress
configure lldp portidsubtype local Batman
configure lldp portidsubtype local Batman description Batman
configure lldp tx-interval 30
configure lldp tx-hold 4
configure ports eth0 lldp status tx-only
configure lldp status rx-and-tx
configure lldp custom-tlv oui 33,44,55 subtype 44
configure lldp custom-tlv oui 33,44,55 subtype 44 oui-info 45,45,45,45,45
configure lldp custom-tlv add oui 33,44,55 subtype 44 oui-info 55,55,55,55,55
configure lldp custom-tlv add oui 33,44,55 subtype 55 oui-info 65,65,65,65,65
configure lldp custom-tlv replace oui 33,44,55 subtype 44 oui-info 66,66,66,66,66
unconfigure lldp custom-tlv oui 33,44,55 subtype 55
unconfigure lldp custom-tlv
configure system bond-slave-src-mac-type fixed
configure system bond-slave-src-mac-type local
configure med fast-start enable
configure med fast-start tx-interval 3
unconfigure med fast-start
configure med location coordinate latitude 48.58667N longitude 2.2014E altitude 117.47 m datum WGS84
configure med location address country US language en_US street "Commercial Road" city "Roseville"
configure med location elin 911
configure ports eth0 med location elin 911
configure med policy application voice tagged vlan 500 priority voice dscp 46
configure ports eth0 med policy application voice vlan 500 priority voice dscp 46
configure med power pd source pse priority high value 5000
configure ports eth0 med power pd source pse priority high value 5000
configure dot3 power pse supported enabled paircontrol powerpairs spare class class-3
configure ports eth0 dot3 power pse supported enabled paircontrol powerpairs spare class class-3
configure dot3 power pd supported enabled powerpairs spare class class-3 type 1 source pse priority low requested 10000 allocated 15000

configure inventory hardware-revision "SQRT2-1.41421356237309504880"
configure inventory software-revision "E-2.7182818284590452354"
configure inventory firmware-revision "PI-3.14159265358979323846"
configure inventory serial "FIBO112358"
configure inventory manufacturer "Cybertron"
configure inventory model "OptimusPrime"
configure inventory asset "SQRT3-1.732050807568877"

unconfigure inventory hardware-revision
unconfigure inventory software-revision
unconfigure inventory firmware-revision
unconfigure inventory serial
unconfigure inventory manufacturer
unconfigure inventory model
unconfigure inventory asset

# A convenient way to "test" lldpcli and liblldpctl is to load those commands in lldpcli with valgrind:
#  libtool execute valgrind --suppressions=../src/client/lldpcli.supp --leak-check=full src/client/lldpcli -c ../tests/lldpcli.conf



lldpcli使用

参考:https://man.archlinux.org/man/lldpcli.8.en

1、查看周围的邻居列表

root@hbg:/# lldpcli  -u /data/misc/lldp/lldpd.socket show neighbors

2、查看lldp的统计信息

 root@hbg:/# lldpcli  -u /data/misc/lldp/lldpd.socket show stat

或者使用命令  lldpcli  -u /data/misc/lldp/lldpd.socket show statistics

3、查看当前的配置信息

root@hbg:/# lldpcli  -u /data/misc/lldp/lldpd.socket show configuration

或者使用命令 lldpcli  -u /data/misc/lldp/lldpd.socket show running-configuration
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值