More Macro Examples

Reference Documentation

product_line_custom
Intel® PAC
Napatech SmartNIC
category
Reference Information
Napatech Software Suite: More Macro Examples

Macros Delivered on File

This section shows the NTPL macros that are available in the FilterMacros.txt file.

Loading the Macros

To load the macros into the driver, use the ntpl tool:
ntpl -f FilterMacros.txt
The FilterMacros.txt file is included below:

//
// This file define NT filter macros and fields for MAC, IPv4/6, UDP and TCP.
// =========================================================================
//
// To load the macros into the driver, use the NtplTool tool:\n
// <i>ntpl -f FilterMacros.txt</i>\n
//

// Macro for definitions of MAC Fields
DefineMacro("mMacIG", "Data[DynOffset=DynOffLayer2Frame;Offset=0;DataType=ByteStr1;DataMask=[7:7]]")
  DefineMacro("mMacIG_IndividualAddress", "0")
  DefineMacro("mMacIG_GroupAddress",      "1")
  DefineMacro("mMacUL", "Data[DynOffset=DynOffLayer2Frame;Offset=0;DataType=ByteStr1;DataMask=[6:6]]")
  DefineMacro("mMacUL_GlobalAdministratedAddress",  "0")
  DefineMacro("mMacUL_LocallyAdministratedAddress", "1")
DefineMacro("mMacTypeLength", "Data[DynOffset=DynOffEtherTypeLen;Offset=0;DataType=ByteStr2]")
  DefineMacro("mMacTypeLength_IPv4", "0x0800")
  DefineMacro("mMacTypeLength_ARP",  "0x0806")
  DefineMacro("mMacTypeLength_RARP", "0x8035")
  DefineMacro("mMacTypeLength_IPv6", "0x86DD")
  DefineMacro("mMacTypeLength_FCoE", "0x8906")
DefineMacro("mMacRawTypeLength", "Data[DynOffset=DynOffLayer2Frame;Offset=12;DataType=ByteStr2]")
  DefineMacro("mMacRawTypeLength_VLAN", "0x8100")
// MAC field definitions (can be used in hash recipes)
Define DstMac = Field(StartOfFrame[0]/48)
Define SrcMac = Field(StartOfFrame[6]/48)

// Macros for definition of VLAN Fields
DefineMacro("mVlan0UserPriority", "Data[DynOffset=DynOffLayer2Frame;Offset=14;DataType=ByteStr2;DataMask=[15:13]]")
DefineMacro("mVlan0CFI", "Data[DynOffset=DynOffLayer2Frame;Offset=14;DataType=ByteStr2;DataMask=[12:12]]")
DefineMacro("mVlan0VlanId", "Data[DynOffset=DynOffLayer2Frame;Offset=14;DataType=ByteStr2;DataMask=[11:0]]")
DefineMacro("mVlan0TypeLength", "Data[DynOffset=DynOffLayer2Frame;Offset=16;DataType=ByteStr2]")
DefineMacro("mVlan1UserPriority", "Data[DynOffset=DynOffLayer2Frame;Offset=18;DataType=ByteStr2;DataMask=[15:13]]")
DefineMacro("mVlan1CFI", "Data[DynOffset=DynOffLayer2Frame;Offset=18;DataType=ByteStr2;DataMask=[12:12]]")
  DefineMacro("mVlanCFI_Ethernet",  "0")
  DefineMacro("mVlanCFI_TokenRing", "1")
DefineMacro("mVlan1VlanId", "Data[DynOffset=DynOffLayer2Frame;Offset=18;DataType=ByteStr2;DataMask=[11:0]]")
DefineMacro("mVlan1TypeLength", "Data[DynOffset=DynOffLayer2Frame;Offset=20;DataType=ByteStr2]")
DefineMacro("mVlan2UserPriority", "Data[DynOffset=DynOffLayer2Frame;Offset=22;DataType=ByteStr2;DataMask=[15:13]]")
DefineMacro("mVlan2CFI", "Data[DynOffset=DynOffLayer2Frame;Offset=22;DataType=ByteStr2;DataMask=[12:12]]")
DefineMacro("mVlan2VlanId", "Data[DynOffset=DynOffLayer2Frame;Offset=22;DataType=ByteStr2;DataMask=[11:0]]")
DefineMacro("mVlan2TypeLength", "Data[DynOffset=DynOffLayer2Frame;Offset=24;DataType=ByteStr2]")
// Field definitions for VLAN (can be used in hash recipes)
Define Vlan0TCI = Field(FirstVLAN[2]/16)
Define Vlan1TCI = Field(FirstVLAN[6]/16)
Define Vlan2TCI = Field(FirstVLAN[10]/16)

// Macros for definition of the ARP Protocol Header
// Definition of the ARP protocol header (only valid for IPv4 and Ethernet)
// NOTE: When using these ARP macros, <FilterExpressionSpec> must also
// include a test on the MAC type/length field to determine if the frame
// is an ARP frame (mMacTypeLength == mMacTypeLength_ARP).
DefineMacro("mArpHardwareType",       "Data[DynOffset=DynOffLayer2Data;Offset=0;DataType=ByteStr2]")
DefineMacro("mArpHardwareType_Ethernet", "1")
DefineMacro("mArpProtocolType",       "Data[DynOffset=DynOffLayer2Data;Offset=2;DataType=ByteStr2]")
DefineMacro("mArpHardwareAddrLength", "Data[DynOffset=DynOffLayer2Data;Offset=4;DataType=ByteStr1]")
DefineMacro("mArpProtocolAddrLength", "Data[DynOffset=DynOffLayer2Data;Offset=5;DataType=ByteStr1]")
DefineMacro("mArpOperation",          "Data[DynOffset=DynOffLayer2Data;Offset=6;DataType=ByteStr2]")
  DefineMacro("mArpOperation_Request", "1")
  DefineMacro("mArpOperation_Replay",  "2")
