Skip to content

Commit 2712cdb

Browse files
committed
RFC 2292 struct and constant definitions
This PR adds the icmp6_filter struct and constants as defined by RFC 2292 - Advanced Sockets API for IPv6. These constants are available for use in get/setsockopt on supported Unix platforms. The operations defined on the icmp6_filter struct are defined as C macros, so the implementations are not included here. See the RFC for definitions and use.
1 parent 97e6889 commit 2712cdb

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

libc-test/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ fn test_apple(target: &str) {
254254
"netinet/ip.h",
255255
"netinet/tcp.h",
256256
"netinet/udp.h",
257+
"netinet/icmp6.h",
257258
"netinet6/in6_var.h",
258259
"os/clock.h",
259260
"os/lock.h",
@@ -449,6 +450,7 @@ fn test_openbsd(target: &str) {
449450
"netinet/ip.h",
450451
"netinet/tcp.h",
451452
"netinet/udp.h",
453+
"netinet/icmp6.h",
452454
"net/bpf.h",
453455
"regex.h",
454456
"resolv.h",
@@ -867,6 +869,7 @@ fn test_redox(target: &str) {
867869
"netinet/in.h",
868870
"netinet/ip.h",
869871
"netinet/tcp.h",
872+
"netinet/icmp6.h",
870873
"poll.h",
871874
"pwd.h",
872875
"semaphore.h",
@@ -945,6 +948,7 @@ fn test_solarish(target: &str) {
945948
"netinet/ip.h",
946949
"netinet/tcp.h",
947950
"netinet/udp.h",
951+
"netinet/icmp6.h",
948952
"poll.h",
949953
"port.h",
950954
"pthread.h",
@@ -1229,6 +1233,7 @@ fn test_netbsd(target: &str) {
12291233
"netinet/ip.h",
12301234
"netinet/tcp.h",
12311235
"netinet/udp.h",
1236+
"netinet/icmp6.h",
12321237
"poll.h",
12331238
"pthread.h",
12341239
"pwd.h",
@@ -1518,6 +1523,7 @@ fn test_dragonflybsd(target: &str) {
15181523
"netinet/ip.h",
15191524
"netinet/tcp.h",
15201525
"netinet/udp.h",
1526+
"netinet/icmp6.h",
15211527
"poll.h",
15221528
"pthread.h",
15231529
"pthread_np.h",
@@ -1833,6 +1839,7 @@ fn test_android(target: &str) {
18331839
"netinet/ip.h",
18341840
"netinet/tcp.h",
18351841
"netinet/udp.h",
1842+
"netinet/icmp6.h",
18361843
"netpacket/packet.h",
18371844
"poll.h",
18381845
"pthread.h",
@@ -2373,6 +2380,7 @@ fn test_freebsd(target: &str) {
23732380
"netinet/sctp.h",
23742381
"netinet/tcp.h",
23752382
"netinet/udp.h",
2383+
"netinet/icmp6.h",
23762384
"poll.h",
23772385
"pthread.h",
23782386
"pthread_np.h",
@@ -3000,6 +3008,7 @@ fn test_emscripten(target: &str) {
30003008
"netinet/ip.h",
30013009
"netinet/tcp.h",
30023010
"netinet/udp.h",
3011+
"netinet/icmp6.h",
30033012
"netpacket/packet.h",
30043013
"poll.h",
30053014
"pthread.h",
@@ -3268,6 +3277,7 @@ fn test_neutrino(target: &str) {
32683277
"netinet/tcp.h",
32693278
"netinet/udp.h",
32703279
"netinet/ip_var.h",
3280+
"netinet/icmp6.h",
32713281
"sys/poll.h",
32723282
"pthread.h",
32733283
"pwd.h",
@@ -3764,6 +3774,7 @@ fn test_linux(target: &str) {
37643774
"netinet/ip.h",
37653775
"netinet/tcp.h",
37663776
"netinet/udp.h",
3777+
"netinet/icmp6.h",
37673778
(l4re, "netpacket/packet.h"),
37683779
"poll.h",
37693780
"pthread.h",
@@ -5022,6 +5033,7 @@ fn test_haiku(target: &str) {
50225033
"netinet/ip_var.h",
50235034
"netinet/tcp.h",
50245035
"netinet/udp.h",
5036+
"netinet/icmp6.h",
50255037
"netinet6/in6.h",
50265038
"nl_types.h",
50275039
"null.h",

src/unix/mod.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ s! {
217217
pub struct in6_addr {
218218
pub s6_addr: [u8; 16],
219219
}
220+
221+
pub struct icmp6_filter {
222+
pub icmp6_filt: [u32; 8],
223+
}
220224
}
221225

222226
s_no_extra_traits! {
@@ -364,6 +368,48 @@ pub const ATF_PERM: c_int = 0x04;
364368
pub const ATF_PUBL: c_int = 0x08;
365369
pub const ATF_USETRAILERS: c_int = 0x10;
366370

371+
pub const ICMP6_FILTER: c_int = 1;
372+
373+
// ICMPv6 Type and Code Values
374+
pub const ICMP6_DST_UNREACH: u8 = 1;
375+
pub const ICMP6_PACKET_TOO_BIG: u8 = 2;
376+
pub const ICMP6_TIME_EXCEEDED: u8 = 3;
377+
pub const ICMP6_PARAM_PROB: u8 = 4;
378+
379+
pub const ICMP6_INFOMSG_MASK: u8 = 0x80;
380+
381+
pub const ICMP6_ECHO_REQUEST: u8 = 128;
382+
pub const ICMP6_ECHO_REPLY: u8 = 129;
383+
pub const MLD_LISTENER_QUERY: u8 = 130;
384+
pub const MLD_LISTENER_REPORT: u8 = 131;
385+
pub const MLD_LISTENER_REDUCTION: u8 = 132;
386+
387+
pub const ICMP6_DST_UNREACH_NOROUTE: u8 = 0;
388+
pub const ICMP6_DST_UNREACH_ADMIN: u8 = 1;
389+
pub const ICMP6_DST_UNREACH_BEYONDSCOPE: u8 = 2;
390+
pub const ICMP6_DST_UNREACH_ADDR: u8 = 3;
391+
pub const ICMP6_DST_UNREACH_NOPORT: u8 = 4;
392+
393+
pub const ICMP6_TIME_EXCEED_TRANSIT: u8 = 0;
394+
pub const ICMP6_TIME_EXCEED_REASSEMBLY: u8 = 1;
395+
396+
pub const ICMP6_PARAMPROB_HEADER: u8 = 0;
397+
pub const ICMP6_PARAMPROB_NEXTHEADER: u8 = 1;
398+
pub const ICMP6_PARAMPROB_OPTION: u8 = 2;
399+
400+
// ICMPv6 Neighbor Discovery Type and Code Values
401+
pub const ND_ROUTER_SOLICIT: u8 = 133;
402+
pub const ND_ROUTER_ADVERT: u8 = 134;
403+
pub const ND_NEIGHBOR_SOLICIT: u8 = 135;
404+
pub const ND_NEIGHBOR_ADVERT: u8 = 136;
405+
pub const ND_REDIRECT: u8 = 137;
406+
407+
pub const ND_OPT_SOURCE_LINKADDR: u8 = 1;
408+
pub const ND_OPT_TARGET_LINKADDR: u8 = 2;
409+
pub const ND_OPT_PREFIX_INFORMATION: u8 = 3;
410+
pub const ND_OPT_REDIRECTED_HEADER: u8 = 4;
411+
pub const ND_OPT_MTU: u8 = 5;
412+
367413
cfg_if! {
368414
if #[cfg(any(target_os = "nto", target_os = "aix"))] {
369415
pub const FNM_PERIOD: c_int = 1 << 1;

0 commit comments

Comments
 (0)