stp.go 687 B

123456789101112131415161718192021222324252627
  1. // Copyright 2017 Google, Inc. All rights reserved.
  2. //
  3. // Use of this source code is governed by a BSD-style license
  4. // that can be found in the LICENSE file in the root of the source
  5. // tree.
  6. package layers
  7. import (
  8. "github.com/google/gopacket"
  9. )
  10. // STP decode spanning tree protocol packets to transport BPDU (bridge protocol data unit) message.
  11. type STP struct {
  12. BaseLayer
  13. }
  14. // LayerType returns gopacket.LayerTypeSTP.
  15. func (s *STP) LayerType() gopacket.LayerType { return LayerTypeSTP }
  16. func decodeSTP(data []byte, p gopacket.PacketBuilder) error {
  17. stp := &STP{}
  18. stp.Contents = data[:]
  19. // TODO: parse the STP protocol into actual subfields.
  20. p.AddLayer(stp)
  21. return nil
  22. }