github.com/gopacket/gopacket@v1.1.0/layers/enums_generated.go (about)

     1  // Copyright 2012 Google, Inc. All rights reserved.
     2  
     3  package layers
     4  
     5  // Created by gen2.go, don't edit manually
     6  // Generated at 2022-08-14 17:04:22.83449 +0200 CEST m=+0.008730827
     7  
     8  import (
     9  	"fmt"
    10  
    11  	"github.com/gopacket/gopacket"
    12  )
    13  
    14  func init() {
    15  	initUnknownTypesForLinkType()
    16  	initUnknownTypesForEthernetType()
    17  	initUnknownTypesForPPPType()
    18  	initUnknownTypesForIPProtocol()
    19  	initUnknownTypesForSCTPChunkType()
    20  	initUnknownTypesForPPPoECode()
    21  	initUnknownTypesForFDDIFrameControl()
    22  	initUnknownTypesForEAPOLType()
    23  	initUnknownTypesForProtocolFamily()
    24  	initUnknownTypesForDot11Type()
    25  	initUnknownTypesForUSBTransportType()
    26  	initActualTypeData()
    27  }
    28  
    29  // Decoder calls LinkTypeMetadata.DecodeWith's decoder.
    30  func (a LinkType) Decode(data []byte, p gopacket.PacketBuilder) error {
    31  	if int(a) >= 277 {
    32  		errDecoder := errorDecoderForLinkType(a)
    33  		return &errDecoder
    34  	}
    35  
    36  	return LinkTypeMetadata[a].DecodeWith.Decode(data, p)
    37  }
    38  
    39  // String returns LinkTypeMetadata.Name.
    40  func (a LinkType) String() string {
    41  	if int(a) >= 277 {
    42  		return "UnknownLinkType"
    43  	}
    44  
    45  	return LinkTypeMetadata[a].Name
    46  }
    47  
    48  // LayerType returns LinkTypeMetadata.LayerType.
    49  func (a LinkType) LayerType() gopacket.LayerType {
    50  	if int(a) >= 277 {
    51  		return 0
    52  	}
    53  
    54  	return LinkTypeMetadata[a].LayerType
    55  }
    56  
    57  type errorDecoderForLinkType int
    58  
    59  func (a *errorDecoderForLinkType) Decode(data []byte, p gopacket.PacketBuilder) error {
    60  	return a
    61  }
    62  func (a *errorDecoderForLinkType) Error() string {
    63  	return fmt.Sprintf("Unable to decode LinkType %d", int(*a))
    64  }
    65  
    66  var errorDecodersForLinkType [277]errorDecoderForLinkType
    67  var LinkTypeMetadata [277]EnumMetadata
    68  
    69  func initUnknownTypesForLinkType() {
    70  	for i := 0; i < 277; i++ {
    71  		errorDecodersForLinkType[i] = errorDecoderForLinkType(i)
    72  		LinkTypeMetadata[i] = EnumMetadata{
    73  			DecodeWith: &errorDecodersForLinkType[i],
    74  			Name:       "UnknownLinkType",
    75  		}
    76  	}
    77  }
    78  
    79  // Decoder calls EthernetTypeMetadata.DecodeWith's decoder.
    80  func (a EthernetType) Decode(data []byte, p gopacket.PacketBuilder) error {
    81  	if int(a) >= 65536 {
    82  		errDecoder := errorDecoderForEthernetType(a)
    83  		return &errDecoder
    84  	}
    85  
    86  	return EthernetTypeMetadata[a].DecodeWith.Decode(data, p)
    87  }
    88  
    89  // String returns EthernetTypeMetadata.Name.
    90  func (a EthernetType) String() string {
    91  	if int(a) >= 65536 {
    92  		return "UnknownEthernetType"
    93  	}
    94  
    95  	return EthernetTypeMetadata[a].Name
    96  }
    97  
    98  // LayerType returns EthernetTypeMetadata.LayerType.
    99  func (a EthernetType) LayerType() gopacket.LayerType {
   100  	if int(a) >= 65536 {
   101  		return 0
   102  	}
   103  
   104  	return EthernetTypeMetadata[a].LayerType
   105  }
   106  
   107  type errorDecoderForEthernetType int
   108  
   109  func (a *errorDecoderForEthernetType) Decode(data []byte, p gopacket.PacketBuilder) error {
   110  	return a
   111  }
   112  func (a *errorDecoderForEthernetType) Error() string {
   113  	return fmt.Sprintf("Unable to decode EthernetType %d", int(*a))
   114  }
   115  
   116  var errorDecodersForEthernetType [65536]errorDecoderForEthernetType
   117  var EthernetTypeMetadata [65536]EnumMetadata
   118  
   119  func initUnknownTypesForEthernetType() {
   120  	for i := 0; i < 65536; i++ {
   121  		errorDecodersForEthernetType[i] = errorDecoderForEthernetType(i)
   122  		EthernetTypeMetadata[i] = EnumMetadata{
   123  			DecodeWith: &errorDecodersForEthernetType[i],
   124  			Name:       "UnknownEthernetType",
   125  		}
   126  	}
   127  }
   128  
   129  // Decoder calls PPPTypeMetadata.DecodeWith's decoder.
   130  func (a PPPType) Decode(data []byte, p gopacket.PacketBuilder) error {
   131  	if int(a) >= 65536 {
   132  		errDecoder := errorDecoderForPPPType(a)
   133  		return &errDecoder
   134  	}
   135  
   136  	return PPPTypeMetadata[a].DecodeWith.Decode(data, p)
   137  }
   138  
   139  // String returns PPPTypeMetadata.Name.
   140  func (a PPPType) String() string {
   141  	if int(a) >= 65536 {
   142  		return "UnknownPPPType"
   143  	}
   144  
   145  	return PPPTypeMetadata[a].Name
   146  }
   147  
   148  // LayerType returns PPPTypeMetadata.LayerType.
   149  func (a PPPType) LayerType() gopacket.LayerType {
   150  	if int(a) >= 65536 {
   151  		return 0
   152  	}
   153  
   154  	return PPPTypeMetadata[a].LayerType
   155  }
   156  
   157  type errorDecoderForPPPType int
   158  
   159  func (a *errorDecoderForPPPType) Decode(data []byte, p gopacket.PacketBuilder) error {
   160  	return a
   161  }
   162  func (a *errorDecoderForPPPType) Error() string {
   163  	return fmt.Sprintf("Unable to decode PPPType %d", int(*a))
   164  }
   165  
   166  var errorDecodersForPPPType [65536]errorDecoderForPPPType
   167  var PPPTypeMetadata [65536]EnumMetadata
   168  
   169  func initUnknownTypesForPPPType() {
   170  	for i := 0; i < 65536; i++ {
   171  		errorDecodersForPPPType[i] = errorDecoderForPPPType(i)
   172  		PPPTypeMetadata[i] = EnumMetadata{
   173  			DecodeWith: &errorDecodersForPPPType[i],
   174  			Name:       "UnknownPPPType",
   175  		}
   176  	}
   177  }
   178  
   179  // Decoder calls IPProtocolMetadata.DecodeWith's decoder.
   180  func (a IPProtocol) Decode(data []byte, p gopacket.PacketBuilder) error {
   181  	if int(a) >= 256 {
   182  		errDecoder := errorDecoderForIPProtocol(a)
   183  		return &errDecoder
   184  	}
   185  
   186  	return IPProtocolMetadata[a].DecodeWith.Decode(data, p)
   187  }
   188  
   189  // String returns IPProtocolMetadata.Name.
   190  func (a IPProtocol) String() string {
   191  	if int(a) >= 256 {
   192  		return "UnknownIPProtocol"
   193  	}
   194  
   195  	return IPProtocolMetadata[a].Name
   196  }
   197  
   198  // LayerType returns IPProtocolMetadata.LayerType.
   199  func (a IPProtocol) LayerType() gopacket.LayerType {
   200  	if int(a) >= 256 {
   201  		return 0
   202  	}
   203  
   204  	return IPProtocolMetadata[a].LayerType
   205  }
   206  
   207  type errorDecoderForIPProtocol int
   208  
   209  func (a *errorDecoderForIPProtocol) Decode(data []byte, p gopacket.PacketBuilder) error {
   210  	return a
   211  }
   212  func (a *errorDecoderForIPProtocol) Error() string {
   213  	return fmt.Sprintf("Unable to decode IPProtocol %d", int(*a))
   214  }
   215  
   216  var errorDecodersForIPProtocol [256]errorDecoderForIPProtocol
   217  var IPProtocolMetadata [256]EnumMetadata
   218  
   219  func initUnknownTypesForIPProtocol() {
   220  	for i := 0; i < 256; i++ {
   221  		errorDecodersForIPProtocol[i] = errorDecoderForIPProtocol(i)
   222  		IPProtocolMetadata[i] = EnumMetadata{
   223  			DecodeWith: &errorDecodersForIPProtocol[i],
   224  			Name:       "UnknownIPProtocol",
   225  		}
   226  	}
   227  }
   228  
   229  // Decoder calls SCTPChunkTypeMetadata.DecodeWith's decoder.
   230  func (a SCTPChunkType) Decode(data []byte, p gopacket.PacketBuilder) error {
   231  	if int(a) >= 256 {
   232  		errDecoder := errorDecoderForSCTPChunkType(a)
   233  		return &errDecoder
   234  	}
   235  
   236  	return SCTPChunkTypeMetadata[a].DecodeWith.Decode(data, p)
   237  }
   238  
   239  // String returns SCTPChunkTypeMetadata.Name.
   240  func (a SCTPChunkType) String() string {
   241  	if int(a) >= 256 {
   242  		return "UnknownSCTPChunkType"
   243  	}
   244  
   245  	return SCTPChunkTypeMetadata[a].Name
   246  }
   247  
   248  // LayerType returns SCTPChunkTypeMetadata.LayerType.
   249  func (a SCTPChunkType) LayerType() gopacket.LayerType {
   250  	if int(a) >= 256 {
   251  		return 0
   252  	}
   253  
   254  	return SCTPChunkTypeMetadata[a].LayerType
   255  }
   256  
   257  type errorDecoderForSCTPChunkType int
   258  
   259  func (a *errorDecoderForSCTPChunkType) Decode(data []byte, p gopacket.PacketBuilder) error {
   260  	return a
   261  }
   262  func (a *errorDecoderForSCTPChunkType) Error() string {
   263  	return fmt.Sprintf("Unable to decode SCTPChunkType %d", int(*a))
   264  }
   265  
   266  var errorDecodersForSCTPChunkType [256]errorDecoderForSCTPChunkType
   267  var SCTPChunkTypeMetadata [256]EnumMetadata
   268  
   269  func initUnknownTypesForSCTPChunkType() {
   270  	for i := 0; i < 256; i++ {
   271  		errorDecodersForSCTPChunkType[i] = errorDecoderForSCTPChunkType(i)
   272  		SCTPChunkTypeMetadata[i] = EnumMetadata{
   273  			DecodeWith: &errorDecodersForSCTPChunkType[i],
   274  			Name:       "UnknownSCTPChunkType",
   275  		}
   276  	}
   277  }
   278  
   279  // Decoder calls PPPoECodeMetadata.DecodeWith's decoder.
   280  func (a PPPoECode) Decode(data []byte, p gopacket.PacketBuilder) error {
   281  	if int(a) >= 256 {
   282  		errDecoder := errorDecoderForPPPoECode(a)
   283  		return &errDecoder
   284  	}
   285  
   286  	return PPPoECodeMetadata[a].DecodeWith.Decode(data, p)
   287  }
   288  
   289  // String returns PPPoECodeMetadata.Name.
   290  func (a PPPoECode) String() string {
   291  	if int(a) >= 256 {
   292  		return "UnknownPPPoECode"
   293  	}
   294  
   295  	return PPPoECodeMetadata[a].Name
   296  }
   297  
   298  // LayerType returns PPPoECodeMetadata.LayerType.
   299  func (a PPPoECode) LayerType() gopacket.LayerType {
   300  	if int(a) >= 256 {
   301  		return 0
   302  	}
   303  
   304  	return PPPoECodeMetadata[a].LayerType
   305  }
   306  
   307  type errorDecoderForPPPoECode int
   308  
   309  func (a *errorDecoderForPPPoECode) Decode(data []byte, p gopacket.PacketBuilder) error {
   310  	return a
   311  }
   312  func (a *errorDecoderForPPPoECode) Error() string {
   313  	return fmt.Sprintf("Unable to decode PPPoECode %d", int(*a))
   314  }
   315  
   316  var errorDecodersForPPPoECode [256]errorDecoderForPPPoECode
   317  var PPPoECodeMetadata [256]EnumMetadata
   318  
   319  func initUnknownTypesForPPPoECode() {
   320  	for i := 0; i < 256; i++ {
   321  		errorDecodersForPPPoECode[i] = errorDecoderForPPPoECode(i)
   322  		PPPoECodeMetadata[i] = EnumMetadata{
   323  			DecodeWith: &errorDecodersForPPPoECode[i],
   324  			Name:       "UnknownPPPoECode",
   325  		}
   326  	}
   327  }
   328  
   329  // Decoder calls FDDIFrameControlMetadata.DecodeWith's decoder.
   330  func (a FDDIFrameControl) Decode(data []byte, p gopacket.PacketBuilder) error {
   331  	if int(a) >= 256 {
   332  		errDecoder := errorDecoderForFDDIFrameControl(a)
   333  		return &errDecoder
   334  	}
   335  
   336  	return FDDIFrameControlMetadata[a].DecodeWith.Decode(data, p)
   337  }
   338  
   339  // String returns FDDIFrameControlMetadata.Name.
   340  func (a FDDIFrameControl) String() string {
   341  	if int(a) >= 256 {
   342  		return "UnknownFDDIFrameControl"
   343  	}
   344  
   345  	return FDDIFrameControlMetadata[a].Name
   346  }
   347  
   348  // LayerType returns FDDIFrameControlMetadata.LayerType.
   349  func (a FDDIFrameControl) LayerType() gopacket.LayerType {
   350  	if int(a) >= 256 {
   351  		return 0
   352  	}
   353  
   354  	return FDDIFrameControlMetadata[a].LayerType
   355  }
   356  
   357  type errorDecoderForFDDIFrameControl int
   358  
   359  func (a *errorDecoderForFDDIFrameControl) Decode(data []byte, p gopacket.PacketBuilder) error {
   360  	return a
   361  }
   362  func (a *errorDecoderForFDDIFrameControl) Error() string {
   363  	return fmt.Sprintf("Unable to decode FDDIFrameControl %d", int(*a))
   364  }
   365  
   366  var errorDecodersForFDDIFrameControl [256]errorDecoderForFDDIFrameControl
   367  var FDDIFrameControlMetadata [256]EnumMetadata
   368  
   369  func initUnknownTypesForFDDIFrameControl() {
   370  	for i := 0; i < 256; i++ {
   371  		errorDecodersForFDDIFrameControl[i] = errorDecoderForFDDIFrameControl(i)
   372  		FDDIFrameControlMetadata[i] = EnumMetadata{
   373  			DecodeWith: &errorDecodersForFDDIFrameControl[i],
   374  			Name:       "UnknownFDDIFrameControl",
   375  		}
   376  	}
   377  }
   378  
   379  // Decoder calls EAPOLTypeMetadata.DecodeWith's decoder.
   380  func (a EAPOLType) Decode(data []byte, p gopacket.PacketBuilder) error {
   381  	if int(a) >= 256 {
   382  		errDecoder := errorDecoderForEAPOLType(a)
   383  		return &errDecoder
   384  	}
   385  
   386  	return EAPOLTypeMetadata[a].DecodeWith.Decode(data, p)
   387  }
   388  
   389  // String returns EAPOLTypeMetadata.Name.
   390  func (a EAPOLType) String() string {
   391  	if int(a) >= 256 {
   392  		return "UnknownEAPOLType"
   393  	}
   394  
   395  	return EAPOLTypeMetadata[a].Name
   396  }
   397  
   398  // LayerType returns EAPOLTypeMetadata.LayerType.
   399  func (a EAPOLType) LayerType() gopacket.LayerType {
   400  	if int(a) >= 256 {
   401  		return 0
   402  	}
   403  
   404  	return EAPOLTypeMetadata[a].LayerType
   405  }
   406  
   407  type errorDecoderForEAPOLType int
   408  
   409  func (a *errorDecoderForEAPOLType) Decode(data []byte, p gopacket.PacketBuilder) error {
   410  	return a
   411  }
   412  func (a *errorDecoderForEAPOLType) Error() string {
   413  	return fmt.Sprintf("Unable to decode EAPOLType %d", int(*a))
   414  }
   415  
   416  var errorDecodersForEAPOLType [256]errorDecoderForEAPOLType
   417  var EAPOLTypeMetadata [256]EnumMetadata
   418  
   419  func initUnknownTypesForEAPOLType() {
   420  	for i := 0; i < 256; i++ {
   421  		errorDecodersForEAPOLType[i] = errorDecoderForEAPOLType(i)
   422  		EAPOLTypeMetadata[i] = EnumMetadata{
   423  			DecodeWith: &errorDecodersForEAPOLType[i],
   424  			Name:       "UnknownEAPOLType",
   425  		}
   426  	}
   427  }
   428  
   429  // Decoder calls ProtocolFamilyMetadata.DecodeWith's decoder.
   430  func (a ProtocolFamily) Decode(data []byte, p gopacket.PacketBuilder) error {
   431  	if int(a) >= 256 {
   432  		errDecoder := errorDecoderForProtocolFamily(a)
   433  		return &errDecoder
   434  	}
   435  
   436  	return ProtocolFamilyMetadata[a].DecodeWith.Decode(data, p)
   437  }
   438  
   439  // String returns ProtocolFamilyMetadata.Name.
   440  func (a ProtocolFamily) String() string {
   441  	if int(a) >= 256 {
   442  		return "UnknownProtocolFamily"
   443  	}
   444  
   445  	return ProtocolFamilyMetadata[a].Name
   446  }
   447  
   448  // LayerType returns ProtocolFamilyMetadata.LayerType.
   449  func (a ProtocolFamily) LayerType() gopacket.LayerType {
   450  	if int(a) >= 256 {
   451  		return 0
   452  	}
   453  
   454  	return ProtocolFamilyMetadata[a].LayerType
   455  }
   456  
   457  type errorDecoderForProtocolFamily int
   458  
   459  func (a *errorDecoderForProtocolFamily) Decode(data []byte, p gopacket.PacketBuilder) error {
   460  	return a
   461  }
   462  func (a *errorDecoderForProtocolFamily) Error() string {
   463  	return fmt.Sprintf("Unable to decode ProtocolFamily %d", int(*a))
   464  }
   465  
   466  var errorDecodersForProtocolFamily [256]errorDecoderForProtocolFamily
   467  var ProtocolFamilyMetadata [256]EnumMetadata
   468  
   469  func initUnknownTypesForProtocolFamily() {
   470  	for i := 0; i < 256; i++ {
   471  		errorDecodersForProtocolFamily[i] = errorDecoderForProtocolFamily(i)
   472  		ProtocolFamilyMetadata[i] = EnumMetadata{
   473  			DecodeWith: &errorDecodersForProtocolFamily[i],
   474  			Name:       "UnknownProtocolFamily",
   475  		}
   476  	}
   477  }
   478  
   479  // Decoder calls Dot11TypeMetadata.DecodeWith's decoder.
   480  func (a Dot11Type) Decode(data []byte, p gopacket.PacketBuilder) error {
   481  	if int(a) >= 256 {
   482  		errDecoder := errorDecoderForDot11Type(a)
   483  		return &errDecoder
   484  	}
   485  
   486  	return Dot11TypeMetadata[a].DecodeWith.Decode(data, p)
   487  }
   488  
   489  // String returns Dot11TypeMetadata.Name.
   490  func (a Dot11Type) String() string {
   491  	if int(a) >= 256 {
   492  		return "UnknownDot11Type"
   493  	}
   494  
   495  	return Dot11TypeMetadata[a].Name
   496  }
   497  
   498  // LayerType returns Dot11TypeMetadata.LayerType.
   499  func (a Dot11Type) LayerType() gopacket.LayerType {
   500  	if int(a) >= 256 {
   501  		return 0
   502  	}
   503  
   504  	return Dot11TypeMetadata[a].LayerType
   505  }
   506  
   507  type errorDecoderForDot11Type int
   508  
   509  func (a *errorDecoderForDot11Type) Decode(data []byte, p gopacket.PacketBuilder) error {
   510  	return a
   511  }
   512  func (a *errorDecoderForDot11Type) Error() string {
   513  	return fmt.Sprintf("Unable to decode Dot11Type %d", int(*a))
   514  }
   515  
   516  var errorDecodersForDot11Type [256]errorDecoderForDot11Type
   517  var Dot11TypeMetadata [256]EnumMetadata
   518  
   519  func initUnknownTypesForDot11Type() {
   520  	for i := 0; i < 256; i++ {
   521  		errorDecodersForDot11Type[i] = errorDecoderForDot11Type(i)
   522  		Dot11TypeMetadata[i] = EnumMetadata{
   523  			DecodeWith: &errorDecodersForDot11Type[i],
   524  			Name:       "UnknownDot11Type",
   525  		}
   526  	}
   527  }
   528  
   529  // Decoder calls USBTransportTypeMetadata.DecodeWith's decoder.
   530  func (a USBTransportType) Decode(data []byte, p gopacket.PacketBuilder) error {
   531  	if int(a) >= 256 {
   532  		errDecoder := errorDecoderForUSBTransportType(a)
   533  		return &errDecoder
   534  	}
   535  
   536  	return USBTransportTypeMetadata[a].DecodeWith.Decode(data, p)
   537  }
   538  
   539  // String returns USBTransportTypeMetadata.Name.
   540  func (a USBTransportType) String() string {
   541  	if int(a) >= 256 {
   542  		return "UnknownUSBTransportType"
   543  	}
   544  
   545  	return USBTransportTypeMetadata[a].Name
   546  }
   547  
   548  // LayerType returns USBTransportTypeMetadata.LayerType.
   549  func (a USBTransportType) LayerType() gopacket.LayerType {
   550  	if int(a) >= 256 {
   551  		return 0
   552  	}
   553  
   554  	return USBTransportTypeMetadata[a].LayerType
   555  }
   556  
   557  type errorDecoderForUSBTransportType int
   558  
   559  func (a *errorDecoderForUSBTransportType) Decode(data []byte, p gopacket.PacketBuilder) error {
   560  	return a
   561  }
   562  func (a *errorDecoderForUSBTransportType) Error() string {
   563  	return fmt.Sprintf("Unable to decode USBTransportType %d", int(*a))
   564  }
   565  
   566  var errorDecodersForUSBTransportType [256]errorDecoderForUSBTransportType
   567  var USBTransportTypeMetadata [256]EnumMetadata
   568  
   569  func initUnknownTypesForUSBTransportType() {
   570  	for i := 0; i < 256; i++ {
   571  		errorDecodersForUSBTransportType[i] = errorDecoderForUSBTransportType(i)
   572  		USBTransportTypeMetadata[i] = EnumMetadata{
   573  			DecodeWith: &errorDecodersForUSBTransportType[i],
   574  			Name:       "UnknownUSBTransportType",
   575  		}
   576  	}
   577  }