DefineMacro("mArpSenderProtocolAddr", "Data[DynOffset=DynOffLayer2Data;Offset=14;DataType=ByteStr4]")
DefineMacro("mArpTragetProtocolAddr", "Data[DynOffset=DynOffLayer2Data;Offset=24;DataType=ByteStr4]")

// Macros for definition of IP Fields Common to IPv4 and IPv6
DefineMacro("mIPVersion", "Data[DynOffset=DynOffIPv4Frame;Offset=0;DataType=ByteStr1;DataMask=[7:4]]")
  DefineMacro("mIPVersion_4", "4")
  DefineMacro("mIPVersion_6", "6")

// Macros for definition of the IPv4 Protocol Header
DefineMacro("mIPv4Version",        "Data[DynOffset=DynOffIPv4Frame;Offset=0;DataType=ByteStr1;DataMask=[7:4]]")
  DefineMacro("mIPv4Version_4", "4")
  DefineMacro("mIPv4Version_6", "6")
DefineMacro("mIPv4IHL",            "Data[DynOffset=DynOffIPv4Frame;Offset=0;DataType=ByteStr1;DataMask=[3:0]]")
DefineMacro("mIPv4Tos",            "Data[DynOffset=DynOffIPv4Frame;Offset=1;DataType=ByteStr1]")
  DefineMacro("mIPv4Tos_Precedence", "Data[DynOffset=DynOffIPv4Frame;Offset=1;DataType=ByteStr1;DataMask=[7:5]]")
    DefineMacro("mIPv4Tos_Precedence_Routine",             "0")
    DefineMacro("mIPv4Tos_Precedence_Priority",            "1")
    DefineMacro("mIPv4Tos_Precedence_Immediate",           "2")
    DefineMacro("mIPv4Tos_Precedence_Flash",               "3")
    DefineMacro("mIPv4Tos_Precedence_FlashOverride",       "4")
    DefineMacro("mIPv4Tos_Precedence_CRITIC_ECP",          "5")
    DefineMacro("mIPv4Tos_Precedence_InternetworkControl", "6")
    DefineMacro("mIPv4Tos_Precedence_NetworkControl",      "7")
  DefineMacro("mIPv4Tos_Delay", "Data[DynOffset=DynOffIPv4Frame;Offset=1;DataType=ByteStr1;DataMask=[4:4]]")
    DefineMacro("mIPv4Tos_Delay_NormalDelay", "0")
    DefineMacro("mIPv4Tos_Delay_LowDelay",    "1")
  DefineMacro("mIPv4Tos_Throughput", "Data[DynOffset=DynOffIPv4Frame;Offset=1;DataType=ByteStr1;DataMask=[3:3]]")
    DefineMacro("mIPv4Tos_Throughput_NormalThroughput", "0")
    DefineMacro("mIPv4Tos_Throughput_HighThroughput",   "1")
  DefineMacro("mIPv4Tos_Reliability", "Data[DynOffset=DynOffIPv4Frame;Offset=1;DataType=ByteStr1;DataMask=[2:2]]")
    DefineMacro("mIPv4Tos_Reliability_NormalReliability", "0")
    DefineMacro("mIPv4Tos_Reliability_HighReliability",   "1")
DefineMacro("mIPv4TotalLength",    "Data[DynOffset=DynOffIPv4Frame;Offset=2;DataType=ByteStr2]")
DefineMacro("mIPv4Identification", "Data[DynOffset=DynOffIPv4Frame;Offset=4;DataType=ByteStr2]")
DefineMacro("mIPv4Flags",          "Data[DynOffset=DynOffIPv4Frame;Offset=6;DataType=ByteStr1;DataMask=[7:5]]")
  DefineMacro("mIPv4Flags_Zero",          "Data[DynOffset=DynOffIPv4Frame;Offset=6;DataType=ByteStr1;DataMask=[7:7]]")
  DefineMacro("mIPv4Flags_Zero_Zero", "0")                                 // This bit must be zero.
  DefineMacro("mIPv4Flags_DontFragment",  "Data[DynOffset=DynOffIPv4Frame;Offset=6;DataType=ByteStr1;DataMask=[6:6]]")
    DefineMacro("mIPv4Flags_DontFragment_MayFragment",  "0")
    DefineMacro("mIPv4Flags_DontFragment_DontFragment", "1")
  DefineMacro("mIPv4Flags_MoreFragments", "Data[DynOffset=DynOffIPv4Frame;Offset=6;DataType=ByteStr1;DataMask=[5:5]]")
    DefineMacro("mIPv4Flags_MoreFragments_LastFragment",  "0")
    DefineMacro("mIPv4Flags_MoreFragments_MoreFragments", "1")
