Simplify existing libraries to fetch LLDP information

Hey,

I am really new to golang and to programming. I am able to write simple scripts, but that’s pretty much where my knowledge ends.

What I want to code:
I would like to have a “simple” function, that I can call in order to get LLDP neighbor information of a given interface.

I already found this, which already seems to do what I want

My issue:
It is a plugin for a bigger software and seems to communicate to other processes via grpc.
So this does way to much for me. I really would just like to call a blocking function, that returns me the LLDP-Information of a given interface.
So I tried it like this: lldp.go - Pastebin.com (if you test it, you need to change the name of your interface in line 183).

Sadly it does not seem to work:

go build lldptest.go && ./lldptest                                                                                                                                                                                                   2.6.3
2022/10/24 21:06:14 LLDP Plugin Started.
2022/10/24 21:06:14 Started Capture
2022/10/24 21:06:24 Opened interface:  en0
SysName: %s  lol
2022/10/24 21:06:26 Waited for all processes to stop
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
{{0 0   0} <nil>}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x10044daac]

goroutine 35 [running]:
github.com/RackHD/inservice/plugins/lldp/neighbors.(*Neighbors).translatePacket(0x1e?, 0xc000100a00)
	/Users/user/code/go/pkg/mod/github.com/!rack!h!d/inservice@v0.0.0-20170929210032-8049898f824e/plugins/lldp/neighbors/decode.go:12 +0x2c
github.com/RackHD/inservice/plugins/lldp/neighbors.(*Neighbors).ProcessPacket(0xc00022e150, 0xc00022e0f0?, {{0x0, 0x0, {0x0, 0x0}, {0x0, 0x0, 0x0}, 0x0}, ...})
	/Users/user/code/go/pkg/mod/github.com/!rack!h!d/inservice@v0.0.0-20170929210032-8049898f824e/plugins/lldp/neighbors/neighbors.go:148 +0xc5
created by main.(*LLDPPlugin).Capture.func1
	/tmp/lldptest/lldptest.go:139 +0x38
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.