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)
| 51 | // types, and are somewhat slower (they require a map lookup over an array |
| 52 | // index). |
| 53 | func 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 |
no test coverage detected
searching dependent graphs…