DefineMacro("mIPv4FragmentOffset", "Data[DynOffset=DynOffIPv4Frame;Offset=6;DataType=ByteStr2;DataMask=[12:0]]")
DefineMacro("mIPv4TTL",            "Data[DynOffset=DynOffIPv4Frame;Offset=8;DataType=ByteStr1]")
DefineMacro("mIPv4Protocol",       "Data[DynOffset=DynOffIPv4Frame;Offset=9;DataType=ByteStr1]")
  DefineMacro("mIPv4Protocol_ICMP",   "1")
  DefineMacro("mIPv4Protocol_IGMP",   "2")
  DefineMacro("mIPv4Protocol_IPinIP", "4")
  DefineMacro("mIPv4Protocol_TCP",    "6")
  DefineMacro("mIPv4Protocol_UDP",    "17")
  DefineMacro("mIPv4Protocol_GRE",    "47")
  DefineMacro("mIPv4Protocol_L2TP",   "115")
  DefineMacro("mIPv4Protocol_SCTP",   "132")
DefineMacro("mIPv4HeaderChecksum", "Data[DynOffset=DynOffIPv4Frame;Offset=10;DataType=ByteStr2]")
DefineMacro("mIPv4SrcAddr",        "Data[DynOffset=DynOffIPv4Frame;Offset=12;DataType=ByteStr4]")
DefineMacro("mIPv4SrcAddrIP",      "Data[DynOffset=DynOffIPv4Frame;Offset=12;DataType=IPv4Addr]")
DefineMacro("mIPv4DestAddr",       "Data[DynOffset=DynOffIPv4Frame;Offset=16;DataType=ByteStr4]")
DefineMacro("mIPv4DestAddrIP",     "Data[DynOffset=DynOffIPv4Frame;Offset=16;DataType=IPv4Addr]")
// Field definitions for IPv4 (can be used in hash recipes and key matching)
Define SrcIPv4 = Field(Layer3Header[12]/32)
Define DestIPv4 = Field(Layer3Header[16]/32)
// Fragment identification field (can be used in hash recipes)
Define IdentIPv4 = Field(IdentificationField[0]/16)


// Macros for definition of the inner tunnel IPv4 Protocol Header
DefineMacro("mInnerIPv4Version",        "Data[DynOffset=DynOffInnerIPv4Frame;Offset=0;DataType=ByteStr1;DataMask=[7:4]]")
DefineMacro("mInnerIPv4IHL",            "Data[DynOffset=DynOffInnerIPv4Frame;Offset=0;DataType=ByteStr1;DataMask=[3:0]]")
DefineMacro("mInnerIPv4Tos",            "Data[DynOffset=DynOffInnerIPv4Frame;Offset=1;DataType=ByteStr1]")
  DefineMacro("mInnerIPv4Tos_Precedence", "Data[DynOffset=DynOffInnerIPv4Frame;Offset=1;DataType=ByteStr1;DataMask=[7:5]]")
  DefineMacro("mInnerIPv4Tos_Delay", "Data[DynOffset=DynOffInnerIPv4Frame;Offset=1;DataType=ByteStr1;DataMask=[4:4]]")
  DefineMacro("mInnerIPv4Tos_Throughput", "Data[DynOffset=DynOffInnerIPv4Frame;Offset=1;DataType=ByteStr1;DataMask=[3:3]]")
  DefineMacro("mInnerIPv4Tos_Reliability", "Data[DynOffset=DynOffInnerIPv4Frame;Offset=1;DataType=ByteStr1;DataMask=[2:2]]")
DefineMacro("mInnerIPv4TotalLength",    "Data[DynOffset=DynOffInnerIPv4Frame;Offset=2;DataType=ByteStr2]")
DefineMacro("mInnerIPv4Identification", "Data[DynOffset=DynOffInnerIPv4Frame;Offset=4;DataType=ByteStr2]")
DefineMacro("mInnerIPv4Flags",          "Data[DynOffset=DynOffInnerIPv4Frame;Offset=6;DataType=ByteStr1;DataMask=[7:5]]")
  DefineMacro("mInnerIPv4Flags_Zero",          "Data[DynOffset=DynOffInnerIPv4Frame;Offset=6;DataType=ByteStr1;DataMask=[7:7]]")
  DefineMacro("mInnerIPv4Flags_DontFragment",  "Data[DynOffset=DynOffInnerIPv4Frame;Offset=6;DataType=ByteStr1;DataMask=[6:6]]")
  DefineMacro("mInnerIPv4Flags_MoreFragments", "Data[DynOffset=DynOffInnerIPv4Frame;Offset=6;DataType=ByteStr1;DataMask=[5:5]]")
DefineMacro("mInnerIPv4FragmentOffset", "Data[DynOffset=DynOffInnerIPv4Frame;Offset=6;DataType=ByteStr2;DataMask=[12:0]]")
DefineMacro("mInnerIPv4TTL",            "Data[DynOffset=DynOffInnerIPv4Frame;Offset=8;DataType=ByteStr1]")
DefineMacro("mInnerIPv4Protocol",       "Data[DynOffset=DynOffInnerIPv4Frame;Offset=9;DataType=ByteStr1]")
DefineMacro("mInnerIPv4HeaderChecksum", "Data[DynOffset=DynOffInnerIPv4Frame;Offset=10;DataType=ByteStr2]")
DefineMacro("mInnerIPv4SrcAddr",        "Data[DynOffset=DynOffInnerIPv4Frame;Offset=12;DataType=ByteStr4]")
DefineMacro("mInnerIPv4DestAddr",       "Data[DynOffset=DynOffInnerIPv4Frame;Offset=16;DataType=ByteStr4]")
// Field definitions for tunneled IPv4 (can be used in hash recipes and key matching)
Define InnerSrcIPv4 = Field(InnerLayer3Header[12]/32)
Define InnerDestIPv4 = Field(InnerLayer3Header[16]/32)
// Fragment identification field (can be used in hash recipes)
Define InnerIdentIPv4 = Field(InnerIdentificationField[0]/16)


