rfc.go 39 KB

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