ParseStringFlag.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace IPLib;
  3. /**
  4. * Flags for the parseString() methods.
  5. *
  6. * @since 1.17.0
  7. */
  8. class ParseStringFlag
  9. {
  10. /**
  11. * Use this flag if the input string may include the port.
  12. *
  13. * @var int
  14. */
  15. const MAY_INCLUDE_PORT = 1;
  16. /**
  17. * Use this flag if the input string may include a zone ID.
  18. *
  19. * @var int
  20. */
  21. const MAY_INCLUDE_ZONEID = 2;
  22. /**
  23. * Use this flag if IPv4 addresses may be in decimal/octal/hexadecimal format.
  24. * This notation is accepted by the implementation of inet_aton and inet_addr of the libc implementation of GNU, Windows and Mac (but not Musl), but not by inet_pton and ip2long.
  25. *
  26. * @var int
  27. *
  28. * @example 1.08.0x10.0 => 5.0.0.1
  29. * @example 5.256 => 5.0.1.0
  30. * @example 5.0.256 => 5.0.1.0
  31. * @example 123456789 => 7.91.205.21
  32. */
  33. const IPV4_MAYBE_NON_DECIMAL = 4;
  34. /**
  35. * Use this flag if IPv4 subnet ranges may be in compact form.
  36. *
  37. * @example 127/24 => 127.0.0.0/24
  38. * @example 10/8 => 10.0.0.0/8
  39. * @example 10/24 => 10.0.0.0/24
  40. * @example 10.10.10/24 => 10.10.10.0/24
  41. *
  42. * @var int
  43. */
  44. const IPV4SUBNET_MAYBE_COMPACT = 8;
  45. /**
  46. * Use this flag if IPv4 addresses may be in non quad-dotted notation.
  47. * This notation is accepted by the implementation of inet_aton and inet_addr of the libc implementation of GNU, Windows and Mac (but not Musl), but not by inet_pton and ip2long.
  48. *
  49. * @var int
  50. *
  51. * @example 5.1 => 5.0.0.1
  52. * @example 5.256 => 5.0.1.0
  53. * @example 5.0.256 => 5.0.1.0
  54. * @example 123456789 => 7.91.205.21
  55. *
  56. * @see https://man7.org/linux/man-pages/man3/inet_addr.3.html#DESCRIPTION
  57. * @see https://www.freebsd.org/cgi/man.cgi?query=inet_net&sektion=3&apropos=0&manpath=FreeBSD+12.2-RELEASE+and+Ports#end
  58. * @see http://git.musl-libc.org/cgit/musl/tree/src/network/inet_aton.c?h=v1.2.2
  59. */
  60. const IPV4ADDRESS_MAYBE_NON_QUAD_DOTTED = 16;
  61. /**
  62. * Use this flag if you want to accept parsing IPv4/IPv6 addresses in Reverse DNS Lookup Address format.
  63. *
  64. * @var int
  65. *
  66. * @since 1.18.0
  67. *
  68. * @example 140.13.12.10.in-addr.arpa => 10.12.13.140
  69. * @example b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.0.0.0.0.1.2.3.4.ip6.arpa => 4321:0:1:2:3:4:567:89ab
  70. */
  71. const ADDRESS_MAYBE_RDNS = 32;
  72. }