// Macros for definition of the IPv6 Protocol Header
DefineMacro("mIPv6Version",        "Data[DynOffset=DynOffIPv6Frame;Offset=0;DataType=ByteStr1;DataMask=[7:4]]")
  DefineMacro("mIPv6Version_4", "4")
  DefineMacro("mIPv6Version_6", "6")
DefineMacro("mIPv6TrafficClass",   "Data[DynOffset=DynOffIPv6Frame;Offset=0;DataType=ByteStr2;DataMask=[11:4]]")
DefineMacro("mIPv6FlowLabel",      "Data[DynOffset=DynOffIPv6Frame;Offset=0;DataType=ByteStr4;DataMask=[19:0]]")
DefineMacro("mIPv6PayloadLength",  "Data[DynOffset=DynOffIPv6Frame;Offset=4;DataType=ByteStr2]")
DefineMacro("mIPv6NextHeader",     "Data[DynOffset=DynOffIPv6Frame;Offset=6;DataType=ByteStr1]")
  DefineMacro("mIPv6NextHeader_HopByHop",           "0")
  DefineMacro("mIPv6NextHeader_TCP",                "6")
  DefineMacro("mIPv6NextHeader_UDP",                "17")
  DefineMacro("mIPv6NextHeader_RoutingHeader",      "43")
  DefineMacro("mIPv6NextHeader_FragmentHeader",     "44")
  DefineMacro("mIPv6NextHeader_GRE",                "47")
  DefineMacro("mIPv6NextHeader_ESP",                "50")
  DefineMacro("mIPv6NextHeader_AH",                 "51")
  DefineMacro("mIPv6NextHeader_ICMP",               "58")
  DefineMacro("mIPv6NextHeader_DestinationOptions", "60")
  DefineMacro("mIPv6NextHeader_SCTP",               "132")
DefineMacro("mIPv6HopLimit",       "Data[DynOffset=DynOffIPv6Frame;Offset=7;DataType=ByteStr1]")
// Field definitions for IPv6 (can be used in hash recipes and key matching)
Define SrcIPv6 = Field(Layer3Header[8]/128)
Define DestIPv6 = Field(Layer3Header[24]/128)
// The last destination of the packet in the presence of routing header, else the same as DestIPv6
Define FinalDestIPv6 = Field(DestinationIP[0]/128)
// Fragment identification field (can be used in hash recipes)
Define IdentIPv6 = Field(IdentificationField[0]/32)


// Macros for definition of the inner tunnel IPv6 Protocol Header
DefineMacro("mInnerIPv6Version",        "Data[DynOffset=DynOffInnerIPv6Frame;Offset=0;DataType=ByteStr1;DataMask=[7:4]]")
DefineMacro("mInnerIPv6TrafficClass",   "Data[DynOffset=DynOffInnerIPv6Frame;Offset=0;DataType=ByteStr2;DataMask=[11:4]]")
DefineMacro("mInnerIPv6FlowLabel",      "Data[DynOffset=DynOffInnerIPv6Frame;Offset=0;DataType=ByteStr4;DataMask=[19:0]]")
DefineMacro("mInnerIPv6PayloadLength",  "Data[DynOffset=DynOffInnerIPv6Frame;Offset=4;DataType=ByteStr2]")
DefineMacro("mInnerIPv6NextHeader",     "Data[DynOffset=DynOffInnerIPv6Frame;Offset=6;DataType=ByteStr1]")
DefineMacro("mInnerIPv6HopLimit",       "Data[DynOffset=DynOffInnerIPv6Frame;Offset=7;DataType=ByteStr1]")
// Field definitions for tunneled IPv6 (can be used in hash recipes and key matching)
Define InnerSrcIPv6 = Field(InnerLayer3Header[8]/128)
Define InnerDstIPv6 = Field(InnerLayer3Header[24]/128)
// The last destination of the inner packet in the presence of routing header, else the same as InnerDestIPv6
Define InnerFinalDstIPv6 = Field(InnerDestinationIP[0]/128)
// Fragment identification field (can be used in hash recipes)
Define InnerIdentIPv6 = Field(InnerIdentificationField[0]/32)


// Macros for definition of the UDP Protocol Header
DefineMacro("mUdpSrcPort",  "Data[DynOffset=DynOffUDPFrame;Offset=0;DataType=ByteStr2]")
DefineMacro("mUdpDestPort", "Data[DynOffset=DynOffUDPFrame;Offset=2;DataType=ByteStr2]")
  DefineMacro("mUdpPort_Bootp",                   "68")
  DefineMacro("mUdpPort_DHCP",                    "68")
  DefineMacro("mUdpPort_GTP_Control",             "2123")
  DefineMacro("mUdpPort_GTP_User",                "2152")
  DefineMacro("mUdpPort_GTP_v0-U",                "3386")
  DefineMacro("mUdpPort_GTP_v1-U",                "2152")
  DefineMacro("mUdpPort_GTP_v1v2-C",              "2123")
