1use crate::PrimitiveValues;
2
3#[cfg(feature = "serde")]
4use serde::{Deserialize, Serialize};
5
6#[repr(u8)]
8#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
9#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
10pub enum IpNextLevelProtocol {
11 Hopopt = 0,
13 Icmp = 1,
15 Igmp = 2,
17 Ggp = 3,
19 Ipv4 = 4,
21 St = 5,
23 Tcp = 6,
25 Cbt = 7,
27 Egp = 8,
29 Igp = 9,
31 BbnRccMon = 10,
33 NvpII = 11,
35 Pup = 12,
37 Argus = 13,
39 Emcon = 14,
41 Xnet = 15,
43 Chaos = 16,
45 Udp = 17,
47 Mux = 18,
49 DcnMeas = 19,
51 Hmp = 20,
53 Prm = 21,
55 XnsIdp = 22,
57 Trunk1 = 23,
59 Trunk2 = 24,
61 Leaf1 = 25,
63 Leaf2 = 26,
65 Rdp = 27,
67 Irtp = 28,
69 IsoTp4 = 29,
71 Netblt = 30,
73 MfeNsp = 31,
75 MeritInp = 32,
77 Dccp = 33,
79 ThreePc = 34,
81 Idpr = 35,
83 Xtp = 36,
85 Ddp = 37,
87 IdprCmtp = 38,
89 TpPlusPlus = 39,
91 Il = 40,
93 Ipv6 = 41,
95 Sdrp = 42,
97 Ipv6Route = 43,
99 Ipv6Frag = 44,
101 Idrp = 45,
103 Rsvp = 46,
105 Gre = 47,
107 Dsr = 48,
109 Bna = 49,
111 Esp = 50,
113 Ah = 51,
115 INlsp = 52,
117 Swipe = 53,
119 Narp = 54,
121 Mobile = 55,
123 Tlsp = 56,
125 Skip = 57,
127 Icmpv6 = 58,
129 Ipv6NoNxt = 59,
131 Ipv6Opts = 60,
133 HostInternal = 61,
135 Cftp = 62,
137 LocalNetwork = 63,
139 SatExpak = 64,
141 Kryptolan = 65,
143 Rvd = 66,
145 Ippc = 67,
147 DistributedFs = 68,
149 SatMon = 69,
151 Visa = 70,
153 Ipcv = 71,
155 Cpnx = 72,
157 Cphb = 73,
159 Wsn = 74,
161 Pvp = 75,
163 BrSatMon = 76,
165 SunNd = 77,
167 WbMon = 78,
169 WbExpak = 79,
171 IsoIp = 80,
173 Vmtp = 81,
175 SecureVmtp = 82,
177 Vines = 83,
179 TtpOrIptm = 84,
181 NsfnetIgp = 85,
183 Dgp = 86,
185 Tcf = 87,
187 Eigrp = 88,
189 OspfigP = 89,
191 SpriteRpc = 90,
193 Larp = 91,
195 Mtp = 92,
197 Ax25 = 93,
199 IpIp = 94,
201 Micp = 95,
203 SccSp = 96,
205 Etherip = 97,
207 Encap = 98,
209 PrivEncryption = 99,
211 Gmtp = 100,
213 Ifmp = 101,
215 Pnni = 102,
217 Pim = 103,
219 Aris = 104,
221 Scps = 105,
223 Qnx = 106,
225 AN = 107,
227 IpComp = 108,
229 Snp = 109,
231 CompaqPeer = 110,
233 IpxInIp = 111,
235 Vrrp = 112,
237 Pgm = 113,
239 ZeroHop = 114,
241 L2tp = 115,
243 Ddx = 116,
245 Iatp = 117,
247 Stp = 118,
249 Srp = 119,
251 Uti = 120,
253 Smp = 121,
255 Sm = 122,
257 Ptp = 123,
259 IsisOverIpv4 = 124,
261 Fire = 125,
263 Crtp = 126,
265 Crudp = 127,
267 Sscopmce = 128,
269 Iplt = 129,
271 Sps = 130,
273 Pipe = 131,
275 Sctp = 132,
277 Fc = 133,
279 RsvpE2eIgnore = 134,
281 MobilityHeader = 135,
283 UdpLite = 136,
285 MplsInIp = 137,
287 Manet = 138,
289 Hip = 139,
291 Shim6 = 140,
293 Wesp = 141,
295 Rohc = 142,
297 Test1 = 253,
299 Test2 = 254,
301 Reserved = 255,
303}
304
305impl IpNextLevelProtocol {
306 pub fn new(n: u8) -> Self {
308 match n {
309 0 => Self::Hopopt,
310 1 => Self::Icmp,
311 2 => Self::Igmp,
312 3 => Self::Ggp,
313 4 => Self::Ipv4,
314 5 => Self::St,
315 6 => Self::Tcp,
316 7 => Self::Cbt,
317 8 => Self::Egp,
318 9 => Self::Igp,
319 10 => Self::BbnRccMon,
320 11 => Self::NvpII,
321 12 => Self::Pup,
322 13 => Self::Argus,
323 14 => Self::Emcon,
324 15 => Self::Xnet,
325 16 => Self::Chaos,
326 17 => Self::Udp,
327 18 => Self::Mux,
328 19 => Self::DcnMeas,
329 20 => Self::Hmp,
330 21 => Self::Prm,
331 22 => Self::XnsIdp,
332 23 => Self::Trunk1,
333 24 => Self::Trunk2,
334 25 => Self::Leaf1,
335 26 => Self::Leaf2,
336 27 => Self::Rdp,
337 28 => Self::Irtp,
338 29 => Self::IsoTp4,
339 30 => Self::Netblt,
340 31 => Self::MfeNsp,
341 32 => Self::MeritInp,
342 33 => Self::Dccp,
343 34 => Self::ThreePc,
344 35 => Self::Idpr,
345 36 => Self::Xtp,
346 37 => Self::Ddp,
347 38 => Self::IdprCmtp,
348 39 => Self::TpPlusPlus,
349 40 => Self::Il,
350 41 => Self::Ipv6,
351 42 => Self::Sdrp,
352 43 => Self::Ipv6Route,
353 44 => Self::Ipv6Frag,
354 45 => Self::Idrp,
355 46 => Self::Rsvp,
356 47 => Self::Gre,
357 48 => Self::Dsr,
358 49 => Self::Bna,
359 50 => Self::Esp,
360 51 => Self::Ah,
361 52 => Self::INlsp,
362 53 => Self::Swipe,
363 54 => Self::Narp,
364 55 => Self::Mobile,
365 56 => Self::Tlsp,
366 57 => Self::Skip,
367 58 => Self::Icmpv6,
368 59 => Self::Ipv6NoNxt,
369 60 => Self::Ipv6Opts,
370 61 => Self::HostInternal,
371 62 => Self::Cftp,
372 63 => Self::LocalNetwork,
373 64 => Self::SatExpak,
374 65 => Self::Kryptolan,
375 66 => Self::Rvd,
376 67 => Self::Ippc,
377 68 => Self::DistributedFs,
378 69 => Self::SatMon,
379 70 => Self::Visa,
380 71 => Self::Ipcv,
381 72 => Self::Cpnx,
382 73 => Self::Cphb,
383 74 => Self::Wsn,
384 75 => Self::Pvp,
385 76 => Self::BrSatMon,
386 77 => Self::SunNd,
387 78 => Self::WbMon,
388 79 => Self::WbExpak,
389 80 => Self::IsoIp,
390 81 => Self::Vmtp,
391 82 => Self::SecureVmtp,
392 83 => Self::Vines,
393 84 => Self::TtpOrIptm,
394 85 => Self::NsfnetIgp,
395 86 => Self::Dgp,
396 87 => Self::Tcf,
397 88 => Self::Eigrp,
398 89 => Self::OspfigP,
399 90 => Self::SpriteRpc,
400 91 => Self::Larp,
401 92 => Self::Mtp,
402 93 => Self::Ax25,
403 94 => Self::IpIp,
404 95 => Self::Micp,
405 96 => Self::SccSp,
406 97 => Self::Etherip,
407 98 => Self::Encap,
408 99 => Self::PrivEncryption,
409 100 => Self::Gmtp,
410 101 => Self::Ifmp,
411 102 => Self::Pnni,
412 103 => Self::Pim,
413 104 => Self::Aris,
414 105 => Self::Scps,
415 106 => Self::Qnx,
416 107 => Self::AN,
417 108 => Self::IpComp,
418 109 => Self::Snp,
419 110 => Self::CompaqPeer,
420 111 => Self::IpxInIp,
421 112 => Self::Vrrp,
422 113 => Self::Pgm,
423 114 => Self::ZeroHop,
424 115 => Self::L2tp,
425 116 => Self::Ddx,
426 117 => Self::Iatp,
427 118 => Self::Stp,
428 119 => Self::Srp,
429 120 => Self::Uti,
430 121 => Self::Smp,
431 122 => Self::Sm,
432 123 => Self::Ptp,
433 124 => Self::IsisOverIpv4,
434 125 => Self::Fire,
435 126 => Self::Crtp,
436 127 => Self::Crudp,
437 128 => Self::Sscopmce,
438 129 => Self::Iplt,
439 130 => Self::Sps,
440 131 => Self::Pipe,
441 132 => Self::Sctp,
442 133 => Self::Fc,
443 134 => Self::RsvpE2eIgnore,
444 135 => Self::MobilityHeader,
445 136 => Self::UdpLite,
446 137 => Self::MplsInIp,
447 138 => Self::Manet,
448 139 => Self::Hip,
449 140 => Self::Shim6,
450 141 => Self::Wesp,
451 142 => Self::Rohc,
452 253 => Self::Test1,
453 254 => Self::Test2,
454 _ => Self::Reserved,
455 }
456 }
457 pub fn as_str(&self) -> &'static str {
458 match self {
459 IpNextLevelProtocol::Hopopt => "Hopopt",
460 IpNextLevelProtocol::Icmp => "Icmp",
461 IpNextLevelProtocol::Igmp => "Igmp",
462 IpNextLevelProtocol::Ggp => "Ggp",
463 IpNextLevelProtocol::Ipv4 => "Ipv4",
464 IpNextLevelProtocol::St => "St",
465 IpNextLevelProtocol::Tcp => "Tcp",
466 IpNextLevelProtocol::Cbt => "Cbt",
467 IpNextLevelProtocol::Egp => "Egp",
468 IpNextLevelProtocol::Igp => "Igp",
469 IpNextLevelProtocol::BbnRccMon => "BbnRccMon",
470 IpNextLevelProtocol::NvpII => "NvpII",
471 IpNextLevelProtocol::Pup => "Pup",
472 IpNextLevelProtocol::Argus => "Argus",
473 IpNextLevelProtocol::Emcon => "Emcon",
474 IpNextLevelProtocol::Xnet => "Xnet",
475 IpNextLevelProtocol::Chaos => "Chaos",
476 IpNextLevelProtocol::Udp => "Udp",
477 IpNextLevelProtocol::Mux => "Mux",
478 IpNextLevelProtocol::DcnMeas => "DcnMeas",
479 IpNextLevelProtocol::Hmp => "Hmp",
480 IpNextLevelProtocol::Prm => "Prm",
481 IpNextLevelProtocol::XnsIdp => "XnsIdp",
482 IpNextLevelProtocol::Trunk1 => "Trunk1",
483 IpNextLevelProtocol::Trunk2 => "Trunk2",
484 IpNextLevelProtocol::Leaf1 => "Leaf1",
485 IpNextLevelProtocol::Leaf2 => "Leaf2",
486 IpNextLevelProtocol::Rdp => "Rdp",
487 IpNextLevelProtocol::Irtp => "Irtp",
488 IpNextLevelProtocol::IsoTp4 => "IsoTp4",
489 IpNextLevelProtocol::Netblt => "Netblt",
490 IpNextLevelProtocol::MfeNsp => "MfeNsp",
491 IpNextLevelProtocol::MeritInp => "MeritInp",
492 IpNextLevelProtocol::Dccp => "Dccp",
493 IpNextLevelProtocol::ThreePc => "ThreePc",
494 IpNextLevelProtocol::Idpr => "Idpr",
495 IpNextLevelProtocol::Xtp => "Xtp",
496 IpNextLevelProtocol::Ddp => "Ddp",
497 IpNextLevelProtocol::IdprCmtp => "IdprCmtp",
498 IpNextLevelProtocol::TpPlusPlus => "TpPlusPlus",
499 IpNextLevelProtocol::Il => "Il",
500 IpNextLevelProtocol::Ipv6 => "Ipv6",
501 IpNextLevelProtocol::Sdrp => "Sdrp",
502 IpNextLevelProtocol::Ipv6Route => "Ipv6Route",
503 IpNextLevelProtocol::Ipv6Frag => "Ipv6Frag",
504 IpNextLevelProtocol::Idrp => "Idrp",
505 IpNextLevelProtocol::Rsvp => "Rsvp",
506 IpNextLevelProtocol::Gre => "Gre",
507 IpNextLevelProtocol::Dsr => "Dsr",
508 IpNextLevelProtocol::Bna => "Bna",
509 IpNextLevelProtocol::Esp => "Esp",
510 IpNextLevelProtocol::Ah => "Ah",
511 IpNextLevelProtocol::INlsp => "INlsp",
512 IpNextLevelProtocol::Swipe => "Swipe",
513 IpNextLevelProtocol::Narp => "Narp",
514 IpNextLevelProtocol::Mobile => "Mobile",
515 IpNextLevelProtocol::Tlsp => "Tlsp",
516 IpNextLevelProtocol::Skip => "Skip",
517 IpNextLevelProtocol::Icmpv6 => "Icmpv6",
518 IpNextLevelProtocol::Ipv6NoNxt => "Ipv6NoNxt",
519 IpNextLevelProtocol::Ipv6Opts => "Ipv6Opts",
520 IpNextLevelProtocol::HostInternal => "HostInternal",
521 IpNextLevelProtocol::Cftp => "Cftp",
522 IpNextLevelProtocol::LocalNetwork => "LocalNetwork",
523 IpNextLevelProtocol::SatExpak => "SatExpak",
524 IpNextLevelProtocol::Kryptolan => "Kryptolan",
525 IpNextLevelProtocol::Rvd => "Rvd",
526 IpNextLevelProtocol::Ippc => "Ippc",
527 IpNextLevelProtocol::DistributedFs => "DistributedFs",
528 IpNextLevelProtocol::SatMon => "SatMon",
529 IpNextLevelProtocol::Visa => "Visa",
530 IpNextLevelProtocol::Ipcv => "Ipcv",
531 IpNextLevelProtocol::Cpnx => "Cpnx",
532 IpNextLevelProtocol::Cphb => "Cphb",
533 IpNextLevelProtocol::Wsn => "Wsn",
534 IpNextLevelProtocol::Pvp => "Pvp",
535 IpNextLevelProtocol::BrSatMon => "BrSatMon",
536 IpNextLevelProtocol::SunNd => "SunNd",
537 IpNextLevelProtocol::WbMon => "WbMon",
538 IpNextLevelProtocol::WbExpak => "WbExpak",
539 IpNextLevelProtocol::IsoIp => "IsoIp",
540 IpNextLevelProtocol::Vmtp => "Vmtp",
541 IpNextLevelProtocol::SecureVmtp => "SecureVmtp",
542 IpNextLevelProtocol::Vines => "Vines",
543 IpNextLevelProtocol::TtpOrIptm => "TtpOrIptm",
544 IpNextLevelProtocol::NsfnetIgp => "NsfnetIgp",
545 IpNextLevelProtocol::Dgp => "Dgp",
546 IpNextLevelProtocol::Tcf => "Tcf",
547 IpNextLevelProtocol::Eigrp => "Eigrp",
548 IpNextLevelProtocol::OspfigP => "OspfigP",
549 IpNextLevelProtocol::SpriteRpc => "SpriteRpc",
550 IpNextLevelProtocol::Larp => "Larp",
551 IpNextLevelProtocol::Mtp => "Mtp",
552 IpNextLevelProtocol::Ax25 => "Ax25",
553 IpNextLevelProtocol::IpIp => "IpIp",
554 IpNextLevelProtocol::Micp => "Micp",
555 IpNextLevelProtocol::SccSp => "SccSp",
556 IpNextLevelProtocol::Etherip => "Etherip",
557 IpNextLevelProtocol::Encap => "Encap",
558 IpNextLevelProtocol::PrivEncryption => "PrivEncryption",
559 IpNextLevelProtocol::Gmtp => "Gmtp",
560 IpNextLevelProtocol::Ifmp => "Ifmp",
561 IpNextLevelProtocol::Pnni => "Pnni",
562 IpNextLevelProtocol::Pim => "Pim",
563 IpNextLevelProtocol::Aris => "Aris",
564 IpNextLevelProtocol::Scps => "Scps",
565 IpNextLevelProtocol::Qnx => "Qnx",
566 IpNextLevelProtocol::AN => "AN",
567 IpNextLevelProtocol::IpComp => "IpComp",
568 IpNextLevelProtocol::Snp => "Snp",
569 IpNextLevelProtocol::CompaqPeer => "CompaqPeer",
570 IpNextLevelProtocol::IpxInIp => "IpxInIp",
571 IpNextLevelProtocol::Vrrp => "Vrrp",
572 IpNextLevelProtocol::Pgm => "Pgm",
573 IpNextLevelProtocol::ZeroHop => "ZeroHop",
574 IpNextLevelProtocol::L2tp => "L2tp",
575 IpNextLevelProtocol::Ddx => "Ddx",
576 IpNextLevelProtocol::Iatp => "Iatp",
577 IpNextLevelProtocol::Stp => "Stp",
578 IpNextLevelProtocol::Srp => "Srp",
579 IpNextLevelProtocol::Uti => "Uti",
580 IpNextLevelProtocol::Smp => "Smp",
581 IpNextLevelProtocol::Sm => "Sm",
582 IpNextLevelProtocol::Ptp => "Ptp",
583 IpNextLevelProtocol::IsisOverIpv4 => "IsisOverIpv4",
584 IpNextLevelProtocol::Fire => "Fire",
585 IpNextLevelProtocol::Crtp => "Crtp",
586 IpNextLevelProtocol::Crudp => "Crudp",
587 IpNextLevelProtocol::Sscopmce => "Sscopmce",
588 IpNextLevelProtocol::Iplt => "Iplt",
589 IpNextLevelProtocol::Sps => "Sps",
590 IpNextLevelProtocol::Pipe => "Pipe",
591 IpNextLevelProtocol::Sctp => "Sctp",
592 IpNextLevelProtocol::Fc => "Fc",
593 IpNextLevelProtocol::RsvpE2eIgnore => "RsvpE2eIgnore",
594 IpNextLevelProtocol::MobilityHeader => "MobilityHeader",
595 IpNextLevelProtocol::UdpLite => "UdpLite",
596 IpNextLevelProtocol::MplsInIp => "MplsInIp",
597 IpNextLevelProtocol::Manet => "Manet",
598 IpNextLevelProtocol::Hip => "Hip",
599 IpNextLevelProtocol::Shim6 => "Shim6",
600 IpNextLevelProtocol::Wesp => "Wesp",
601 IpNextLevelProtocol::Rohc => "Rohc",
602 IpNextLevelProtocol::Test1 => "Test1",
603 IpNextLevelProtocol::Test2 => "Test2",
604 IpNextLevelProtocol::Reserved => "Reserved",
605 }
606 }
607}
608
609impl PrimitiveValues for IpNextLevelProtocol {
610 type T = (u8,);
611 fn to_primitive_values(&self) -> (u8,) {
612 (*self as u8,)
613 }
614}