MCPcopy
hub / github.com/google/gopacket / RegisterLayerType

Function RegisterLayerType

layertype.go:53–64  ·  view source on GitHub ↗

RegisterLayerType creates a new layer type and registers it globally. The number passed in must be unique, or a runtime panic will occur. Numbers 0-999 are reserved for the gopacket library. Numbers 1000-1999 should be used for common application-specific types, and are very fast. Any other numbe

(num int, meta LayerTypeMetadata)

Source from the content-addressed store, hash-verified

51// types, and are somewhat slower (they require a map lookup over an array
52// index).
53func RegisterLayerType(num int, meta LayerTypeMetadata) LayerType {
54 if 0 <= num && num < maxLayerType {
55 if ltMeta[num].inUse {
56 panic("Layer type already exists")
57 }
58 } else {
59 if ltMetaMap[LayerType(num)].inUse {
60 panic("Layer type already exists")
61 }
62 }
63 return OverrideLayerType(num, meta)
64}
65
66// OverrideLayerType acts like RegisterLayerType, except that if the layer type
67// has already been registered, it overrides the metadata with the passed-in

Callers 3

RegisterLCMLayerTypeFunction · 0.92
layertypes.goFile · 0.92
decode.goFile · 0.85

Calls 2

LayerTypeTypeAlias · 0.85
OverrideLayerTypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…