DefineMacro("mUdpLength",   "Data[DynOffset=DynOffUDPFrame;Offset=4;DataType=ByteStr2]")
DefineMacro("mUdpChecksum", "Data[DynOffset=DynOffUDPFrame;Offset=6;DataType=ByteStr2]")
// Field definitions for UDP protocol header
Define SrcUdp = Field(Layer4Header[0]/16)
Define DestUdp = Field(Layer4Header[2]/16)


// Macros for definition of the inner tunnel UDP Protocol Header
DefineMacro("mInnerUdpSrcPort",  "Data[DynOffset=DynOffInnerUDPFrame;Offset=0;DataType=ByteStr2]")
DefineMacro("mInnerUdpDestPort", "Data[DynOffset=DynOffInnerUDPFrame;Offset=2;DataType=ByteStr2]")
DefineMacro("mInnerUdpLength",   "Data[DynOffset=DynOffInnerUDPFrame;Offset=4;DataType=ByteStr2]")
DefineMacro("mInnerUdpChecksum", "Data[DynOffset=DynOffInnerUDPFrame;Offset=6;DataType=ByteStr2]")
// Field definitions for the tunneled UDP header (can be used in hash recipes)
Define InnerSrcUdp = Field(InnerLayer4Header[0]/16)
Define InnerDestUdp = Field(InnerLayer4Header[2]/16)

// Macros for definition of the TCP protocol header.
DefineMacro("mTcpSrcPort",       "Data[DynOffset=DynOffTCPFrame;Offset=0;DataType=ByteStr2]")
DefineMacro("mTcpDestPort",      "Data[DynOffset=DynOffTCPFrame;Offset=2;DataType=ByteStr2]")
  DefineMacro("mTcpPort_FTP_Data",                "20")
  DefineMacro("mTcpPort_FTP_Control",             "21")
  DefineMacro("mTcpPort_SSH",                     "22")
  DefineMacro("mTcpPort_Telnet",                  "23")
  DefineMacro("mTcpPort_SMTP",                    "25")
  DefineMacro("mTcpPort_DNS",                     "53")
  DefineMacro("mTcpPort_HTTP",                    "80")
  DefineMacro("mTcpPort_Kerberos",                "88")
  DefineMacro("mTcpPort_POP3",                    "110")
  DefineMacro("mTcpPort_NNTP",                    "119")
  DefineMacro("mTcpPort_NTP",                     "123")
  DefineMacro("mTcpPort_NetBIOS_NameService",     "137")
  DefineMacro("mTcpPort_NetBIOS_DatagramService", "138")
  DefineMacro("mTcpPort_NetBIOS_SessionService",  "139")
  DefineMacro("mTcpPort_IMAP",                    "143")
  DefineMacro("mTcpPort_SNMP",                    "161")
  DefineMacro("mTcpPort_SNMPTRAP",                "162")
  DefineMacro("mTcpPort_CMIP_Manager",            "163")
  DefineMacro("mTcpPort_CMIP_Agent",              "164")
  DefineMacro("mTcpPort_IRC",                     "194")
  DefineMacro("mTcpPort_HTTPS",                   "443")
  DefineMacro("mTcpPort_Syslog",                  "514")
  DefineMacro("mTcpPort_NNTPS",                   "563")
  DefineMacro("mTcpPort_FTP_DataSecure",          "989")
  DefineMacro("mTcpPort_FTP_ControlSecure",       "990")
  DefineMacro("mTcpPort_Radius",                  "1812")
  DefineMacro("mTcpPort_RadiusAcct",              "1813")
  DefineMacro("mTcpPort_GTP_Control",             "2123")
  DefineMacro("mTcpPort_GTP_User",                "2152")
  DefineMacro("mTcpPort_GTP_v0-U",                "3386")
DefineMacro("mTcpSeqNumber",     "Data[DynOffset=DynOffTCPFrame;Offset=4;DataType=ByteStr4]")
DefineMacro("mTcpAckNumber",     "Data[DynOffset=DynOffTCPFrame;Offset=8;DataType=ByteStr4]")
DefineMacro("mTcpOffset",        "Data[DynOffset=DynOffTCPFrame;Offset=12;DataType=ByteStr2;DataMask=[15:12]]")
DefineMacro("mTcpReserved",      "Data[DynOffset=DynOffTCPFrame;Offset=12;DataType=ByteStr2;DataMask=[11:6]]")
DefineMacro("mTcpControlBits",   "Data[DynOffset=DynOffTCPFrame;Offset=13;DataType=ByteStr1;DataMask=[5:0]]")
  DefineMacro("mTcpControlBits_Urg",   "Data[DynOffset=DynOffTCPFrame;Offset=13;DataType=ByteStr1;DataMask=[5:5]]")
  DefineMacro("mTcpControlBits_ACK",   "Data[DynOffset=DynOffTCPFrame;Offset=13;DataType=ByteStr1;DataMask=[4:4]]")
  DefineMacro("mTcpControlBits_PSH",   "Data[DynOffset=DynOffTCPFrame;Offset=13;DataType=ByteStr1;DataMask=[3:3]]")
  DefineMacro("mTcpControlBits_RST",   "Data[DynOffset=DynOffTCPFrame;Offset=13;DataType=ByteStr1;DataMask=[2:2]]")
  DefineMacro("mTcpControlBits_SYN",   "Data[DynOffset=DynOffTCPFrame;Offset=13;DataType=ByteStr1;DataMask=[1:1]]")
  DefineMacro("mTcpControlBits_FIN",   "Data[DynOffset=DynOffTCPFrame;Offset=13;DataType=ByteStr1;DataMask=[0:0]]")
