@@ -56,14 +56,15 @@ func ParseLLDPCTL(data []byte) (LLDP, error) {
5656 type rawVlan struct {
5757 VlanID string `json:"vlan-id"`
5858 PVID bool `json:"pvid"`
59+ Value string `json:"value,omitempty"`
5960 }
6061 type rawIfaceDetails struct {
6162 Via string `json:"via"`
6263 RID string `json:"rid"`
6364 Age string `json:"age"`
6465 Chassis map [string ]rawChassis `json:"chassis"`
6566 Port rawPort `json:"port"`
66- Vlan * rawVlan `json:"vlan,omitempty"`
67+ Vlan json. RawMessage `json:"vlan,omitempty"`
6768 }
6869 type rawLLDPCTL struct {
6970 LLDP struct {
@@ -105,8 +106,28 @@ func ParseLLDPCTL(data []byte) (LLDP, error) {
105106 PortDescription : details .Port .Descr ,
106107 MgmtIP : ch .MgmtIP ,
107108 }
108- if details .Vlan != nil {
109- n .VlanID = details .Vlan .VlanID
109+ // Parse vlan field which can be either a single object or an array
110+ if len (details .Vlan ) > 0 {
111+ // Try single object first
112+ var singleVlan rawVlan
113+ if err := json .Unmarshal (details .Vlan , & singleVlan ); err == nil {
114+ n .VlanID = singleVlan .VlanID
115+ } else {
116+ // Try array of vlans
117+ var vlanArray []rawVlan
118+ if err := json .Unmarshal (details .Vlan , & vlanArray ); err == nil && len (vlanArray ) > 0 {
119+ // Take the first vlan with pvid=true, or just the first one
120+ for _ , v := range vlanArray {
121+ if v .PVID {
122+ n .VlanID = v .VlanID
123+ break
124+ }
125+ }
126+ if n .VlanID == "" && len (vlanArray ) > 0 {
127+ n .VlanID = vlanArray [0 ].VlanID
128+ }
129+ }
130+ }
110131 }
111132 for _ , cap := range ch .Capability {
112133 if cap .Enabled {
0 commit comments