rfc.go 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948
  1. package sockaddr
  2. // ForwardingBlacklist is a faux RFC that includes a list of non-forwardable IP
  3. // blocks.
  4. const ForwardingBlacklist = 4294967295
  5. const ForwardingBlacklistRFC = "4294967295"
  6. // IsRFC tests to see if an SockAddr matches the specified RFC
  7. func IsRFC(rfcNum uint, sa SockAddr) bool {
  8. rfcNetMap := KnownRFCs()
  9. rfcNets, ok := rfcNetMap[rfcNum]
  10. if !ok {
  11. return false
  12. }
  13. var contained bool
  14. for _, rfcNet := range rfcNets {
  15. if rfcNet.Contains(sa) {
  16. contained = true
  17. break
  18. }
  19. }
  20. return contained
  21. }
  22. // KnownRFCs returns an initial set of known RFCs.
  23. //
  24. // NOTE (sean@): As this list evolves over time, please submit patches to keep
  25. // this list current. If something isn't right, inquire, as it may just be a
  26. // bug on my part. Some of the inclusions were based on my judgement as to what
  27. // would be a useful value (e.g. RFC3330).
  28. //
  29. // Useful resources:
  30. //
  31. // * https://www.iana.org/assignments/ipv6-address-space/ipv6-address-space.xhtml
  32. // * https://www.iana.org/assignments/ipv6-unicast-address-assignments/ipv6-unicast-address-assignments.xhtml
  33. // * https://www.iana.org/assignments/ipv6-address-space/ipv6-address-space.xhtml
  34. func KnownRFCs() map[uint]SockAddrs {
  35. // NOTE(sean@): Multiple SockAddrs per RFC lend themselves well to a
  36. // RADIX tree, but `ENOTIME`. Patches welcome.
  37. return map[uint]SockAddrs{
  38. 919: {
  39. // [RFC919] Broadcasting Internet Datagrams
  40. MustIPv4Addr("255.255.255.255/32"), // [RFC1122], §7 Broadcast IP Addressing - Proposed Standards
  41. },
  42. 1122: {
  43. // [RFC1122] Requirements for Internet Hosts -- Communication Layers
  44. MustIPv4Addr("0.0.0.0/8"), // [RFC1122], §3.2.1.3
  45. MustIPv4Addr("127.0.0.0/8"), // [RFC1122], §3.2.1.3
  46. },
  47. 1112: {
  48. // [RFC1112] Host Extensions for IP Multicasting
  49. MustIPv4Addr("224.0.0.0/4"), // [RFC1112], §4 Host Group Addresses
  50. },
  51. 1918: {
  52. // [RFC1918] Address Allocation for Private Internets
  53. MustIPv4Addr("10.0.0.0/8"),
  54. MustIPv4Addr("172.16.0.0/12"),
  55. MustIPv4Addr("192.168.0.0/16"),
  56. },
  57. 2544: {
  58. // [RFC2544] Benchmarking Methodology for Network
  59. // Interconnect Devices
  60. MustIPv4Addr("198.18.0.0/15"),
  61. },
  62. 2765: {
  63. // [RFC2765] Stateless IP/ICMP Translation Algorithm
  64. // (SIIT) (obsoleted by RFCs 6145, which itself was
  65. // later obsoleted by 7915).
  66. // [RFC2765], §2.1 Addresses
  67. MustIPv6Addr("0:0:0:0:0:ffff:0:0/96"),
  68. },
  69. 2928: {
  70. // [RFC2928] Initial IPv6 Sub-TLA ID Assignments
  71. MustIPv6Addr("2001::/16"), // Superblock
  72. //MustIPv6Addr("2001:0000::/23"), // IANA
  73. //MustIPv6Addr("2001:0200::/23"), // APNIC
  74. //MustIPv6Addr("2001:0400::/23"), // ARIN
  75. //MustIPv6Addr("2001:0600::/23"), // RIPE NCC
  76. //MustIPv6Addr("2001:0800::/23"), // (future assignment)
  77. // ...
  78. //MustIPv6Addr("2001:FE00::/23"), // (future assignment)
  79. },
  80. 3056: { // 6to4 address
  81. // [RFC3056] Connection of IPv6 Domains via IPv4 Clouds
  82. // [RFC3056], §2 IPv6 Prefix Allocation
  83. MustIPv6Addr("2002::/16"),
  84. },
  85. 3068: {
  86. // [RFC3068] An Anycast Prefix for 6to4 Relay Routers
  87. // (obsolete by RFC7526)
  88. // [RFC3068], § 6to4 Relay anycast address
  89. MustIPv4Addr("192.88.99.0/24"),
  90. // [RFC3068], §2.5 6to4 IPv6 relay anycast address
  91. //
  92. // NOTE: /120 == 128-(32-24)
  93. MustIPv6Addr("2002:c058:6301::/120"),
  94. },
  95. 3171: {
  96. // [RFC3171] IANA Guidelines for IPv4 Multicast Address Assignments
  97. MustIPv4Addr("224.0.0.0/4"),
  98. },
  99. 3330: {
  100. // [RFC3330] Special-Use IPv4 Addresses
  101. // Addresses in this block refer to source hosts on
  102. // "this" network. Address 0.0.0.0/32 may be used as a
  103. // source address for this host on this network; other
  104. // addresses within 0.0.0.0/8 may be used to refer to
  105. // specified hosts on this network [RFC1700, page 4].
  106. MustIPv4Addr("0.0.0.0/8"),
  107. // 10.0.0.0/8 - This block is set aside for use in
  108. // private networks. Its intended use is documented in
  109. // [RFC1918]. Addresses within this block should not
  110. // appear on the public Internet.
  111. MustIPv4Addr("10.0.0.0/8"),
  112. // 14.0.0.0/8 - This block is set aside for assignments
  113. // to the international system of Public Data Networks
  114. // [RFC1700, page 181]. The registry of assignments
  115. // within this block can be accessed from the "Public
  116. // Data Network Numbers" link on the web page at
  117. // http://www.iana.org/numbers.html. Addresses within
  118. // this block are assigned to users and should be
  119. // treated as such.
  120. // 24.0.0.0/8 - This block was allocated in early 1996
  121. // for use in provisioning IP service over cable
  122. // television systems. Although the IANA initially was
  123. // involved in making assignments to cable operators,
  124. // this responsibility was transferred to American
  125. // Registry for Internet Numbers (ARIN) in May 2001.
  126. // Addresses within this block are assigned in the
  127. // normal manner and should be treated as such.
  128. // 39.0.0.0/8 - This block was used in the "Class A
  129. // Subnet Experiment" that commenced in May 1995, as
  130. // documented in [RFC1797]. The experiment has been
  131. // completed and this block has been returned to the
  132. // pool of addresses reserved for future allocation or
  133. // assignment. This block therefore no longer has a
  134. // special use and is subject to allocation to a
  135. // Regional Internet Registry for assignment in the
  136. // normal manner.
  137. // 127.0.0.0/8 - This block is assigned for use as the Internet host
  138. // loopback address. A datagram sent by a higher level protocol to an
  139. // address anywhere within this block should loop back inside the host.
  140. // This is ordinarily implemented using only 127.0.0.1/32 for loopback,
  141. // but no addresses within this block should ever appear on any network
  142. // anywhere [RFC1700, page 5].
  143. MustIPv4Addr("127.0.0.0/8"),
  144. // 128.0.0.0/16 - This block, corresponding to the
  145. // numerically lowest of the former Class B addresses,
  146. // was initially and is still reserved by the IANA.
  147. // Given the present classless nature of the IP address
  148. // space, the basis for the reservation no longer
  149. // applies and addresses in this block are subject to
  150. // future allocation to a Regional Internet Registry for
  151. // assignment in the normal manner.
  152. // 169.254.0.0/16 - This is the "link local" block. It
  153. // is allocated for communication between hosts on a
  154. // single link. Hosts obtain these addresses by
  155. // auto-configuration, such as when a DHCP server may
  156. // not be found.
  157. MustIPv4Addr("169.254.0.0/16"),
  158. // 172.16.0.0/12 - This block is set aside for use in
  159. // private networks. Its intended use is documented in
  160. // [RFC1918]. Addresses within this block should not
  161. // appear on the public Internet.
  162. MustIPv4Addr("172.16.0.0/12"),
  163. // 191.255.0.0/16 - This block, corresponding to the numerically highest
  164. // to the former Class B addresses, was initially and is still reserved
  165. // by the IANA. Given the present classless nature of the IP address
  166. // space, the basis for the reservation no longer applies and addresses
  167. // in this block are subject to future allocation to a Regional Internet
  168. // Registry for assignment in the normal manner.
  169. // 192.0.0.0/24 - This block, corresponding to the
  170. // numerically lowest of the former Class C addresses,
  171. // was initially and is still reserved by the IANA.
  172. // Given the present classless nature of the IP address
  173. // space, the basis for the reservation no longer
  174. // applies and addresses in this block are subject to
  175. // future allocation to a Regional Internet Registry for
  176. // assignment in the normal manner.
  177. // 192.0.2.0/24 - This block is assigned as "TEST-NET" for use in
  178. // documentation and example code. It is often used in conjunction with
  179. // domain names example.com or example.net in vendor and protocol
  180. // documentation. Addresses within this block should not appear on the
  181. // public Internet.
  182. MustIPv4Addr("192.0.2.0/24"),
  183. // 192.88.99.0/24 - This block is allocated for use as 6to4 relay
  184. // anycast addresses, according to [RFC3068].
  185. MustIPv4Addr("192.88.99.0/24"),
  186. // 192.168.0.0/16 - This block is set aside for use in private networks.
  187. // Its intended use is documented in [RFC1918]. Addresses within this
  188. // block should not appear on the public Internet.
  189. MustIPv4Addr("192.168.0.0/16"),
  190. // 198.18.0.0/15 - This block has been allocated for use
  191. // in benchmark tests of network interconnect devices.
  192. // Its use is documented in [RFC2544].
  193. MustIPv4Addr("198.18.0.0/15"),
  194. // 223.255.255.0/24 - This block, corresponding to the
  195. // numerically highest of the former Class C addresses,
  196. // was initially and is still reserved by the IANA.
  197. // Given the present classless nature of the IP address
  198. // space, the basis for the reservation no longer
  199. // applies and addresses in this block are subject to
  200. // future allocation to a Regional Internet Registry for
  201. // assignment in the normal manner.
  202. // 224.0.0.0/4 - This block, formerly known as the Class
  203. // D address space, is allocated for use in IPv4
  204. // multicast address assignments. The IANA guidelines
  205. // for assignments from this space are described in
  206. // [RFC3171].
  207. MustIPv4Addr("224.0.0.0/4"),
  208. // 240.0.0.0/4 - This block, formerly known as the Class E address
  209. // space, is reserved. The "limited broadcast" destination address
  210. // 255.255.255.255 should never be forwarded outside the (sub-)net of
  211. // the source. The remainder of this space is reserved
  212. // for future use. [RFC1700, page 4]
  213. MustIPv4Addr("240.0.0.0/4"),
  214. },
  215. 3849: {
  216. // [RFC3849] IPv6 Address Prefix Reserved for Documentation
  217. MustIPv6Addr("2001:db8::/32"), // [RFC3849], §4 IANA Considerations
  218. },
  219. 3927: {
  220. // [RFC3927] Dynamic Configuration of IPv4 Link-Local Addresses
  221. MustIPv4Addr("169.254.0.0/16"), // [RFC3927], §2.1 Link-Local Address Selection
  222. },
  223. 4038: {
  224. // [RFC4038] Application Aspects of IPv6 Transition
  225. // [RFC4038], §4.2. IPv6 Applications in a Dual-Stack Node
  226. MustIPv6Addr("0:0:0:0:0:ffff::/96"),
  227. },
  228. 4193: {
  229. // [RFC4193] Unique Local IPv6 Unicast Addresses
  230. MustIPv6Addr("fc00::/7"),
  231. },
  232. 4291: {
  233. // [RFC4291] IP Version 6 Addressing Architecture
  234. // [RFC4291], §2.5.2 The Unspecified Address
  235. MustIPv6Addr("::/128"),
  236. // [RFC4291], §2.5.3 The Loopback Address
  237. MustIPv6Addr("::1/128"),
  238. // [RFC4291], §2.5.5.1. IPv4-Compatible IPv6 Address
  239. MustIPv6Addr("::/96"),
  240. // [RFC4291], §2.5.5.2. IPv4-Mapped IPv6 Address
  241. MustIPv6Addr("::ffff:0:0/96"),
  242. // [RFC4291], §2.5.6 Link-Local IPv6 Unicast Addresses
  243. MustIPv6Addr("fe80::/10"),
  244. // [RFC4291], §2.5.7 Site-Local IPv6 Unicast Addresses
  245. // (depreciated)
  246. MustIPv6Addr("fec0::/10"),
  247. // [RFC4291], §2.7 Multicast Addresses
  248. MustIPv6Addr("ff00::/8"),
  249. // IPv6 Multicast Information.
  250. //
  251. // In the following "table" below, `ff0x` is replaced
  252. // with the following values depending on the scope of
  253. // the query:
  254. //
  255. // IPv6 Multicast Scopes:
  256. // * ff00/9 // reserved
  257. // * ff01/9 // interface-local
  258. // * ff02/9 // link-local
  259. // * ff03/9 // realm-local
  260. // * ff04/9 // admin-local
  261. // * ff05/9 // site-local
  262. // * ff08/9 // organization-local
  263. // * ff0e/9 // global
  264. // * ff0f/9 // reserved
  265. //
  266. // IPv6 Multicast Addresses:
  267. // * ff0x::2 // All routers
  268. // * ff02::5 // OSPFIGP
  269. // * ff02::6 // OSPFIGP Designated Routers
  270. // * ff02::9 // RIP Routers
  271. // * ff02::a // EIGRP Routers
  272. // * ff02::d // All PIM Routers
  273. // * ff02::1a // All RPL Routers
  274. // * ff0x::fb // mDNSv6
  275. // * ff0x::101 // All Network Time Protocol (NTP) servers
  276. // * ff02::1:1 // Link Name
  277. // * ff02::1:2 // All-dhcp-agents
  278. // * ff02::1:3 // Link-local Multicast Name Resolution
  279. // * ff05::1:3 // All-dhcp-servers
  280. // * ff02::1:ff00:0/104 // Solicited-node multicast address.
  281. // * ff02::2:ff00:0/104 // Node Information Queries
  282. },
  283. 4380: {
  284. // [RFC4380] Teredo: Tunneling IPv6 over UDP through
  285. // Network Address Translations (NATs)
  286. // [RFC4380], §2.6 Global Teredo IPv6 Service Prefix
  287. MustIPv6Addr("2001:0000::/32"),
  288. },
  289. 4773: {
  290. // [RFC4773] Administration of the IANA Special Purpose IPv6 Address Block
  291. MustIPv6Addr("2001:0000::/23"), // IANA
  292. },
  293. 4843: {
  294. // [RFC4843] An IPv6 Prefix for Overlay Routable Cryptographic Hash Identifiers (ORCHID)
  295. MustIPv6Addr("2001:10::/28"), // [RFC4843], §7 IANA Considerations
  296. },
  297. 5180: {
  298. // [RFC5180] IPv6 Benchmarking Methodology for Network Interconnect Devices
  299. MustIPv6Addr("2001:0200::/48"), // [RFC5180], §8 IANA Considerations
  300. },
  301. 5735: {
  302. // [RFC5735] Special Use IPv4 Addresses
  303. MustIPv4Addr("192.0.2.0/24"), // TEST-NET-1
  304. MustIPv4Addr("198.51.100.0/24"), // TEST-NET-2
  305. MustIPv4Addr("203.0.113.0/24"), // TEST-NET-3
  306. MustIPv4Addr("198.18.0.0/15"), // Benchmarks
  307. },
  308. 5737: {
  309. // [RFC5737] IPv4 Address Blocks Reserved for Documentation
  310. MustIPv4Addr("192.0.2.0/24"), // TEST-NET-1
  311. MustIPv4Addr("198.51.100.0/24"), // TEST-NET-2
  312. MustIPv4Addr("203.0.113.0/24"), // TEST-NET-3
  313. },
  314. 6052: {
  315. // [RFC6052] IPv6 Addressing of IPv4/IPv6 Translators
  316. MustIPv6Addr("64:ff9b::/96"), // [RFC6052], §2.1. Well-Known Prefix
  317. },
  318. 6333: {
  319. // [RFC6333] Dual-Stack Lite Broadband Deployments Following IPv4 Exhaustion
  320. MustIPv4Addr("192.0.0.0/29"), // [RFC6333], §5.7 Well-Known IPv4 Address
  321. },
  322. 6598: {
  323. // [RFC6598] IANA-Reserved IPv4 Prefix for Shared Address Space
  324. MustIPv4Addr("100.64.0.0/10"),
  325. },
  326. 6666: {
  327. // [RFC6666] A Discard Prefix for IPv6
  328. MustIPv6Addr("0100::/64"),
  329. },
  330. 6890: {
  331. // [RFC6890] Special-Purpose IP Address Registries
  332. // From "RFC6890 §2.2.1 Information Requirements":
  333. /*
  334. The IPv4 and IPv6 Special-Purpose Address Registries maintain the
  335. following information regarding each entry:
  336. o Address Block - A block of IPv4 or IPv6 addresses that has been
  337. registered for a special purpose.
  338. o Name - A descriptive name for the special-purpose address block.
  339. o RFC - The RFC through which the special-purpose address block was
  340. requested.
  341. o Allocation Date - The date upon which the special-purpose address
  342. block was allocated.
  343. o Termination Date - The date upon which the allocation is to be
  344. terminated. This field is applicable for limited-use allocations
  345. only.
  346. o Source - A boolean value indicating whether an address from the
  347. allocated special-purpose address block is valid when used as the
  348. source address of an IP datagram that transits two devices.
  349. o Destination - A boolean value indicating whether an address from
  350. the allocated special-purpose address block is valid when used as
  351. the destination address of an IP datagram that transits two
  352. devices.
  353. o Forwardable - A boolean value indicating whether a router may
  354. forward an IP datagram whose destination address is drawn from the
  355. allocated special-purpose address block between external
  356. interfaces.
  357. o Global - A boolean value indicating whether an IP datagram whose
  358. destination address is drawn from the allocated special-purpose
  359. address block is forwardable beyond a specified administrative
  360. domain.
  361. o Reserved-by-Protocol - A boolean value indicating whether the
  362. special-purpose address block is reserved by IP, itself. This
  363. value is "TRUE" if the RFC that created the special-purpose
  364. address block requires all compliant IP implementations to behave
  365. in a special way when processing packets either to or from
  366. addresses contained by the address block.
  367. If the value of "Destination" is FALSE, the values of "Forwardable"
  368. and "Global" must also be false.
  369. */
  370. /*+----------------------+----------------------------+
  371. * | Attribute | Value |
  372. * +----------------------+----------------------------+
  373. * | Address Block | 0.0.0.0/8 |
  374. * | Name | "This host on this network"|
  375. * | RFC | [RFC1122], Section 3.2.1.3 |
  376. * | Allocation Date | September 1981 |
  377. * | Termination Date | N/A |
  378. * | Source | True |
  379. * | Destination | False |
  380. * | Forwardable | False |
  381. * | Global | False |
  382. * | Reserved-by-Protocol | True |
  383. * +----------------------+----------------------------+*/
  384. MustIPv4Addr("0.0.0.0/8"),
  385. /*+----------------------+---------------+
  386. * | Attribute | Value |
  387. * +----------------------+---------------+
  388. * | Address Block | 10.0.0.0/8 |
  389. * | Name | Private-Use |
  390. * | RFC | [RFC1918] |
  391. * | Allocation Date | February 1996 |
  392. * | Termination Date | N/A |
  393. * | Source | True |
  394. * | Destination | True |
  395. * | Forwardable | True |
  396. * | Global | False |
  397. * | Reserved-by-Protocol | False |
  398. * +----------------------+---------------+ */
  399. MustIPv4Addr("10.0.0.0/8"),
  400. /*+----------------------+----------------------+
  401. | Attribute | Value |
  402. +----------------------+----------------------+
  403. | Address Block | 100.64.0.0/10 |
  404. | Name | Shared Address Space |
  405. | RFC | [RFC6598] |
  406. | Allocation Date | April 2012 |
  407. | Termination Date | N/A |
  408. | Source | True |
  409. | Destination | True |
  410. | Forwardable | True |
  411. | Global | False |
  412. | Reserved-by-Protocol | False |
  413. +----------------------+----------------------+*/
  414. MustIPv4Addr("100.64.0.0/10"),
  415. /*+----------------------+----------------------------+
  416. | Attribute | Value |
  417. +----------------------+----------------------------+
  418. | Address Block | 127.0.0.0/8 |
  419. | Name | Loopback |
  420. | RFC | [RFC1122], Section 3.2.1.3 |
  421. | Allocation Date | September 1981 |
  422. | Termination Date | N/A |
  423. | Source | False [1] |
  424. | Destination | False [1] |
  425. | Forwardable | False [1] |
  426. | Global | False [1] |
  427. | Reserved-by-Protocol | True |
  428. +----------------------+----------------------------+*/
  429. // [1] Several protocols have been granted exceptions to
  430. // this rule. For examples, see [RFC4379] and
  431. // [RFC5884].
  432. MustIPv4Addr("127.0.0.0/8"),
  433. /*+----------------------+----------------+
  434. | Attribute | Value |
  435. +----------------------+----------------+
  436. | Address Block | 169.254.0.0/16 |
  437. | Name | Link Local |
  438. | RFC | [RFC3927] |
  439. | Allocation Date | May 2005 |
  440. | Termination Date | N/A |
  441. | Source | True |
  442. | Destination | True |
  443. | Forwardable | False |
  444. | Global | False |
  445. | Reserved-by-Protocol | True |
  446. +----------------------+----------------+*/
  447. MustIPv4Addr("169.254.0.0/16"),
  448. /*+----------------------+---------------+
  449. | Attribute | Value |
  450. +----------------------+---------------+
  451. | Address Block | 172.16.0.0/12 |
  452. | Name | Private-Use |
  453. | RFC | [RFC1918] |
  454. | Allocation Date | February 1996 |
  455. | Termination Date | N/A |
  456. | Source | True |
  457. | Destination | True |
  458. | Forwardable | True |
  459. | Global | False |
  460. | Reserved-by-Protocol | False |
  461. +----------------------+---------------+*/
  462. MustIPv4Addr("172.16.0.0/12"),
  463. /*+----------------------+---------------------------------+
  464. | Attribute | Value |
  465. +----------------------+---------------------------------+
  466. | Address Block | 192.0.0.0/24 [2] |
  467. | Name | IETF Protocol Assignments |
  468. | RFC | Section 2.1 of this document |
  469. | Allocation Date | January 2010 |
  470. | Termination Date | N/A |
  471. | Source | False |
  472. | Destination | False |
  473. | Forwardable | False |
  474. | Global | False |
  475. | Reserved-by-Protocol | False |
  476. +----------------------+---------------------------------+*/
  477. // [2] Not usable unless by virtue of a more specific
  478. // reservation.
  479. MustIPv4Addr("192.0.0.0/24"),
  480. /*+----------------------+--------------------------------+
  481. | Attribute | Value |
  482. +----------------------+--------------------------------+
  483. | Address Block | 192.0.0.0/29 |
  484. | Name | IPv4 Service Continuity Prefix |
  485. | RFC | [RFC6333], [RFC7335] |
  486. | Allocation Date | June 2011 |
  487. | Termination Date | N/A |
  488. | Source | True |
  489. | Destination | True |
  490. | Forwardable | True |
  491. | Global | False |
  492. | Reserved-by-Protocol | False |
  493. +----------------------+--------------------------------+*/
  494. MustIPv4Addr("192.0.0.0/29"),
  495. /*+----------------------+----------------------------+
  496. | Attribute | Value |
  497. +----------------------+----------------------------+
  498. | Address Block | 192.0.2.0/24 |
  499. | Name | Documentation (TEST-NET-1) |
  500. | RFC | [RFC5737] |
  501. | Allocation Date | January 2010 |
  502. | Termination Date | N/A |
  503. | Source | False |
  504. | Destination | False |
  505. | Forwardable | False |
  506. | Global | False |
  507. | Reserved-by-Protocol | False |
  508. +----------------------+----------------------------+*/
  509. MustIPv4Addr("192.0.2.0/24"),
  510. /*+----------------------+--------------------+
  511. | Attribute | Value |
  512. +----------------------+--------------------+
  513. | Address Block | 192.88.99.0/24 |
  514. | Name | 6to4 Relay Anycast |
  515. | RFC | [RFC3068] |
  516. | Allocation Date | June 2001 |
  517. | Termination Date | N/A |
  518. | Source | True |
  519. | Destination | True |
  520. | Forwardable | True |
  521. | Global | True |
  522. | Reserved-by-Protocol | False |
  523. +----------------------+--------------------+*/
  524. MustIPv4Addr("192.88.99.0/24"),
  525. /*+----------------------+----------------+
  526. | Attribute | Value |
  527. +----------------------+----------------+
  528. | Address Block | 192.168.0.0/16 |
  529. | Name | Private-Use |
  530. | RFC | [RFC1918] |
  531. | Allocation Date | February 1996 |
  532. | Termination Date | N/A |
  533. | Source | True |
  534. | Destination | True |
  535. | Forwardable | True |
  536. | Global | False |
  537. | Reserved-by-Protocol | False |
  538. +----------------------+----------------+*/
  539. MustIPv4Addr("192.168.0.0/16"),
  540. /*+----------------------+---------------+
  541. | Attribute | Value |
  542. +----------------------+---------------+
  543. | Address Block | 198.18.0.0/15 |
  544. | Name | Benchmarking |
  545. | RFC | [RFC2544] |
  546. | Allocation Date | March 1999 |
  547. | Termination Date | N/A |
  548. | Source | True |
  549. | Destination | True |
  550. | Forwardable | True |
  551. | Global | False |
  552. | Reserved-by-Protocol | False |
  553. +----------------------+---------------+*/
  554. MustIPv4Addr("198.18.0.0/15"),
  555. /*+----------------------+----------------------------+
  556. | Attribute | Value |
  557. +----------------------+----------------------------+
  558. | Address Block | 198.51.100.0/24 |
  559. | Name | Documentation (TEST-NET-2) |
  560. | RFC | [RFC5737] |
  561. | Allocation Date | January 2010 |
  562. | Termination Date | N/A |
  563. | Source | False |
  564. | Destination | False |
  565. | Forwardable | False |
  566. | Global | False |
  567. | Reserved-by-Protocol | False |
  568. +----------------------+----------------------------+*/
  569. MustIPv4Addr("198.51.100.0/24"),
  570. /*+----------------------+----------------------------+
  571. | Attribute | Value |
  572. +----------------------+----------------------------+
  573. | Address Block | 203.0.113.0/24 |
  574. | Name | Documentation (TEST-NET-3) |
  575. | RFC | [RFC5737] |
  576. | Allocation Date | January 2010 |
  577. | Termination Date | N/A |
  578. | Source | False |
  579. | Destination | False |
  580. | Forwardable | False |
  581. | Global | False |
  582. | Reserved-by-Protocol | False |
  583. +----------------------+----------------------------+*/
  584. MustIPv4Addr("203.0.113.0/24"),
  585. /*+----------------------+----------------------+
  586. | Attribute | Value |
  587. +----------------------+----------------------+
  588. | Address Block | 240.0.0.0/4 |
  589. | Name | Reserved |
  590. | RFC | [RFC1112], Section 4 |
  591. | Allocation Date | August 1989 |
  592. | Termination Date | N/A |
  593. | Source | False |
  594. | Destination | False |
  595. | Forwardable | False |
  596. | Global | False |
  597. | Reserved-by-Protocol | True |
  598. +----------------------+----------------------+*/
  599. MustIPv4Addr("240.0.0.0/4"),
  600. /*+----------------------+----------------------+
  601. | Attribute | Value |
  602. +----------------------+----------------------+
  603. | Address Block | 255.255.255.255/32 |
  604. | Name | Limited Broadcast |
  605. | RFC | [RFC0919], Section 7 |
  606. | Allocation Date | October 1984 |
  607. | Termination Date | N/A |
  608. | Source | False |
  609. | Destination | True |
  610. | Forwardable | False |
  611. | Global | False |
  612. | Reserved-by-Protocol | False |
  613. +----------------------+----------------------+*/
  614. MustIPv4Addr("255.255.255.255/32"),
  615. /*+----------------------+------------------+
  616. | Attribute | Value |
  617. +----------------------+------------------+
  618. | Address Block | ::1/128 |
  619. | Name | Loopback Address |
  620. | RFC | [RFC4291] |
  621. | Allocation Date | February 2006 |
  622. | Termination Date | N/A |
  623. | Source | False |
  624. | Destination | False |
  625. | Forwardable | False |
  626. | Global | False |
  627. | Reserved-by-Protocol | True |
  628. +----------------------+------------------+*/
  629. MustIPv6Addr("::1/128"),
  630. /*+----------------------+---------------------+
  631. | Attribute | Value |
  632. +----------------------+---------------------+
  633. | Address Block | ::/128 |
  634. | Name | Unspecified Address |
  635. | RFC | [RFC4291] |
  636. | Allocation Date | February 2006 |
  637. | Termination Date | N/A |
  638. | Source | True |
  639. | Destination | False |
  640. | Forwardable | False |
  641. | Global | False |
  642. | Reserved-by-Protocol | True |
  643. +----------------------+---------------------+*/
  644. MustIPv6Addr("::/128"),
  645. /*+----------------------+---------------------+
  646. | Attribute | Value |
  647. +----------------------+---------------------+
  648. | Address Block | 64:ff9b::/96 |
  649. | Name | IPv4-IPv6 Translat. |
  650. | RFC | [RFC6052] |
  651. | Allocation Date | October 2010 |
  652. | Termination Date | N/A |
  653. | Source | True |
  654. | Destination | True |
  655. | Forwardable | True |
  656. | Global | True |
  657. | Reserved-by-Protocol | False |
  658. +----------------------+---------------------+*/
  659. MustIPv6Addr("64:ff9b::/96"),
  660. /*+----------------------+---------------------+
  661. | Attribute | Value |
  662. +----------------------+---------------------+
  663. | Address Block | ::ffff:0:0/96 |
  664. | Name | IPv4-mapped Address |
  665. | RFC | [RFC4291] |
  666. | Allocation Date | February 2006 |
  667. | Termination Date | N/A |
  668. | Source | False |
  669. | Destination | False |
  670. | Forwardable | False |
  671. | Global | False |
  672. | Reserved-by-Protocol | True |
  673. +----------------------+---------------------+*/
  674. MustIPv6Addr("::ffff:0:0/96"),
  675. /*+----------------------+----------------------------+
  676. | Attribute | Value |
  677. +----------------------+----------------------------+
  678. | Address Block | 100::/64 |
  679. | Name | Discard-Only Address Block |
  680. | RFC | [RFC6666] |
  681. | Allocation Date | June 2012 |
  682. | Termination Date | N/A |
  683. | Source | True |
  684. | Destination | True |
  685. | Forwardable | True |
  686. | Global | False |
  687. | Reserved-by-Protocol | False |
  688. +----------------------+----------------------------+*/
  689. MustIPv6Addr("100::/64"),
  690. /*+----------------------+---------------------------+
  691. | Attribute | Value |
  692. +----------------------+---------------------------+
  693. | Address Block | 2001::/23 |
  694. | Name | IETF Protocol Assignments |
  695. | RFC | [RFC2928] |
  696. | Allocation Date | September 2000 |
  697. | Termination Date | N/A |
  698. | Source | False[1] |
  699. | Destination | False[1] |
  700. | Forwardable | False[1] |
  701. | Global | False[1] |
  702. | Reserved-by-Protocol | False |
  703. +----------------------+---------------------------+*/
  704. // [1] Unless allowed by a more specific allocation.
  705. MustIPv6Addr("2001::/16"),
  706. /*+----------------------+----------------+
  707. | Attribute | Value |
  708. +----------------------+----------------+
  709. | Address Block | 2001::/32 |
  710. | Name | TEREDO |
  711. | RFC | [RFC4380] |
  712. | Allocation Date | January 2006 |
  713. | Termination Date | N/A |
  714. | Source | True |
  715. | Destination | True |
  716. | Forwardable | True |
  717. | Global | False |
  718. | Reserved-by-Protocol | False |
  719. +----------------------+----------------+*/
  720. // Covered by previous entry, included for completeness.
  721. //
  722. // MustIPv6Addr("2001::/16"),
  723. /*+----------------------+----------------+
  724. | Attribute | Value |
  725. +----------------------+----------------+
  726. | Address Block | 2001:2::/48 |
  727. | Name | Benchmarking |
  728. | RFC | [RFC5180] |
  729. | Allocation Date | April 2008 |
  730. | Termination Date | N/A |
  731. | Source | True |
  732. | Destination | True |
  733. | Forwardable | True |
  734. | Global | False |
  735. | Reserved-by-Protocol | False |
  736. +----------------------+----------------+*/
  737. // Covered by previous entry, included for completeness.
  738. //
  739. // MustIPv6Addr("2001:2::/48"),
  740. /*+----------------------+---------------+
  741. | Attribute | Value |
  742. +----------------------+---------------+
  743. | Address Block | 2001:db8::/32 |
  744. | Name | Documentation |
  745. | RFC | [RFC3849] |
  746. | Allocation Date | July 2004 |
  747. | Termination Date | N/A |
  748. | Source | False |
  749. | Destination | False |
  750. | Forwardable | False |
  751. | Global | False |
  752. | Reserved-by-Protocol | False |
  753. +----------------------+---------------+*/
  754. // Covered by previous entry, included for completeness.
  755. //
  756. // MustIPv6Addr("2001:db8::/32"),
  757. /*+----------------------+--------------+
  758. | Attribute | Value |
  759. +----------------------+--------------+
  760. | Address Block | 2001:10::/28 |
  761. | Name | ORCHID |
  762. | RFC | [RFC4843] |
  763. | Allocation Date | March 2007 |
  764. | Termination Date | March 2014 |
  765. | Source | False |
  766. | Destination | False |
  767. | Forwardable | False |
  768. | Global | False |
  769. | Reserved-by-Protocol | False |
  770. +----------------------+--------------+*/
  771. // Covered by previous entry, included for completeness.
  772. //
  773. // MustIPv6Addr("2001:10::/28"),
  774. /*+----------------------+---------------+
  775. | Attribute | Value |
  776. +----------------------+---------------+
  777. | Address Block | 2002::/16 [2] |
  778. | Name | 6to4 |
  779. | RFC | [RFC3056] |
  780. | Allocation Date | February 2001 |
  781. | Termination Date | N/A |
  782. | Source | True |
  783. | Destination | True |
  784. | Forwardable | True |
  785. | Global | N/A [2] |
  786. | Reserved-by-Protocol | False |
  787. +----------------------+---------------+*/
  788. // [2] See [RFC3056] for details.
  789. MustIPv6Addr("2002::/16"),
  790. /*+----------------------+--------------+
  791. | Attribute | Value |
  792. +----------------------+--------------+
  793. | Address Block | fc00::/7 |
  794. | Name | Unique-Local |
  795. | RFC | [RFC4193] |
  796. | Allocation Date | October 2005 |
  797. | Termination Date | N/A |
  798. | Source | True |
  799. | Destination | True |
  800. | Forwardable | True |
  801. | Global | False |
  802. | Reserved-by-Protocol | False |
  803. +----------------------+--------------+*/
  804. MustIPv6Addr("fc00::/7"),
  805. /*+----------------------+-----------------------+
  806. | Attribute | Value |
  807. +----------------------+-----------------------+
  808. | Address Block | fe80::/10 |
  809. | Name | Linked-Scoped Unicast |
  810. | RFC | [RFC4291] |
  811. | Allocation Date | February 2006 |
  812. | Termination Date | N/A |
  813. | Source | True |
  814. | Destination | True |
  815. | Forwardable | False |
  816. | Global | False |
  817. | Reserved-by-Protocol | True |
  818. +----------------------+-----------------------+*/
  819. MustIPv6Addr("fe80::/10"),
  820. },
  821. 7335: {
  822. // [RFC7335] IPv4 Service Continuity Prefix
  823. MustIPv4Addr("192.0.0.0/29"), // [RFC7335], §6 IANA Considerations
  824. },
  825. ForwardingBlacklist: { // Pseudo-RFC
  826. // Blacklist of non-forwardable IP blocks taken from RFC6890
  827. //
  828. // TODO: the attributes for forwardable should be
  829. // searcahble and embedded in the main list of RFCs
  830. // above.
  831. MustIPv4Addr("0.0.0.0/8"),
  832. MustIPv4Addr("127.0.0.0/8"),
  833. MustIPv4Addr("169.254.0.0/16"),
  834. MustIPv4Addr("192.0.0.0/24"),
  835. MustIPv4Addr("192.0.2.0/24"),
  836. MustIPv4Addr("198.51.100.0/24"),
  837. MustIPv4Addr("203.0.113.0/24"),
  838. MustIPv4Addr("240.0.0.0/4"),
  839. MustIPv4Addr("255.255.255.255/32"),
  840. MustIPv6Addr("::1/128"),
  841. MustIPv6Addr("::/128"),
  842. MustIPv6Addr("::ffff:0:0/96"),
  843. // There is no way of expressing a whitelist per RFC2928
  844. // atm without creating a negative mask, which I don't
  845. // want to do atm.
  846. //MustIPv6Addr("2001::/23"),
  847. MustIPv6Addr("2001:db8::/32"),
  848. MustIPv6Addr("2001:10::/28"),
  849. MustIPv6Addr("fe80::/10"),
  850. },
  851. }
  852. }
  853. // VisitAllRFCs iterates over all known RFCs and calls the visitor
  854. func VisitAllRFCs(fn func(rfcNum uint, sockaddrs SockAddrs)) {
  855. rfcNetMap := KnownRFCs()
  856. // Blacklist of faux-RFCs. Don't show the world that we're abusing the
  857. // RFC system in this library.
  858. rfcBlacklist := map[uint]struct{}{
  859. ForwardingBlacklist: {},
  860. }
  861. for rfcNum, sas := range rfcNetMap {
  862. if _, found := rfcBlacklist[rfcNum]; !found {
  863. fn(rfcNum, sas)
  864. }
  865. }
  866. }