DefineMacro("mTcpWindow",        "Data[DynOffset=DynOffTCPFrame;Offset=14;DataType=ByteStr2]")
DefineMacro("mTcpChecksum",      "Data[DynOffset=DynOffTCPFrame;Offset=16;DataType=ByteStr2]")
DefineMacro("mTcpUrgentPointer", "Data[DynOffset=DynOffTCPFrame;Offset=18;DataType=ByteStr2]")
// Field definitions for the TCP protocol header (can be used in hash recipes)
Define SrcTcp = Field(Layer4Header[0]/16)
Define DestTcp = Field(Layer4Header[2]/16)

// Macros for definition of the inner tunnel TCP protocol header.
DefineMacro("mInnerTcpSrcPort",       "Data[DynOffset=DynOffInnerTCPFrame;Offset=0;DataType=ByteStr2]")
DefineMacro("mInnerTcpDestPort",      "Data[DynOffset=DynOffInnerTCPFrame;Offset=2;DataType=ByteStr2]")
DefineMacro("mInnerTcpSeqNumber",     "Data[DynOffset=DynOffInnerTCPFrame;Offset=4;DataType=ByteStr4]")
DefineMacro("mInnerTcpAckNumber",     "Data[DynOffset=DynOffInnerTCPFrame;Offset=8;DataType=ByteStr4]")
DefineMacro("mInnerTcpOffset",        "Data[DynOffset=DynOffInnerTCPFrame;Offset=12;DataType=ByteStr2;DataMask=[15:12]]")
DefineMacro("mInnerTcpReserved",      "Data[DynOffset=DynOffInnerTCPFrame;Offset=12;DataType=ByteStr2;DataMask=[11:6]]")
DefineMacro("mInnerTcpControlBits",   "Data[DynOffset=DynOffInnerTCPFrame;Offset=13;DataType=ByteStr1;DataMask=[5:0]]")
DefineMacro("mInnerTcpWindow",        "Data[DynOffset=DynOffInnerTCPFrame;Offset=14;DataType=ByteStr2]")
DefineMacro("mInnerTcpChecksum",      "Data[DynOffset=DynOffInnerTCPFrame;Offset=16;DataType=ByteStr2]")
DefineMacro("mInnerTcpUrgentPointer", "Data[DynOffset=DynOffInnerTCPFrame;Offset=18;DataType=ByteStr2]")
// Field definitions for the tunneled TCP header (can be used in hash recipes)
Define InnerSrcTcp = Field(InnerLayer4Header[0]/16)
Define InnerDestTcp = Field(InnerLayer4Header[2]/16)

// Macros for definition of Hash Masks.
DefineMacro("mHashMaskLastMPLS", "HashWord0")
DefineMacro("mHashMaskMPLS1", "HashWord0")
DefineMacro("mHashMaskMPLS2", "HashWord1")
DefineMacro("mHashMaskMPLS3", "HashWord2")
DefineMacro("mHashMaskMPLS4", "HashWord3")
DefineMacro("mHashMaskMPLS5", "HashWord4")
DefineMacro("mHashMaskMPLS6", "HashWord5")
DefineMacro("mHashMaskMPLS7", "HashWord6")
DefineMacro("mHashMaskLastVLANId", "HashWord0")
DefineMacro("mHashMaskVLANId1", "HashWord0")
DefineMacro("mHashMaskVLANId2", "HashWord1")
DefineMacro("mHashMaskVLANId3", "HashWord2")
DefineMacro("mHashMaskIPv4SrcAddr", "HashWord0")
DefineMacro("mHashMaskIPv4DstAddr", "HashWord4")
DefineMacro("mHashMaskIPv4MaxAddr", "HashWord0")
DefineMacro("mHashMaskIPv4MinAddr", "HashWord4")
DefineMacro("mHashMaskIPv6SrcAddr", "HashWord0_3")
DefineMacro("mHashMaskIPv6DstAddr", "HashWord4_7")
DefineMacro("mHashMaskIPv6MaxAddr", "HashWord0_3")
DefineMacro("mHashMaskIPv6MinAddr", "HashWord4_7")
DefineMacro("mHashMaskSrcPort", "HashWord8_Lo")
DefineMacro("mHashMaskDstPort", "HashWord8_Hi")
DefineMacro("mHashMaskMaxPort", "HashWord8_Lo")
DefineMacro("mHashMaskMinPort", "HashWord8_Hi")
DefineMacro("mHashMaskProtocol", "HashWord9_Lo")
DefineMacro("mHashMaskGREKey", "HashWord8")
DefineMacro("mHashMaskSCTPVerifyTag", "HashWord9")
DefineMacro("mHashMaskFlowLabel", "HashWord8_Lo")
DefineMacro("mHashMaskGTPTEID", "HashWord8")

