Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 1 | package org.openflow.types; |
| 2 | |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame] | 3 | import org.jboss.netty.buffer.ChannelBuffer; |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame] | 4 | |
| 5 | /** |
| 6 | * IP-Protocol field representation |
| 7 | * |
| 8 | * @author Yotam Harchol (yotam.harchol@bigswitch.com) |
| 9 | */ |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame] | 10 | public class IpProtocol implements OFValueType<IpProtocol> { |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame] | 11 | |
| 12 | static final short MAX_PROTO = 0xFF; |
| 13 | static final int LENGTH = 1; |
| 14 | |
| 15 | private final short proto; |
| 16 | |
| 17 | static final short IP_PROTO_NUM_HOPOPT = 0x00; |
| 18 | static final short IP_PROTO_NUM_ICMP = 0x01; |
| 19 | static final short IP_PROTO_NUM_IGMP = 0x02; |
| 20 | static final short IP_PROTO_NUM_GGP = 0x03; |
| 21 | static final short IP_PROTO_NUM_IPv4 = 0x04; |
| 22 | static final short IP_PROTO_NUM_ST = 0x05; |
| 23 | static final short IP_PROTO_NUM_TCP = 0x06; |
| 24 | static final short IP_PROTO_NUM_CBT = 0x07; |
| 25 | static final short IP_PROTO_NUM_EGP = 0x08; |
| 26 | static final short IP_PROTO_NUM_IGP = 0x09; |
| 27 | static final short IP_PROTO_NUM_BBN_RCC_MON = 0x0A; |
| 28 | static final short IP_PROTO_NUM_NVP_II = 0x0B; |
| 29 | static final short IP_PROTO_NUM_PUP = 0x0C; |
| 30 | static final short IP_PROTO_NUM_ARGUS = 0x0D; |
| 31 | static final short IP_PROTO_NUM_EMCON = 0x0E; |
| 32 | static final short IP_PROTO_NUM_XNET = 0x0F; |
| 33 | static final short IP_PROTO_NUM_CHAOS = 0x10; |
| 34 | static final short IP_PROTO_NUM_UDP = 0x11; |
| 35 | static final short IP_PROTO_NUM_MUX = 0x12; |
| 36 | static final short IP_PROTO_NUM_DCN_MEAS = 0x13; |
| 37 | static final short IP_PROTO_NUM_HMP = 0x14; |
| 38 | static final short IP_PROTO_NUM_PRM = 0x15; |
| 39 | static final short IP_PROTO_NUM_XNS_IDP = 0x16; |
| 40 | static final short IP_PROTO_NUM_TRUNK_1 = 0x17; |
| 41 | static final short IP_PROTO_NUM_TRUNK_2 = 0x18; |
| 42 | static final short IP_PROTO_NUM_LEAF_1 = 0x19; |
| 43 | static final short IP_PROTO_NUM_LEAF_2 = 0x1A; |
| 44 | static final short IP_PROTO_NUM_RDP = 0x1B; |
| 45 | static final short IP_PROTO_NUM_IRTP = 0x1C; |
| 46 | static final short IP_PROTO_NUM_ISO_TP4 = 0x1D; |
| 47 | static final short IP_PROTO_NUM_NETBLT = 0x1E; |
| 48 | static final short IP_PROTO_NUM_MFE_NSP = 0x1F; |
| 49 | static final short IP_PROTO_NUM_MERIT_INP = 0x20; |
| 50 | static final short IP_PROTO_NUM_DCCP = 0x21; |
| 51 | static final short IP_PROTO_NUM_3PC = 0x22; |
| 52 | static final short IP_PROTO_NUM_IDPR = 0x23; |
| 53 | static final short IP_PROTO_NUM_XTP = 0x24; |
| 54 | static final short IP_PROTO_NUM_DDP = 0x25; |
| 55 | static final short IP_PROTO_NUM_IDPR_CMTP = 0x26; |
| 56 | static final short IP_PROTO_NUM_TP_PP = 0x27; |
| 57 | static final short IP_PROTO_NUM_IL = 0x28; |
| 58 | static final short IP_PROTO_NUM_IPv6 = 0x29; |
| 59 | static final short IP_PROTO_NUM_SDRP = 0x2A; |
| 60 | static final short IP_PROTO_NUM_IPv6_ROUTE = 0x2B; |
| 61 | static final short IP_PROTO_NUM_IPv6_FRAG = 0x2C; |
| 62 | static final short IP_PROTO_NUM_IDRP = 0x2D; |
| 63 | static final short IP_PROTO_NUM_RSVP = 0x2E; |
| 64 | static final short IP_PROTO_NUM_GRE = 0x2F; |
| 65 | static final short IP_PROTO_NUM_MHRP = 0x30; |
| 66 | static final short IP_PROTO_NUM_BNA = 0x31; |
| 67 | static final short IP_PROTO_NUM_ESP = 0x32; |
| 68 | static final short IP_PROTO_NUM_AH = 0x33; |
| 69 | static final short IP_PROTO_NUM_I_NLSP = 0x34; |
| 70 | static final short IP_PROTO_NUM_SWIPE = 0x35; |
| 71 | static final short IP_PROTO_NUM_NARP = 0x36; |
| 72 | static final short IP_PROTO_NUM_MOBILE = 0x37; |
| 73 | static final short IP_PROTO_NUM_TLSP = 0x38; |
| 74 | static final short IP_PROTO_NUM_SKIP = 0x39; |
| 75 | static final short IP_PROTO_NUM_IPv6_ICMP = 0x3A; |
| 76 | static final short IP_PROTO_NUM_IPv6_NO_NXT = 0x3B; |
| 77 | static final short IP_PROTO_NUM_IPv6_OPTS = 0x3C; |
| 78 | static final short IP_PROTO_NUM_HOST_INTERNAL = 0x3D; |
| 79 | static final short IP_PROTO_NUM_CFTP = 0x3E; |
| 80 | static final short IP_PROTO_NUM_LOCAL_NET = 0x3F; |
| 81 | static final short IP_PROTO_NUM_SAT_EXPAK = 0x40; |
| 82 | static final short IP_PROTO_NUM_KRYPTOLAN = 0x41; |
| 83 | static final short IP_PROTO_NUM_RVD = 0x42; |
| 84 | static final short IP_PROTO_NUM_IPPC = 0x43; |
| 85 | static final short IP_PROTO_NUM_DIST_FS = 0x44; |
| 86 | static final short IP_PROTO_NUM_SAT_MON = 0x45; |
| 87 | static final short IP_PROTO_NUM_VISA = 0x46; |
| 88 | static final short IP_PROTO_NUM_IPCV = 0x47; |
| 89 | static final short IP_PROTO_NUM_CPNX = 0x48; |
| 90 | static final short IP_PROTO_NUM_CPHB = 0x49; |
| 91 | static final short IP_PROTO_NUM_WSN = 0x4A; |
| 92 | static final short IP_PROTO_NUM_PVP = 0x4B; |
| 93 | static final short IP_PROTO_NUM_BR_SAT_MON = 0x4C; |
| 94 | static final short IP_PROTO_NUM_SUN_ND = 0x4D; |
| 95 | static final short IP_PROTO_NUM_WB_MON = 0x4E; |
| 96 | static final short IP_PROTO_NUM_WB_EXPAK = 0x4F; |
| 97 | static final short IP_PROTO_NUM_ISO_IP = 0x50; |
| 98 | static final short IP_PROTO_NUM_VMTP = 0x51; |
| 99 | static final short IP_PROTO_NUM_SECURE_VMTP = 0x52; |
| 100 | static final short IP_PROTO_NUM_VINES = 0x53; |
| 101 | static final short IP_PROTO_NUM_TTP_IPTM = 0x54; |
| 102 | static final short IP_PROTO_NUM_NSFNET_IGP = 0x55; |
| 103 | static final short IP_PROTO_NUM_DGP = 0x56; |
| 104 | static final short IP_PROTO_NUM_TCF = 0x57; |
| 105 | static final short IP_PROTO_NUM_EIGRP = 0x58; |
| 106 | static final short IP_PROTO_NUM_OSPF = 0x59; |
| 107 | static final short IP_PROTO_NUM_Sprite_RPC = 0x5A; |
| 108 | static final short IP_PROTO_NUM_LARP = 0x5B; |
| 109 | static final short IP_PROTO_NUM_MTP = 0x5C; |
| 110 | static final short IP_PROTO_NUM_AX_25 = 0x5D; |
| 111 | static final short IP_PROTO_NUM_IPIP = 0x5E; |
| 112 | static final short IP_PROTO_NUM_MICP = 0x5F; |
| 113 | static final short IP_PROTO_NUM_SCC_SP = 0x60; |
| 114 | static final short IP_PROTO_NUM_ETHERIP = 0x61; |
| 115 | static final short IP_PROTO_NUM_ENCAP = 0x62; |
| 116 | static final short IP_PROTO_NUM_PRIVATE_ENCRYPT = 0x63; |
| 117 | static final short IP_PROTO_NUM_GMTP = 0x64; |
| 118 | static final short IP_PROTO_NUM_IFMP = 0x65; |
| 119 | static final short IP_PROTO_NUM_PNNI = 0x66; |
| 120 | static final short IP_PROTO_NUM_PIM = 0x67; |
| 121 | static final short IP_PROTO_NUM_ARIS = 0x68; |
| 122 | static final short IP_PROTO_NUM_SCPS = 0x69; |
| 123 | static final short IP_PROTO_NUM_QNX = 0x6A; |
| 124 | static final short IP_PROTO_NUM_A_N = 0x6B; |
| 125 | static final short IP_PROTO_NUM_IP_COMP = 0x6C; |
| 126 | static final short IP_PROTO_NUM_SNP = 0x6D; |
| 127 | static final short IP_PROTO_NUM_COMPAQ_PEER = 0x6E; |
| 128 | static final short IP_PROTO_NUM_IPX_IN_IP = 0x6F; |
| 129 | static final short IP_PROTO_NUM_VRRP = 0x70; |
| 130 | static final short IP_PROTO_NUM_PGM = 0x71; |
| 131 | static final short IP_PROTO_NUM_ZERO_HOP = 0x72; |
| 132 | static final short IP_PROTO_NUM_L2TP = 0x73; |
| 133 | static final short IP_PROTO_NUM_DDX = 0x74; |
| 134 | static final short IP_PROTO_NUM_IATP = 0x75; |
| 135 | static final short IP_PROTO_NUM_STP = 0x76; |
| 136 | static final short IP_PROTO_NUM_SRP = 0x77; |
| 137 | static final short IP_PROTO_NUM_UTI = 0x78; |
| 138 | static final short IP_PROTO_NUM_SMP = 0x79; |
| 139 | static final short IP_PROTO_NUM_SM = 0x7A; |
| 140 | static final short IP_PROTO_NUM_PTP = 0x7B; |
| 141 | static final short IP_PROTO_NUM_IS_IS_OVER_IPv4 = 0x7C; |
| 142 | static final short IP_PROTO_NUM_FIRE = 0x7D; |
| 143 | static final short IP_PROTO_NUM_CRTP = 0x7E; |
| 144 | static final short IP_PROTO_NUM_CRUDP = 0x7F; |
| 145 | static final short IP_PROTO_NUM_SSCOPMCE = 0x80; |
| 146 | static final short IP_PROTO_NUM_IPLT = 0x81; |
| 147 | static final short IP_PROTO_NUM_SPS = 0x82; |
| 148 | static final short IP_PROTO_NUM_PIPE = 0x83; |
| 149 | static final short IP_PROTO_NUM_SCTP = 0x84; |
| 150 | static final short IP_PROTO_NUM_FC = 0x85; |
| 151 | static final short IP_PROTO_NUM_RSVP_E2E_IGNORE = 0x86; |
| 152 | static final short IP_PROTO_NUM_MOBILITY_HEADER = 0x87; |
| 153 | static final short IP_PROTO_NUM_UDP_LITE = 0x88; |
| 154 | static final short IP_PROTO_NUM_MPLS_IN_IP = 0x89; |
| 155 | static final short IP_PROTO_NUM_MANET = 0x8A; |
| 156 | static final short IP_PROTO_NUM_HIP = 0x8B; |
| 157 | static final short IP_PROTO_NUM_SHIM6 = 0x8C; |
| 158 | |
| 159 | public static final IpProtocol IP_PROTO_HOPOPT = new IpProtocol(IP_PROTO_NUM_HOPOPT); |
| 160 | public static final IpProtocol IP_PROTO_ICMP = new IpProtocol(IP_PROTO_NUM_ICMP); |
| 161 | public static final IpProtocol IP_PROTO_IGMP = new IpProtocol(IP_PROTO_NUM_IGMP); |
| 162 | public static final IpProtocol IP_PROTO_GGP = new IpProtocol(IP_PROTO_NUM_GGP); |
| 163 | public static final IpProtocol IP_PROTO_IPv4 = new IpProtocol(IP_PROTO_NUM_IPv4); |
| 164 | public static final IpProtocol IP_PROTO_ST = new IpProtocol(IP_PROTO_NUM_ST); |
| 165 | public static final IpProtocol IP_PROTO_TCP = new IpProtocol(IP_PROTO_NUM_TCP); |
| 166 | public static final IpProtocol IP_PROTO_CBT = new IpProtocol(IP_PROTO_NUM_CBT); |
| 167 | public static final IpProtocol IP_PROTO_EGP = new IpProtocol(IP_PROTO_NUM_EGP); |
| 168 | public static final IpProtocol IP_PROTO_IGP = new IpProtocol(IP_PROTO_NUM_IGP); |
| 169 | public static final IpProtocol IP_PROTO_BBN_RCC_MON = new IpProtocol(IP_PROTO_NUM_BBN_RCC_MON); |
| 170 | public static final IpProtocol IP_PROTO_NVP_II = new IpProtocol(IP_PROTO_NUM_NVP_II); |
| 171 | public static final IpProtocol IP_PROTO_PUP = new IpProtocol(IP_PROTO_NUM_PUP); |
| 172 | public static final IpProtocol IP_PROTO_ARGUS = new IpProtocol(IP_PROTO_NUM_ARGUS); |
| 173 | public static final IpProtocol IP_PROTO_EMCON = new IpProtocol(IP_PROTO_NUM_EMCON); |
| 174 | public static final IpProtocol IP_PROTO_XNET = new IpProtocol(IP_PROTO_NUM_XNET); |
| 175 | public static final IpProtocol IP_PROTO_CHAOS = new IpProtocol(IP_PROTO_NUM_CHAOS); |
| 176 | public static final IpProtocol IP_PROTO_UDP = new IpProtocol(IP_PROTO_NUM_UDP); |
| 177 | public static final IpProtocol IP_PROTO_MUX = new IpProtocol(IP_PROTO_NUM_MUX); |
| 178 | public static final IpProtocol IP_PROTO_DCN_MEAS = new IpProtocol(IP_PROTO_NUM_DCN_MEAS); |
| 179 | public static final IpProtocol IP_PROTO_HMP = new IpProtocol(IP_PROTO_NUM_HMP); |
| 180 | public static final IpProtocol IP_PROTO_PRM = new IpProtocol(IP_PROTO_NUM_PRM); |
| 181 | public static final IpProtocol IP_PROTO_XNS_IDP = new IpProtocol(IP_PROTO_NUM_XNS_IDP); |
| 182 | public static final IpProtocol IP_PROTO_TRUNK_1 = new IpProtocol(IP_PROTO_NUM_TRUNK_1); |
| 183 | public static final IpProtocol IP_PROTO_TRUNK_2 = new IpProtocol(IP_PROTO_NUM_TRUNK_2); |
| 184 | public static final IpProtocol IP_PROTO_LEAF_1 = new IpProtocol(IP_PROTO_NUM_LEAF_1); |
| 185 | public static final IpProtocol IP_PROTO_LEAF_2 = new IpProtocol(IP_PROTO_NUM_LEAF_2); |
| 186 | public static final IpProtocol IP_PROTO_RDP = new IpProtocol(IP_PROTO_NUM_RDP); |
| 187 | public static final IpProtocol IP_PROTO_IRTP = new IpProtocol(IP_PROTO_NUM_IRTP); |
| 188 | public static final IpProtocol IP_PROTO_ISO_TP4 = new IpProtocol(IP_PROTO_NUM_ISO_TP4); |
| 189 | public static final IpProtocol IP_PROTO_NETBLT = new IpProtocol(IP_PROTO_NUM_NETBLT); |
| 190 | public static final IpProtocol IP_PROTO_MFE_NSP = new IpProtocol(IP_PROTO_NUM_MFE_NSP); |
| 191 | public static final IpProtocol IP_PROTO_MERIT_INP = new IpProtocol(IP_PROTO_NUM_MERIT_INP); |
| 192 | public static final IpProtocol IP_PROTO_DCCP = new IpProtocol(IP_PROTO_NUM_DCCP); |
| 193 | public static final IpProtocol IP_PROTO_3PC = new IpProtocol(IP_PROTO_NUM_3PC); |
| 194 | public static final IpProtocol IP_PROTO_IDPR = new IpProtocol(IP_PROTO_NUM_IDPR); |
| 195 | public static final IpProtocol IP_PROTO_XTP = new IpProtocol(IP_PROTO_NUM_XTP); |
| 196 | public static final IpProtocol IP_PROTO_DDP = new IpProtocol(IP_PROTO_NUM_DDP); |
| 197 | public static final IpProtocol IP_PROTO_IDPR_CMTP = new IpProtocol(IP_PROTO_NUM_IDPR_CMTP); |
| 198 | public static final IpProtocol IP_PROTO_TP_PP = new IpProtocol(IP_PROTO_NUM_TP_PP); |
| 199 | public static final IpProtocol IP_PROTO_IL = new IpProtocol(IP_PROTO_NUM_IL); |
| 200 | public static final IpProtocol IP_PROTO_IPv6 = new IpProtocol(IP_PROTO_NUM_IPv6); |
| 201 | public static final IpProtocol IP_PROTO_SDRP = new IpProtocol(IP_PROTO_NUM_SDRP); |
| 202 | public static final IpProtocol IP_PROTO_IPv6_ROUTE = new IpProtocol(IP_PROTO_NUM_IPv6_ROUTE); |
| 203 | public static final IpProtocol IP_PROTO_IPv6_FRAG = new IpProtocol(IP_PROTO_NUM_IPv6_FRAG); |
| 204 | public static final IpProtocol IP_PROTO_IDRP = new IpProtocol(IP_PROTO_NUM_IDRP); |
| 205 | public static final IpProtocol IP_PROTO_RSVP = new IpProtocol(IP_PROTO_NUM_RSVP); |
| 206 | public static final IpProtocol IP_PROTO_GRE = new IpProtocol(IP_PROTO_NUM_GRE); |
| 207 | public static final IpProtocol IP_PROTO_MHRP = new IpProtocol(IP_PROTO_NUM_MHRP); |
| 208 | public static final IpProtocol IP_PROTO_BNA = new IpProtocol(IP_PROTO_NUM_BNA); |
| 209 | public static final IpProtocol IP_PROTO_ESP = new IpProtocol(IP_PROTO_NUM_ESP); |
| 210 | public static final IpProtocol IP_PROTO_AH = new IpProtocol(IP_PROTO_NUM_AH); |
| 211 | public static final IpProtocol IP_PROTO_I_NLSP = new IpProtocol(IP_PROTO_NUM_I_NLSP); |
| 212 | public static final IpProtocol IP_PROTO_SWIPE = new IpProtocol(IP_PROTO_NUM_SWIPE); |
| 213 | public static final IpProtocol IP_PROTO_NARP = new IpProtocol(IP_PROTO_NUM_NARP); |
| 214 | public static final IpProtocol IP_PROTO_MOBILE = new IpProtocol(IP_PROTO_NUM_MOBILE); |
| 215 | public static final IpProtocol IP_PROTO_TLSP = new IpProtocol(IP_PROTO_NUM_TLSP); |
| 216 | public static final IpProtocol IP_PROTO_SKIP = new IpProtocol(IP_PROTO_NUM_SKIP); |
| 217 | public static final IpProtocol IP_PROTO_IPv6_ICMP = new IpProtocol(IP_PROTO_NUM_IPv6_ICMP); |
| 218 | public static final IpProtocol IP_PROTO_IPv6_NO_NXT = new IpProtocol(IP_PROTO_NUM_IPv6_NO_NXT); |
| 219 | public static final IpProtocol IP_PROTO_IPv6_OPTS = new IpProtocol(IP_PROTO_NUM_IPv6_OPTS); |
| 220 | public static final IpProtocol IP_PROTO_HOST_INTERNAL = new IpProtocol(IP_PROTO_NUM_HOST_INTERNAL); |
| 221 | public static final IpProtocol IP_PROTO_CFTP = new IpProtocol(IP_PROTO_NUM_CFTP); |
| 222 | public static final IpProtocol IP_PROTO_LOCAL_NET = new IpProtocol(IP_PROTO_NUM_LOCAL_NET); |
| 223 | public static final IpProtocol IP_PROTO_SAT_EXPAK = new IpProtocol(IP_PROTO_NUM_SAT_EXPAK); |
| 224 | public static final IpProtocol IP_PROTO_KRYPTOLAN = new IpProtocol(IP_PROTO_NUM_KRYPTOLAN); |
| 225 | public static final IpProtocol IP_PROTO_RVD = new IpProtocol(IP_PROTO_NUM_RVD); |
| 226 | public static final IpProtocol IP_PROTO_IPPC = new IpProtocol(IP_PROTO_NUM_IPPC); |
| 227 | public static final IpProtocol IP_PROTO_DIST_FS = new IpProtocol(IP_PROTO_NUM_DIST_FS); |
| 228 | public static final IpProtocol IP_PROTO_SAT_MON = new IpProtocol(IP_PROTO_NUM_SAT_MON); |
| 229 | public static final IpProtocol IP_PROTO_VISA = new IpProtocol(IP_PROTO_NUM_VISA); |
| 230 | public static final IpProtocol IP_PROTO_IPCV = new IpProtocol(IP_PROTO_NUM_IPCV); |
| 231 | public static final IpProtocol IP_PROTO_CPNX = new IpProtocol(IP_PROTO_NUM_CPNX); |
| 232 | public static final IpProtocol IP_PROTO_CPHB = new IpProtocol(IP_PROTO_NUM_CPHB); |
| 233 | public static final IpProtocol IP_PROTO_WSN = new IpProtocol(IP_PROTO_NUM_WSN); |
| 234 | public static final IpProtocol IP_PROTO_PVP = new IpProtocol(IP_PROTO_NUM_PVP); |
| 235 | public static final IpProtocol IP_PROTO_BR_SAT_MON = new IpProtocol(IP_PROTO_NUM_BR_SAT_MON); |
| 236 | public static final IpProtocol IP_PROTO_SUN_ND = new IpProtocol(IP_PROTO_NUM_SUN_ND); |
| 237 | public static final IpProtocol IP_PROTO_WB_MON = new IpProtocol(IP_PROTO_NUM_WB_MON); |
| 238 | public static final IpProtocol IP_PROTO_WB_EXPAK = new IpProtocol(IP_PROTO_NUM_WB_EXPAK); |
| 239 | public static final IpProtocol IP_PROTO_ISO_IP = new IpProtocol(IP_PROTO_NUM_ISO_IP); |
| 240 | public static final IpProtocol IP_PROTO_VMTP = new IpProtocol(IP_PROTO_NUM_VMTP); |
| 241 | public static final IpProtocol IP_PROTO_SECURE_VMTP = new IpProtocol(IP_PROTO_NUM_SECURE_VMTP); |
| 242 | public static final IpProtocol IP_PROTO_VINES = new IpProtocol(IP_PROTO_NUM_VINES); |
| 243 | public static final IpProtocol IP_PROTO_TTP_IPTM = new IpProtocol(IP_PROTO_NUM_TTP_IPTM); |
| 244 | public static final IpProtocol IP_PROTO_NSFNET_IGP = new IpProtocol(IP_PROTO_NUM_NSFNET_IGP); |
| 245 | public static final IpProtocol IP_PROTO_DGP = new IpProtocol(IP_PROTO_NUM_DGP); |
| 246 | public static final IpProtocol IP_PROTO_TCF = new IpProtocol(IP_PROTO_NUM_TCF); |
| 247 | public static final IpProtocol IP_PROTO_EIGRP = new IpProtocol(IP_PROTO_NUM_EIGRP); |
| 248 | public static final IpProtocol IP_PROTO_OSPF = new IpProtocol(IP_PROTO_NUM_OSPF); |
| 249 | public static final IpProtocol IP_PROTO_Sprite_RPC = new IpProtocol(IP_PROTO_NUM_Sprite_RPC); |
| 250 | public static final IpProtocol IP_PROTO_LARP = new IpProtocol(IP_PROTO_NUM_LARP); |
| 251 | public static final IpProtocol IP_PROTO_MTP = new IpProtocol(IP_PROTO_NUM_MTP); |
| 252 | public static final IpProtocol IP_PROTO_AX_25 = new IpProtocol(IP_PROTO_NUM_AX_25); |
| 253 | public static final IpProtocol IP_PROTO_IPIP = new IpProtocol(IP_PROTO_NUM_IPIP); |
| 254 | public static final IpProtocol IP_PROTO_MICP = new IpProtocol(IP_PROTO_NUM_MICP); |
| 255 | public static final IpProtocol IP_PROTO_SCC_SP = new IpProtocol(IP_PROTO_NUM_SCC_SP); |
| 256 | public static final IpProtocol IP_PROTO_ETHERIP = new IpProtocol(IP_PROTO_NUM_ETHERIP); |
| 257 | public static final IpProtocol IP_PROTO_ENCAP = new IpProtocol(IP_PROTO_NUM_ENCAP); |
| 258 | public static final IpProtocol IP_PROTO_PRIVATE_ENCRYPT = new IpProtocol(IP_PROTO_NUM_PRIVATE_ENCRYPT); |
| 259 | public static final IpProtocol IP_PROTO_GMTP = new IpProtocol(IP_PROTO_NUM_GMTP); |
| 260 | public static final IpProtocol IP_PROTO_IFMP = new IpProtocol(IP_PROTO_NUM_IFMP); |
| 261 | public static final IpProtocol IP_PROTO_PNNI = new IpProtocol(IP_PROTO_NUM_PNNI); |
| 262 | public static final IpProtocol IP_PROTO_PIM = new IpProtocol(IP_PROTO_NUM_PIM); |
| 263 | public static final IpProtocol IP_PROTO_ARIS = new IpProtocol(IP_PROTO_NUM_ARIS); |
| 264 | public static final IpProtocol IP_PROTO_SCPS = new IpProtocol(IP_PROTO_NUM_SCPS); |
| 265 | public static final IpProtocol IP_PROTO_QNX = new IpProtocol(IP_PROTO_NUM_QNX); |
| 266 | public static final IpProtocol IP_PROTO_A_N = new IpProtocol(IP_PROTO_NUM_A_N); |
| 267 | public static final IpProtocol IP_PROTO_IP_COMP = new IpProtocol(IP_PROTO_NUM_IP_COMP); |
| 268 | public static final IpProtocol IP_PROTO_SNP = new IpProtocol(IP_PROTO_NUM_SNP); |
| 269 | public static final IpProtocol IP_PROTO_COMPAQ_PEER = new IpProtocol(IP_PROTO_NUM_COMPAQ_PEER); |
| 270 | public static final IpProtocol IP_PROTO_IPX_IN_IP = new IpProtocol(IP_PROTO_NUM_IPX_IN_IP); |
| 271 | public static final IpProtocol IP_PROTO_VRRP = new IpProtocol(IP_PROTO_NUM_VRRP); |
| 272 | public static final IpProtocol IP_PROTO_PGM = new IpProtocol(IP_PROTO_NUM_PGM); |
| 273 | public static final IpProtocol IP_PROTO_ZERO_HOP = new IpProtocol(IP_PROTO_NUM_ZERO_HOP); |
| 274 | public static final IpProtocol IP_PROTO_L2TP = new IpProtocol(IP_PROTO_NUM_L2TP); |
| 275 | public static final IpProtocol IP_PROTO_DDX = new IpProtocol(IP_PROTO_NUM_DDX); |
| 276 | public static final IpProtocol IP_PROTO_IATP = new IpProtocol(IP_PROTO_NUM_IATP); |
| 277 | public static final IpProtocol IP_PROTO_STP = new IpProtocol(IP_PROTO_NUM_STP); |
| 278 | public static final IpProtocol IP_PROTO_SRP = new IpProtocol(IP_PROTO_NUM_SRP); |
| 279 | public static final IpProtocol IP_PROTO_UTI = new IpProtocol(IP_PROTO_NUM_UTI); |
| 280 | public static final IpProtocol IP_PROTO_SMP = new IpProtocol(IP_PROTO_NUM_SMP); |
| 281 | public static final IpProtocol IP_PROTO_SM = new IpProtocol(IP_PROTO_NUM_SM); |
| 282 | public static final IpProtocol IP_PROTO_PTP = new IpProtocol(IP_PROTO_NUM_PTP); |
| 283 | public static final IpProtocol IP_PROTO_IS_IS_OVER_IPv4 = new IpProtocol(IP_PROTO_NUM_IS_IS_OVER_IPv4); |
| 284 | public static final IpProtocol IP_PROTO_FIRE = new IpProtocol(IP_PROTO_NUM_FIRE); |
| 285 | public static final IpProtocol IP_PROTO_CRTP = new IpProtocol(IP_PROTO_NUM_CRTP); |
| 286 | public static final IpProtocol IP_PROTO_CRUDP = new IpProtocol(IP_PROTO_NUM_CRUDP); |
| 287 | public static final IpProtocol IP_PROTO_SSCOPMCE = new IpProtocol(IP_PROTO_NUM_SSCOPMCE); |
| 288 | public static final IpProtocol IP_PROTO_IPLT = new IpProtocol(IP_PROTO_NUM_IPLT); |
| 289 | public static final IpProtocol IP_PROTO_SPS = new IpProtocol(IP_PROTO_NUM_SPS); |
| 290 | public static final IpProtocol IP_PROTO_PIPE = new IpProtocol(IP_PROTO_NUM_PIPE); |
| 291 | public static final IpProtocol IP_PROTO_SCTP = new IpProtocol(IP_PROTO_NUM_SCTP); |
| 292 | public static final IpProtocol IP_PROTO_FC = new IpProtocol(IP_PROTO_NUM_FC); |
| 293 | public static final IpProtocol IP_PROTO_RSVP_E2E_IGNORE = new IpProtocol(IP_PROTO_NUM_RSVP_E2E_IGNORE); |
| 294 | public static final IpProtocol IP_PROTO_MOBILITY_HEADER = new IpProtocol(IP_PROTO_NUM_MOBILITY_HEADER); |
| 295 | public static final IpProtocol IP_PROTO_UDP_LITE = new IpProtocol(IP_PROTO_NUM_UDP_LITE); |
| 296 | public static final IpProtocol IP_PROTO_MPLS_IN_IP = new IpProtocol(IP_PROTO_NUM_MPLS_IN_IP); |
| 297 | public static final IpProtocol IP_PROTO_MANET = new IpProtocol(IP_PROTO_NUM_MANET); |
| 298 | public static final IpProtocol IP_PROTO_HIP = new IpProtocol(IP_PROTO_NUM_HIP); |
| 299 | public static final IpProtocol IP_PROTO_SHIM6 = new IpProtocol(IP_PROTO_NUM_SHIM6); |
| 300 | |
Yotam Harchol | ff8f85e | 2013-08-21 10:02:23 -0700 | [diff] [blame] | 301 | public static final IpProtocol NO_MASK = IP_PROTO_HOPOPT; |
| 302 | public static final IpProtocol FULL_MASK = new IpProtocol((short)0x0000); |
Yotam Harchol | c281360 | 2013-08-20 12:14:22 -0700 | [diff] [blame] | 303 | |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame] | 304 | private IpProtocol(short version) { |
| 305 | this.proto = version; |
| 306 | } |
| 307 | |
| 308 | |
| 309 | @Override |
| 310 | public int getLength() { |
| 311 | return LENGTH; |
| 312 | } |
| 313 | |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame] | 314 | public static IpProtocol of(short proto) { |
| 315 | switch (proto) { |
| 316 | case IP_PROTO_NUM_HOPOPT: |
| 317 | return IP_PROTO_HOPOPT; |
| 318 | case IP_PROTO_NUM_ICMP: |
| 319 | return IP_PROTO_ICMP; |
| 320 | case IP_PROTO_NUM_IGMP: |
| 321 | return IP_PROTO_IGMP; |
| 322 | case IP_PROTO_NUM_GGP: |
| 323 | return IP_PROTO_GGP; |
| 324 | case IP_PROTO_NUM_IPv4: |
| 325 | return IP_PROTO_IPv4; |
| 326 | case IP_PROTO_NUM_ST: |
| 327 | return IP_PROTO_ST; |
| 328 | case IP_PROTO_NUM_TCP: |
| 329 | return IP_PROTO_TCP; |
| 330 | case IP_PROTO_NUM_CBT: |
| 331 | return IP_PROTO_CBT; |
| 332 | case IP_PROTO_NUM_EGP: |
| 333 | return IP_PROTO_EGP; |
| 334 | case IP_PROTO_NUM_IGP: |
| 335 | return IP_PROTO_IGP; |
| 336 | case IP_PROTO_NUM_BBN_RCC_MON: |
| 337 | return IP_PROTO_BBN_RCC_MON; |
| 338 | case IP_PROTO_NUM_NVP_II: |
| 339 | return IP_PROTO_NVP_II; |
| 340 | case IP_PROTO_NUM_PUP: |
| 341 | return IP_PROTO_PUP; |
| 342 | case IP_PROTO_NUM_ARGUS: |
| 343 | return IP_PROTO_ARGUS; |
| 344 | case IP_PROTO_NUM_EMCON: |
| 345 | return IP_PROTO_EMCON; |
| 346 | case IP_PROTO_NUM_XNET: |
| 347 | return IP_PROTO_XNET; |
| 348 | case IP_PROTO_NUM_CHAOS: |
| 349 | return IP_PROTO_CHAOS; |
| 350 | case IP_PROTO_NUM_UDP: |
| 351 | return IP_PROTO_UDP; |
| 352 | case IP_PROTO_NUM_MUX: |
| 353 | return IP_PROTO_MUX; |
| 354 | case IP_PROTO_NUM_DCN_MEAS: |
| 355 | return IP_PROTO_DCN_MEAS; |
| 356 | case IP_PROTO_NUM_HMP: |
| 357 | return IP_PROTO_HMP; |
| 358 | case IP_PROTO_NUM_PRM: |
| 359 | return IP_PROTO_PRM; |
| 360 | case IP_PROTO_NUM_XNS_IDP: |
| 361 | return IP_PROTO_XNS_IDP; |
| 362 | case IP_PROTO_NUM_TRUNK_1: |
| 363 | return IP_PROTO_TRUNK_1; |
| 364 | case IP_PROTO_NUM_TRUNK_2: |
| 365 | return IP_PROTO_TRUNK_2; |
| 366 | case IP_PROTO_NUM_LEAF_1: |
| 367 | return IP_PROTO_LEAF_1; |
| 368 | case IP_PROTO_NUM_LEAF_2: |
| 369 | return IP_PROTO_LEAF_2; |
| 370 | case IP_PROTO_NUM_RDP: |
| 371 | return IP_PROTO_RDP; |
| 372 | case IP_PROTO_NUM_IRTP: |
| 373 | return IP_PROTO_IRTP; |
| 374 | case IP_PROTO_NUM_ISO_TP4: |
| 375 | return IP_PROTO_ISO_TP4; |
| 376 | case IP_PROTO_NUM_NETBLT: |
| 377 | return IP_PROTO_NETBLT; |
| 378 | case IP_PROTO_NUM_MFE_NSP: |
| 379 | return IP_PROTO_MFE_NSP; |
| 380 | case IP_PROTO_NUM_MERIT_INP: |
| 381 | return IP_PROTO_MERIT_INP; |
| 382 | case IP_PROTO_NUM_DCCP: |
| 383 | return IP_PROTO_DCCP; |
| 384 | case IP_PROTO_NUM_3PC: |
| 385 | return IP_PROTO_3PC; |
| 386 | case IP_PROTO_NUM_IDPR: |
| 387 | return IP_PROTO_IDPR; |
| 388 | case IP_PROTO_NUM_XTP: |
| 389 | return IP_PROTO_XTP; |
| 390 | case IP_PROTO_NUM_DDP: |
| 391 | return IP_PROTO_DDP; |
| 392 | case IP_PROTO_NUM_IDPR_CMTP: |
| 393 | return IP_PROTO_IDPR_CMTP; |
| 394 | case IP_PROTO_NUM_TP_PP: |
| 395 | return IP_PROTO_TP_PP; |
| 396 | case IP_PROTO_NUM_IL: |
| 397 | return IP_PROTO_IL; |
| 398 | case IP_PROTO_NUM_IPv6: |
| 399 | return IP_PROTO_IPv6; |
| 400 | case IP_PROTO_NUM_SDRP: |
| 401 | return IP_PROTO_SDRP; |
| 402 | case IP_PROTO_NUM_IPv6_ROUTE: |
| 403 | return IP_PROTO_IPv6_ROUTE; |
| 404 | case IP_PROTO_NUM_IPv6_FRAG: |
| 405 | return IP_PROTO_IPv6_FRAG; |
| 406 | case IP_PROTO_NUM_IDRP: |
| 407 | return IP_PROTO_IDRP; |
| 408 | case IP_PROTO_NUM_RSVP: |
| 409 | return IP_PROTO_RSVP; |
| 410 | case IP_PROTO_NUM_GRE: |
| 411 | return IP_PROTO_GRE; |
| 412 | case IP_PROTO_NUM_MHRP: |
| 413 | return IP_PROTO_MHRP; |
| 414 | case IP_PROTO_NUM_BNA: |
| 415 | return IP_PROTO_BNA; |
| 416 | case IP_PROTO_NUM_ESP: |
| 417 | return IP_PROTO_ESP; |
| 418 | case IP_PROTO_NUM_AH: |
| 419 | return IP_PROTO_AH; |
| 420 | case IP_PROTO_NUM_I_NLSP: |
| 421 | return IP_PROTO_I_NLSP; |
| 422 | case IP_PROTO_NUM_SWIPE: |
| 423 | return IP_PROTO_SWIPE; |
| 424 | case IP_PROTO_NUM_NARP: |
| 425 | return IP_PROTO_NARP; |
| 426 | case IP_PROTO_NUM_MOBILE: |
| 427 | return IP_PROTO_MOBILE; |
| 428 | case IP_PROTO_NUM_TLSP: |
| 429 | return IP_PROTO_TLSP; |
| 430 | case IP_PROTO_NUM_SKIP: |
| 431 | return IP_PROTO_SKIP; |
| 432 | case IP_PROTO_NUM_IPv6_ICMP: |
| 433 | return IP_PROTO_IPv6_ICMP; |
| 434 | case IP_PROTO_NUM_IPv6_NO_NXT: |
| 435 | return IP_PROTO_IPv6_NO_NXT; |
| 436 | case IP_PROTO_NUM_IPv6_OPTS: |
| 437 | return IP_PROTO_IPv6_OPTS; |
| 438 | case IP_PROTO_NUM_HOST_INTERNAL: |
| 439 | return IP_PROTO_HOST_INTERNAL; |
| 440 | case IP_PROTO_NUM_CFTP: |
| 441 | return IP_PROTO_CFTP; |
| 442 | case IP_PROTO_NUM_LOCAL_NET: |
| 443 | return IP_PROTO_LOCAL_NET; |
| 444 | case IP_PROTO_NUM_SAT_EXPAK: |
| 445 | return IP_PROTO_SAT_EXPAK; |
| 446 | case IP_PROTO_NUM_KRYPTOLAN: |
| 447 | return IP_PROTO_KRYPTOLAN; |
| 448 | case IP_PROTO_NUM_RVD: |
| 449 | return IP_PROTO_RVD; |
| 450 | case IP_PROTO_NUM_IPPC: |
| 451 | return IP_PROTO_IPPC; |
| 452 | case IP_PROTO_NUM_DIST_FS: |
| 453 | return IP_PROTO_DIST_FS; |
| 454 | case IP_PROTO_NUM_SAT_MON: |
| 455 | return IP_PROTO_SAT_MON; |
| 456 | case IP_PROTO_NUM_VISA: |
| 457 | return IP_PROTO_VISA; |
| 458 | case IP_PROTO_NUM_IPCV: |
| 459 | return IP_PROTO_IPCV; |
| 460 | case IP_PROTO_NUM_CPNX: |
| 461 | return IP_PROTO_CPNX; |
| 462 | case IP_PROTO_NUM_CPHB: |
| 463 | return IP_PROTO_CPHB; |
| 464 | case IP_PROTO_NUM_WSN: |
| 465 | return IP_PROTO_WSN; |
| 466 | case IP_PROTO_NUM_PVP: |
| 467 | return IP_PROTO_PVP; |
| 468 | case IP_PROTO_NUM_BR_SAT_MON: |
| 469 | return IP_PROTO_BR_SAT_MON; |
| 470 | case IP_PROTO_NUM_SUN_ND: |
| 471 | return IP_PROTO_SUN_ND; |
| 472 | case IP_PROTO_NUM_WB_MON: |
| 473 | return IP_PROTO_WB_MON; |
| 474 | case IP_PROTO_NUM_WB_EXPAK: |
| 475 | return IP_PROTO_WB_EXPAK; |
| 476 | case IP_PROTO_NUM_ISO_IP: |
| 477 | return IP_PROTO_ISO_IP; |
| 478 | case IP_PROTO_NUM_VMTP: |
| 479 | return IP_PROTO_VMTP; |
| 480 | case IP_PROTO_NUM_SECURE_VMTP: |
| 481 | return IP_PROTO_SECURE_VMTP; |
| 482 | case IP_PROTO_NUM_VINES: |
| 483 | return IP_PROTO_VINES; |
| 484 | case IP_PROTO_NUM_TTP_IPTM: |
| 485 | return IP_PROTO_TTP_IPTM; |
| 486 | case IP_PROTO_NUM_NSFNET_IGP: |
| 487 | return IP_PROTO_NSFNET_IGP; |
| 488 | case IP_PROTO_NUM_DGP: |
| 489 | return IP_PROTO_DGP; |
| 490 | case IP_PROTO_NUM_TCF: |
| 491 | return IP_PROTO_TCF; |
| 492 | case IP_PROTO_NUM_EIGRP: |
| 493 | return IP_PROTO_EIGRP; |
| 494 | case IP_PROTO_NUM_OSPF: |
| 495 | return IP_PROTO_OSPF; |
| 496 | case IP_PROTO_NUM_Sprite_RPC: |
| 497 | return IP_PROTO_Sprite_RPC; |
| 498 | case IP_PROTO_NUM_LARP: |
| 499 | return IP_PROTO_LARP; |
| 500 | case IP_PROTO_NUM_MTP: |
| 501 | return IP_PROTO_MTP; |
| 502 | case IP_PROTO_NUM_AX_25: |
| 503 | return IP_PROTO_AX_25; |
| 504 | case IP_PROTO_NUM_IPIP: |
| 505 | return IP_PROTO_IPIP; |
| 506 | case IP_PROTO_NUM_MICP: |
| 507 | return IP_PROTO_MICP; |
| 508 | case IP_PROTO_NUM_SCC_SP: |
| 509 | return IP_PROTO_SCC_SP; |
| 510 | case IP_PROTO_NUM_ETHERIP: |
| 511 | return IP_PROTO_ETHERIP; |
| 512 | case IP_PROTO_NUM_ENCAP: |
| 513 | return IP_PROTO_ENCAP; |
| 514 | case IP_PROTO_NUM_PRIVATE_ENCRYPT: |
| 515 | return IP_PROTO_PRIVATE_ENCRYPT; |
| 516 | case IP_PROTO_NUM_GMTP: |
| 517 | return IP_PROTO_GMTP; |
| 518 | case IP_PROTO_NUM_IFMP: |
| 519 | return IP_PROTO_IFMP; |
| 520 | case IP_PROTO_NUM_PNNI: |
| 521 | return IP_PROTO_PNNI; |
| 522 | case IP_PROTO_NUM_PIM: |
| 523 | return IP_PROTO_PIM; |
| 524 | case IP_PROTO_NUM_ARIS: |
| 525 | return IP_PROTO_ARIS; |
| 526 | case IP_PROTO_NUM_SCPS: |
| 527 | return IP_PROTO_SCPS; |
| 528 | case IP_PROTO_NUM_QNX: |
| 529 | return IP_PROTO_QNX; |
| 530 | case IP_PROTO_NUM_A_N: |
| 531 | return IP_PROTO_A_N; |
| 532 | case IP_PROTO_NUM_IP_COMP: |
| 533 | return IP_PROTO_IP_COMP; |
| 534 | case IP_PROTO_NUM_SNP: |
| 535 | return IP_PROTO_SNP; |
| 536 | case IP_PROTO_NUM_COMPAQ_PEER: |
| 537 | return IP_PROTO_COMPAQ_PEER; |
| 538 | case IP_PROTO_NUM_IPX_IN_IP: |
| 539 | return IP_PROTO_IPX_IN_IP; |
| 540 | case IP_PROTO_NUM_VRRP: |
| 541 | return IP_PROTO_VRRP; |
| 542 | case IP_PROTO_NUM_PGM: |
| 543 | return IP_PROTO_PGM; |
| 544 | case IP_PROTO_NUM_ZERO_HOP: |
| 545 | return IP_PROTO_ZERO_HOP; |
| 546 | case IP_PROTO_NUM_L2TP: |
| 547 | return IP_PROTO_L2TP; |
| 548 | case IP_PROTO_NUM_DDX: |
| 549 | return IP_PROTO_DDX; |
| 550 | case IP_PROTO_NUM_IATP: |
| 551 | return IP_PROTO_IATP; |
| 552 | case IP_PROTO_NUM_STP: |
| 553 | return IP_PROTO_STP; |
| 554 | case IP_PROTO_NUM_SRP: |
| 555 | return IP_PROTO_SRP; |
| 556 | case IP_PROTO_NUM_UTI: |
| 557 | return IP_PROTO_UTI; |
| 558 | case IP_PROTO_NUM_SMP: |
| 559 | return IP_PROTO_SMP; |
| 560 | case IP_PROTO_NUM_SM: |
| 561 | return IP_PROTO_SM; |
| 562 | case IP_PROTO_NUM_PTP: |
| 563 | return IP_PROTO_PTP; |
| 564 | case IP_PROTO_NUM_IS_IS_OVER_IPv4: |
| 565 | return IP_PROTO_IS_IS_OVER_IPv4; |
| 566 | case IP_PROTO_NUM_FIRE: |
| 567 | return IP_PROTO_FIRE; |
| 568 | case IP_PROTO_NUM_CRTP: |
| 569 | return IP_PROTO_CRTP; |
| 570 | case IP_PROTO_NUM_CRUDP: |
| 571 | return IP_PROTO_CRUDP; |
| 572 | case IP_PROTO_NUM_SSCOPMCE: |
| 573 | return IP_PROTO_SSCOPMCE; |
| 574 | case IP_PROTO_NUM_IPLT: |
| 575 | return IP_PROTO_IPLT; |
| 576 | case IP_PROTO_NUM_SPS: |
| 577 | return IP_PROTO_SPS; |
| 578 | case IP_PROTO_NUM_PIPE: |
| 579 | return IP_PROTO_PIPE; |
| 580 | case IP_PROTO_NUM_SCTP: |
| 581 | return IP_PROTO_SCTP; |
| 582 | case IP_PROTO_NUM_FC: |
| 583 | return IP_PROTO_FC; |
| 584 | case IP_PROTO_NUM_RSVP_E2E_IGNORE: |
| 585 | return IP_PROTO_RSVP_E2E_IGNORE; |
| 586 | case IP_PROTO_NUM_MOBILITY_HEADER: |
| 587 | return IP_PROTO_MOBILITY_HEADER; |
| 588 | case IP_PROTO_NUM_UDP_LITE: |
| 589 | return IP_PROTO_UDP_LITE; |
| 590 | case IP_PROTO_NUM_MPLS_IN_IP: |
| 591 | return IP_PROTO_MPLS_IN_IP; |
| 592 | case IP_PROTO_NUM_MANET: |
| 593 | return IP_PROTO_MANET; |
| 594 | case IP_PROTO_NUM_HIP: |
| 595 | return IP_PROTO_HIP; |
| 596 | case IP_PROTO_NUM_SHIM6: |
| 597 | return IP_PROTO_SHIM6; |
| 598 | default: |
| 599 | if (proto >= MAX_PROTO) { |
| 600 | throw new IllegalArgumentException("Illegal IP protocol number: " |
| 601 | + proto); |
| 602 | } else { |
| 603 | return new IpProtocol(proto); |
| 604 | } |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | @Override |
| 609 | public boolean equals(Object obj) { |
| 610 | if (!(obj instanceof IpProtocol)) |
| 611 | return false; |
| 612 | IpProtocol o = (IpProtocol)obj; |
| 613 | if (o.proto != this.proto) |
| 614 | return false; |
| 615 | return true; |
| 616 | } |
| 617 | |
| 618 | @Override |
| 619 | public int hashCode() { |
| 620 | final int prime = 37; |
| 621 | int result = 1; |
| 622 | result = prime * result + proto; |
| 623 | return result; |
| 624 | } |
| 625 | |
| 626 | @Override |
| 627 | public String toString() { |
| 628 | return Integer.toHexString(proto); |
| 629 | } |
Yotam Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 630 | |
| 631 | public void writeByte(ChannelBuffer c) { |
| 632 | c.writeByte(this.proto); |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame] | 633 | } |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 634 | |
Yotam Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 635 | public static IpProtocol readByte(ChannelBuffer c) { |
| 636 | return IpProtocol.of(c.readUnsignedByte()); |
| 637 | } |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame] | 638 | |
| 639 | @Override |
| 640 | public IpProtocol applyMask(IpProtocol mask) { |
| 641 | return IpProtocol.of((short)(this.proto & mask.proto)); |
| 642 | } |
| 643 | |
| 644 | public short getIpProtocolNumber() { |
| 645 | return proto; |
| 646 | } |
| 647 | |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 648 | } |