// Macros for definitions of Deduplication Masks.
DefineMacro("mDeduplicationMask_IPv4_DSCP", "IPv4MaskWord0=0xFF03FFFF")
DefineMacro("mDeduplicationMask_IPv4_ECN", "IPv4MaskWord0=0xFFFCFFFF")
DefineMacro("mDeduplicationMask_IPv4_ID", "IPv4MaskWord1=0x0000FFFF")
DefineMacro("mDeduplicationMask_IPv4_Flags", "IPv4MaskWord1=0xFFFF1FFF")
DefineMacro("mDeduplicationMask_IPv4_TTL", "IPv4MaskWord2=0x00FFFFFF")
DefineMacro("mDeduplicationMask_IPv4_CHKSUM", "IPv4MaskWord2=0xFFFF0000")
DefineMacro("mDeduplicationMask_IPv6_DSCP", "IPv6MaskWord0=0xF03FFFFF")
DefineMacro("mDeduplicationMask_IPv6_ECN", "IPv6MaskWord0=0xFFCFFFFF")
DefineMacro("mDeduplicationMask_IPv6_Label", "IPv6MaskWord0=0xFFF00000")
DefineMacro("mDeduplicationMask_IPv6_Limit", "IPv6MaskWord1=0xFFFFFF00")

// Macros for MPLS label and bottom stack flag.
DefineMacro("MPLS0_Value","Data[DynOffset=DynOffLayer2Data;Offset=0;DataType=ByteStr4;DataMask=[31:12]]")
DefineMacro("MPLS0_Stack","Data[DynOffset=DynOffLayer2Data;Offset=0;DataType=ByteStr4;DataMask=[8:8]]")
DefineMacro("MPLS1_Value","Data[DynOffset=DynOffLayer2Data;Offset=4;DataType=ByteStr4;DataMask=[31:12]]")
DefineMacro("MPLS1_Stack","Data[DynOffset=DynOffLayer2Data;Offset=4;DataType=ByteStr4;DataMask=[8:8]]")
DefineMacro("MPLS2_Value","Data[DynOffset=DynOffLayer2Data;Offset=8;DataType=ByteStr4;DataMask=[31:12]]")
DefineMacro("MPLS2_Stack","Data[DynOffset=DynOffLayer2Data;Offset=8;DataType=ByteStr4;DataMask=[8:8]]")

// Hash recipes
Define HashLastMplsLabel = Hash(HashWord0_3=Layer3Header[-4]/20)
Define HashMplsLabels1 = Hash(HashWord0_3=FirstMpls[0]/20)
Define HashMplsLabels2 = Hash(HashWord0_3={0xfffff000fffff000:FirstMpls[0]/64})
Define HashMplsLabels3 = Hash(HashWord0_3={0xfffff000fffff000fffff000:FirstMpls[0]/96})
Define HashMplsLabels4 = Hash(HashWord0_3={0xfffff000fffff000fffff000fffff000:FirstMpls[0]/128})
Define HashMplsLabels5 = Hash(HashWord0_3={0xfffff000fffff000fffff000fffff000:FirstMpls[0]/128},HashWord4_7=FirstMpls[16]/20)
Define HashMplsLabels6 = Hash(HashWord0_3={0xfffff000fffff000fffff000fffff000:FirstMpls[0]/128},HashWord4_7={0xfffff000fffff000:FirstMpls[16]/64})
Define HashMplsLabels7 = Hash(HashWord0_3={0xfffff000fffff000fffff000fffff000:FirstMpls[0]/128},HashWord4_7={0xfffff000fffff000fffff000:FirstMpls[16]/96})
Define Hash2TupleIPv4 = Hash(HashWord0_3=Layer3Header[12]/32,HashWord4_7=Layer3Header[16]/32)
Define Hash2TupleIPv6 = Hash(HashWord0_3=Layer3Header[8]/128,HashWord4_7=Layer3Header[24]/128)
Define Hash2TupleSortedIPv4 = Hash(HashWord0_3=Layer3Header[12]/32,HashWord4_7=Layer3Header[16]/32,XOR=True)
Define Hash2TupleSortedIPv6 = Hash(HashWord0_3=Layer3Header[8]/128,HashWord4_7=Layer3Header[24]/128,XOR=True)
Define HashLastVlanId = Hash(HashWord0_3={0xfff:FirstMPLS[-6]/32})
Define HashVlanIds1 = Hash(HashWord0_3={0xfff:FirstVlan[0]/32})
Define HashVlanIds2 = Hash(HashWord0_3={0xfff00000fff:FirstVlan[0]/64})
Define HashVlanIds3 = Hash(HashWord0_3={0xfff00000fff00000fff:FirstVlan[0]/96})
Define Hash5TupleIPv4 = Hash(HashWord0_3=Layer3Header[12]/32,HashWord4_7=Layer3Header[16]/32,HashWord8=Layer4Header[0]/32,HashWordP=IpProtocol)
Define Hash5TupleIPv6 = Hash(HashWord0_3=Layer3Header[8]/128,HashWord4_7=Layer3Header[24]/128,HashWord8=Layer4Header[0]/32,HashWordP=IpProtocol)
Define Hash5TupleSortedIPv4 = Hash(HashWord0_3=Layer3Header[12]/32,HashWord4_7=Layer3Header[16]/32,HashWord8=Layer4Header[0]/32,XOR=True,HashWordP=IpProtocol)
Define Hash5TupleSortedIPv6 = Hash(HashWord0_3=Layer3Header[8]/128,HashWord4_7=Layer3Header[24]/128,HashWord8=Layer4Header[0]/32,XOR=True,HashWordP=IpProtocol)
Define Hash3TupleGREv0IPv4 = Hash(HashWord0_3=Layer3Header[12]/32,HashWord4_7=Layer3Header[16]/32,HashWord8=Layer4Header[8]/32)
Define Hash3TupleGREv0IPv6 = Hash(HashWord0_3=Layer3Header[8]/128,HashWord4_7=Layer3Header[24]/128,HashWord8=Layer4Header[8]/32)
Define Hash3TupleGREv0SortedIPv4 = Hash(HashWord0_3=Layer3Header[12]/32,HashWord4_7=Layer3Header[16]/32,HashWord9=Layer4Header[8]/32,XOR=True)
Define Hash3TupleGREv0SortedIPv6 = Hash(HashWord0_3=Layer3Header[8]/128,HashWord4_7=Layer3Header[24]/128,HashWord9=Layer4Header[8]/32,XOR=True)
Define Hash5TupleSCTPIPv4 = Hash(HashWord0_3=Layer3Header[12]/32,HashWord4_7=Layer3Header[16]/32,HashWord8=Layer4Header[0]/32,HashWord9=Layer4Header[4]/32)
Define Hash5TupleSCTPIPv6 = Hash(HashWord0_3=Layer3Header[8]/128,HashWord4_7=Layer3Header[24]/128,HashWord8=Layer4Header[0]/32,HashWord9=Layer4Header[4]/32)
Define Hash5TupleSCTPSortedIPv4 = Hash(HashWord0_3=Layer3Header[12]/32,HashWord4_7=Layer3Header[16]/32,HashWord8=Layer4Header[0]/32,HashWord9=Layer4Header[4]/32,XOR=True)
Define Hash5TupleSCTPSortedIPv6 = Hash(HashWord0_3=Layer3Header[8]/128,HashWord4_7=Layer3Header[24]/128,HashWord8=Layer4Header[0]/32,HashWord9=Layer4Header[4]/32,XOR=True)
Define Hash3TupleGTPv0IPv4 = Hash(HashWord0_3=Layer3Header[12]/32,HashWord4_7=Layer3Header[16]/32,HashWord8=Layer4Payload[6]/16)
Define Hash3TupleGTPv0IPv6 = Hash(HashWord0_3=Layer3Header[8]/128,HashWord4_7=Layer3Header[24]/128,HashWord8=Layer4Payload[6]/16)
Define Hash3TupleGTPv0SortedIPv4 = Hash(HashWord0_3=Layer3Header[12]/32,HashWord4_7=Layer3Header[16]/32,HashWord9=Layer4Payload[6]/16,XOR=True)
Define Hash3TupleGTPv0SortedIPv6 = Hash(HashWord0_3=Layer3Header[8]/128,HashWord4_7=Layer3Header[24]/128,HashWord9=Layer4Payload[6]/16,XOR=True)
Define Hash3TupleGTPv1v2IPv4 = Hash(HashWord0_3=Layer3Header[12]/32,HashWord4_7=Layer3Header[16]/32,HashWord8=Layer4Payload[4]/32)
Define Hash3TupleGTPv1v2IPv6 = Hash(HashWord0_3=Layer3Header[8]/128,HashWord4_7=Layer3Header[24]/128,HashWord8=Layer4Payload[4]/32)
Define Hash3TupleGTPv1v2SortedIPv4 = Hash(HashWord0_3=Layer3Header[12]/32,HashWord4_7=Layer3Header[16]/32,HashWord9=Layer4Payload[4]/32,XOR=True)
Define Hash3TupleGTPv1v2SortedIPv6 = Hash(HashWord0_3=Layer3Header[8]/128,HashWord4_7=Layer3Header[24]/128,HashWord9=Layer4Payload[4]/32,XOR=True)
Define HashInner2TupleIPv4 = Hash(HashWord0_3=InnerLayer3Header[12]/32,HashWord4_7=InnerLayer3Header[16]/32)
Define HashInner2TupleIPv6 = Hash(HashWord0_3=InnerLayer3Header[8]/128,HashWord4_7=InnerLayer3Header[24]/128)
Define HashInner2TupleSortedIPv4 = Hash(HashWord0_3=InnerLayer3Header[12]/32,HashWord4_7=InnerLayer3Header[16]/32,XOR=True)
Define HashInner2TupleSortedIPv6 = Hash(HashWord0_3=InnerLayer3Header[8]/128,HashWord4_7=InnerLayer3Header[24]/128,XOR=True)
Define HashInner5TupleIPv4 = Hash(HashWord0_3=InnerLayer3Header[12]/32,HashWord4_7=InnerLayer3Header[16]/32,HashWord8=InnerLayer4Header[0]/32,HashWordP=InnerIpProtocol)
Define HashInner5TupleIPv6 = Hash(HashWord0_3=InnerLayer3Header[8]/128,HashWord4_7=InnerLayer3Header[24]/128,HashWord8=InnerLayer4Header[0]/32,HashWordP=InnerIpProtocol)
Define HashInner5TupleSortedIPv4 = Hash(HashWord0_3=InnerLayer3Header[12]/32,HashWord4_7=InnerLayer3Header[16]/32,HashWord8=InnerLayer4Header[0]/32,XOR=True,HashWordP=InnerIpProtocol)
Define HashInner5TupleSortedIPv6 = Hash(HashWord0_3=InnerLayer3Header[8]/128,HashWord4_7=InnerLayer3Header[24]/128,HashWord8=InnerLayer4Header[0]/32,XOR=True,HashWordP=InnerIpProtocol)