Skip to content

Commit d197e21

Browse files
committed
Auto merge of #543 - berkowski:socket_constants, r=alexcrichton
Adds many socket related constants Started off adding a few constants to help cleaning up some `nix-rust/nix` issues. Went a little.. further. Adds lots of socket-related constants (`PF_*`, `MSG_*`, `AF_*`, `SO_*`, `SOL_*`, etc.) to linux/bsd flavors. Added constants to `bsd/frebsdlike/dragonfly` for completeness, though they aren't covered by CI. Did not touch `notbsd/linux/s390x.rs`
2 parents 612a586 + 985ea40 commit d197e21

File tree

21 files changed

+831
-62
lines changed

21 files changed

+831
-62
lines changed

src/unix/bsd/apple/mod.rs

Lines changed: 116 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -846,12 +846,100 @@ pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8;
846846
pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10;
847847

848848
pub const AF_UNSPEC: ::c_int = 0;
849-
pub const AF_UNIX: ::c_int = 1;
849+
pub const AF_LOCAL: ::c_int = 1;
850+
pub const AF_UNIX: ::c_int = AF_LOCAL;
850851
pub const AF_INET: ::c_int = 2;
852+
pub const AF_IMPLINK: ::c_int = 3;
853+
pub const AF_PUP: ::c_int = 4;
854+
pub const AF_CHAOS: ::c_int = 5;
855+
pub const AF_NS: ::c_int = 6;
856+
pub const AF_ISO: ::c_int = 7;
857+
pub const AF_OSI: ::c_int = AF_ISO;
858+
pub const AF_ECMA: ::c_int = 8;
859+
pub const AF_DATAKIT: ::c_int = 9;
860+
pub const AF_CCITT: ::c_int = 10;
861+
pub const AF_SNA: ::c_int = 11;
862+
pub const AF_DECnet: ::c_int = 12;
863+
pub const AF_DLI: ::c_int = 13;
864+
pub const AF_LAT: ::c_int = 14;
865+
pub const AF_HYLINK: ::c_int = 15;
866+
pub const AF_APPLETALK: ::c_int = 16;
867+
pub const AF_ROUTE: ::c_int = 17;
868+
pub const AF_LINK: ::c_int = 18;
869+
pub const pseudo_AF_XTP: ::c_int = 19;
870+
pub const AF_COIP: ::c_int = 20;
871+
pub const AF_CNT: ::c_int = 21;
872+
pub const pseudo_AF_RTIP: ::c_int = 22;
873+
pub const AF_IPX: ::c_int = 23;
874+
pub const AF_SIP: ::c_int = 24;
875+
pub const pseudo_AF_PIP: ::c_int = 25;
876+
pub const AF_ISDN: ::c_int = 28;
877+
pub const AF_E164: ::c_int = AF_ISDN;
878+
pub const pseudo_AF_KEY: ::c_int = 29;
851879
pub const AF_INET6: ::c_int = 30;
880+
pub const AF_NATM: ::c_int = 31;
881+
pub const AF_SYSTEM: ::c_int = 32;
882+
pub const AF_NETBIOS: ::c_int = 33;
883+
pub const AF_PPP: ::c_int = 34;
884+
pub const pseudo_AF_HDRCMPLT: ::c_int = 35;
885+
#[doc(hidden)]
886+
pub const AF_MAX: ::c_int = 40;
887+
888+
pub const PF_UNSPEC: ::c_int = AF_UNSPEC;
889+
pub const PF_LOCAL: ::c_int = AF_LOCAL;
890+
pub const PF_UNIX: ::c_int = PF_LOCAL;
891+
pub const PF_INET: ::c_int = AF_INET;
892+
pub const PF_IMPLINK: ::c_int = AF_IMPLINK;
893+
pub const PF_PUP: ::c_int = AF_PUP;
894+
pub const PF_CHAOS: ::c_int = AF_CHAOS;
895+
pub const PF_NS: ::c_int = AF_NS;
896+
pub const PF_ISO: ::c_int = AF_ISO;
897+
pub const PF_OSI: ::c_int = AF_ISO;
898+
pub const PF_ECMA: ::c_int = AF_ECMA;
899+
pub const PF_DATAKIT: ::c_int = AF_DATAKIT;
900+
pub const PF_CCITT: ::c_int = AF_CCITT;
901+
pub const PF_SNA: ::c_int = AF_SNA;
902+
pub const PF_DECnet: ::c_int = AF_DECnet;
903+
pub const PF_DLI: ::c_int = AF_DLI;
904+
pub const PF_LAT: ::c_int = AF_LAT;
905+
pub const PF_HYLINK: ::c_int = AF_HYLINK;
906+
pub const PF_APPLETALK: ::c_int = AF_APPLETALK;
907+
pub const PF_ROUTE: ::c_int = AF_ROUTE;
908+
pub const PF_LINK: ::c_int = AF_LINK;
909+
pub const PF_XTP: ::c_int = pseudo_AF_XTP;
910+
pub const PF_COIP: ::c_int = AF_COIP;
911+
pub const PF_CNT: ::c_int = AF_CNT;
912+
pub const PF_SIP: ::c_int = AF_SIP;
913+
pub const PF_IPX: ::c_int = AF_IPX;
914+
pub const PF_RTIP: ::c_int = pseudo_AF_RTIP;
915+
pub const PF_PIP: ::c_int = pseudo_AF_PIP;
916+
pub const PF_ISDN: ::c_int = AF_ISDN;
917+
pub const PF_KEY: ::c_int = pseudo_AF_KEY;
918+
pub const PF_INET6: ::c_int = AF_INET6;
919+
pub const PF_NATM: ::c_int = AF_NATM;
920+
pub const PF_SYSTEM: ::c_int = AF_SYSTEM;
921+
pub const PF_NETBIOS: ::c_int = AF_NETBIOS;
922+
pub const PF_PPP: ::c_int = AF_PPP;
923+
#[doc(hidden)]
924+
pub const PF_MAX: ::c_int = AF_MAX;
925+
926+
#[doc(hidden)]
927+
pub const NET_MAXID: ::c_int = AF_MAX;
928+
929+
pub const NET_RT_DUMP: ::c_int = 1;
930+
pub const NET_RT_FLAGS: ::c_int = 2;
931+
pub const NET_RT_IFLIST: ::c_int = 3;
932+
#[doc(hidden)]
933+
pub const NET_RT_MAXID: ::c_int = 10;
934+
935+
pub const SOMAXCONN: ::c_int = 128;
936+
937+
pub const SOCK_MAXADDRLEN: ::c_int = 255;
938+
852939
pub const SOCK_STREAM: ::c_int = 1;
853940
pub const SOCK_DGRAM: ::c_int = 2;
854941
pub const SOCK_RAW: ::c_int = 3;
942+
pub const SOCK_RDM: ::c_int = 4;
855943
pub const SOCK_SEQPACKET: ::c_int = 5;
856944
pub const IPPROTO_ICMP: ::c_int = 1;
857945
pub const IPPROTO_ICMPV6: ::c_int = 58;
@@ -881,6 +969,10 @@ pub const SO_USELOOPBACK: ::c_int = 0x0040;
881969
pub const SO_LINGER: ::c_int = 0x0080;
882970
pub const SO_OOBINLINE: ::c_int = 0x0100;
883971
pub const SO_REUSEPORT: ::c_int = 0x0200;
972+
pub const SO_TIMESTAMP: ::c_int = 0x0400;
973+
pub const SO_DONTTRUNC: ::c_int = 0x2000;
974+
pub const SO_WANTMORE: ::c_int = 0x4000;
975+
pub const SO_WANTOOBFLAG: ::c_int = 0x8000;
884976
pub const SO_SNDBUF: ::c_int = 0x1001;
885977
pub const SO_RCVBUF: ::c_int = 0x1002;
886978
pub const SO_SNDLOWAT: ::c_int = 0x1003;
@@ -889,8 +981,31 @@ pub const SO_SNDTIMEO: ::c_int = 0x1005;
889981
pub const SO_RCVTIMEO: ::c_int = 0x1006;
890982
pub const SO_ERROR: ::c_int = 0x1007;
891983
pub const SO_TYPE: ::c_int = 0x1008;
984+
pub const SO_NREAD: ::c_int = 0x1020;
985+
pub const SO_NKE: ::c_int = 0x1021;
986+
pub const SO_NOSIGPIPE: ::c_int = 0x1022;
987+
pub const SO_NOADDRERR: ::c_int = 0x1023;
988+
pub const SO_NWRITE: ::c_int = 0x1024;
892989

990+
pub const MSG_OOB: ::c_int = 0x1;
893991
pub const MSG_PEEK: ::c_int = 0x2;
992+
pub const MSG_DONTROUTE: ::c_int = 0x4;
993+
pub const MSG_EOR: ::c_int = 0x8;
994+
pub const MSG_TRUNC: ::c_int = 0x10;
995+
pub const MSG_CTRUNC: ::c_int = 0x20;
996+
pub const MSG_WAITALL: ::c_int = 0x40;
997+
pub const MSG_DONTWAIT: ::c_int = 0x80;
998+
pub const MSG_EOF: ::c_int = 0x100;
999+
pub const MSG_FLUSH: ::c_int = 0x400;
1000+
pub const MSG_HOLD: ::c_int = 0x800;
1001+
pub const MSG_SEND: ::c_int = 0x1000;
1002+
pub const MSG_HAVEMORE: ::c_int = 0x2000;
1003+
pub const MSG_RCVMORE: ::c_int = 0x4000;
1004+
// pub const MSG_COMPAT: ::c_int = 0x8000;
1005+
1006+
pub const SCM_RIGHTS: ::c_int = 0x01;
1007+
pub const SCM_TIMESTAMP: ::c_int = 0x02;
1008+
pub const SCM_CREDS: ::c_int = 0x03;
8941009

8951010
pub const IFF_LOOPBACK: ::c_int = 0x8;
8961011

@@ -917,15 +1032,6 @@ pub const MAP_JIT: ::c_int = 0x0800;
9171032

9181033
pub const IPPROTO_RAW: ::c_int = 255;
9191034

920-
pub const SO_NREAD: ::c_int = 0x1020;
921-
pub const SO_NKE: ::c_int = 0x1021;
922-
pub const SO_NOSIGPIPE: ::c_int = 0x1022;
923-
pub const SO_NOADDRERR: ::c_int = 0x1023;
924-
pub const SO_NWRITE: ::c_int = 0x1024;
925-
pub const SO_DONTTRUNC: ::c_int = 0x2000;
926-
pub const SO_WANTMORE: ::c_int = 0x4000;
927-
pub const SO_WANTOOBFLAG: ::c_int = 0x8000;
928-
9291035
pub const _SC_ARG_MAX: ::c_int = 1;
9301036
pub const _SC_CHILD_MAX: ::c_int = 2;
9311037
pub const _SC_CLK_TCK: ::c_int = 3;

src/unix/bsd/freebsdlike/dragonfly/mod.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,34 @@ pub const NOTE_TRACK: ::uint32_t = 0x00000001;
344344
pub const NOTE_TRACKERR: ::uint32_t = 0x00000002;
345345
pub const NOTE_CHILD: ::uint32_t = 0x00000004;
346346

347-
pub const MSG_PEEK: ::c_int = 0x2;
348-
pub const MSG_NOSIGNAL: ::c_int = 0x400;
347+
pub const SO_SNDSPACE: ::c_int = 0x100a;
348+
pub const SO_CPUHINT: ::c_int = 0x1030;
349+
350+
pub const AF_BLUETOOTH: ::c_int = 33;
351+
pub const AF_MPLS: ::c_int = 34;
352+
pub const AF_IEEE80211: ::c_int = 35;
353+
pub const AF_MAX: ::c_int = 36;
354+
355+
pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
356+
pub const PF_MAX: ::c_int = AF_MAX;
357+
358+
pub const NET_RT_DUMP: ::c_int = 1;
359+
pub const NET_RT_FLAGS: ::c_int = 2;
360+
pub const NET_RT_IFLIST: ::c_int = 3;
361+
pub const NET_RT_MAXID: ::c_int = 4;
362+
363+
pub const SOMAXOPT_SIZE: ::c_int = 65536;
364+
365+
#[doc(hidden)]
366+
pub const NET_MAXID: ::c_int = AF_MAX;
367+
368+
pub const MSG_UNUSED09: ::c_int = 0x00000200;
369+
pub const MSG_NOSIGNAL: ::c_int = 0x00000400;
370+
pub const MSG_SYNC: ::c_int = 0x00000800;
371+
pub const MSG_CMSG_CLOEXEC: ::c_int = 0x00001000;
372+
pub const MSG_FBLOCKING: ::c_int = 0x00010000;
373+
pub const MSG_FNONBLOCKING: ::c_int = 0x00020000;
374+
pub const MSG_FMASK: ::c_int = 0xFFFF0000;
349375

350376
pub const EMPTY: ::c_short = 0;
351377
pub const RUN_LVL: ::c_short = 1;

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,53 @@ pub const JAIL_SYS_DISABLE: ::c_int = 0;
344344
pub const JAIL_SYS_NEW: ::c_int = 1;
345345
pub const JAIL_SYS_INHERIT: ::c_int = 2;
346346

347+
pub const SO_BINTIME: ::c_int = 0x2000;
348+
pub const SO_NO_OFFLOAD: ::c_int = 0x4000;
349+
pub const SO_NO_DDP: ::c_int = 0x8000;
350+
pub const SO_LABEL: ::c_int = 0x1009;
351+
pub const SO_PEERLABEL: ::c_int = 0x1010;
352+
pub const SO_LISTENQLIMIT: ::c_int = 0x1011;
353+
pub const SO_LISTENQLEN: ::c_int = 0x1012;
354+
pub const SO_LISTENINCQLEN: ::c_int = 0x1013;
355+
pub const SO_SETFIB: ::c_int = 0x1014;
356+
pub const SO_USER_COOKIE: ::c_int = 0x1015;
357+
pub const SO_PROTOCOL: ::c_int = 0x1016;
358+
pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL;
359+
pub const SO_VENDOR: ::c_int = 0x80000000;
360+
361+
pub const AF_SLOW: ::c_int = 33;
362+
pub const AF_SCLUSTER: ::c_int = 34;
363+
pub const AF_ARP: ::c_int = 35;
364+
pub const AF_BLUETOOTH: ::c_int = 36;
365+
pub const AF_IEEE80211: ::c_int = 37;
366+
pub const AF_INET_SDP: ::c_int = 40;
367+
pub const AF_INET6_SDP: ::c_int = 42;
368+
#[doc(hidden)]
369+
pub const AF_MAX: ::c_int = 42;
370+
371+
pub const PF_SLOW: ::c_int = AF_SLOW;
372+
pub const PF_SCLUSTER: ::c_int = AF_SCLUSTER;
373+
pub const PF_ARP: ::c_int = AF_ARP;
374+
pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
375+
pub const PF_IEEE80211: ::c_int = AF_IEEE80211;
376+
pub const PF_INET_SDP: ::c_int = AF_INET_SDP;
377+
pub const PF_INET6_SDP: ::c_int = AF_INET6_SDP;
378+
#[doc(hidden)]
379+
pub const PF_MAX: ::c_int = AF_MAX;
380+
381+
pub const NET_RT_DUMP: ::c_int = 1;
382+
pub const NET_RT_FLAGS: ::c_int = 2;
383+
pub const NET_RT_IFLIST: ::c_int = 3;
384+
pub const NET_RT_IFMALIST: ::c_int = 4;
385+
pub const NET_RT_IFLISTL: ::c_int = 5;
386+
347387
// The *_MAXID constants never should've been used outside of the
348388
// FreeBSD base system. And with the exception of CTL_P1003_1B_MAXID,
349389
// they were all removed in svn r262489. They remain here for backwards
350390
// compatibility only, and are scheduled to be removed in libc 1.0.0.
351391
#[doc(hidden)]
392+
pub const NET_MAXID: ::c_int = AF_MAX;
393+
#[doc(hidden)]
352394
pub const CTL_MAXID: ::c_int = 10;
353395
#[doc(hidden)]
354396
pub const KERN_MAXID: ::c_int = 38;
@@ -359,7 +401,10 @@ pub const USER_MAXID: ::c_int = 21;
359401
#[doc(hidden)]
360402
pub const CTL_P1003_1B_MAXID: ::c_int = 26;
361403

362-
pub const MSG_PEEK: ::c_int = 0x2;
404+
pub const MSG_NOTIFICATION: ::c_int = 0x00002000;
405+
pub const MSG_NBIO: ::c_int = 0x00004000;
406+
pub const MSG_COMPAT: ::c_int = 0x00008000;
407+
pub const MSG_CMSG_CLOEXEC: ::c_int = 0x00040000;
363408
pub const MSG_NOSIGNAL: ::c_int = 0x20000;
364409

365410
pub const EMPTY: ::c_short = 0;

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,13 +540,98 @@ pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8;
540540
pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10;
541541
pub const MINCORE_SUPER: ::c_int = 0x20;
542542

543+
pub const AF_UNSPEC: ::c_int = 0;
544+
pub const AF_LOCAL: ::c_int = 1;
545+
pub const AF_UNIX: ::c_int = AF_LOCAL;
543546
pub const AF_INET: ::c_int = 2;
547+
pub const AF_IMPLINK: ::c_int = 3;
548+
pub const AF_PUP: ::c_int = 4;
549+
pub const AF_CHAOS: ::c_int = 5;
550+
pub const AF_NETBIOS: ::c_int = 6;
551+
pub const AF_ISO: ::c_int = 7;
552+
pub const AF_OSI: ::c_int = AF_ISO;
553+
pub const AF_ECMA: ::c_int = 8;
554+
pub const AF_DATAKIT: ::c_int = 9;
555+
pub const AF_CCITT: ::c_int = 10;
556+
pub const AF_SNA: ::c_int = 11;
557+
pub const AF_DECnet: ::c_int = 12;
558+
pub const AF_DLI: ::c_int = 13;
559+
pub const AF_LAT: ::c_int = 14;
560+
pub const AF_HYLINK: ::c_int = 15;
561+
pub const AF_APPLETALK: ::c_int = 16;
562+
pub const AF_ROUTE: ::c_int = 17;
563+
pub const AF_LINK: ::c_int = 18;
564+
pub const pseudo_AF_XTP: ::c_int = 19;
565+
pub const AF_COIP: ::c_int = 20;
566+
pub const AF_CNT: ::c_int = 21;
567+
pub const pseudo_AF_RTIP: ::c_int = 22;
568+
pub const AF_IPX: ::c_int = 23;
569+
pub const AF_SIP: ::c_int = 24;
570+
pub const pseudo_AF_PIP: ::c_int = 25;
571+
pub const AF_ISDN: ::c_int = 26;
572+
pub const AF_E164: ::c_int = AF_ISDN;
573+
pub const pseudo_AF_KEY: ::c_int = 27;
544574
pub const AF_INET6: ::c_int = 28;
545-
pub const AF_UNIX: ::c_int = 1;
575+
pub const AF_NATM: ::c_int = 29;
576+
pub const AF_ATM: ::c_int = 30;
577+
pub const pseudo_AF_HDRCMPLT: ::c_int = 31;
578+
pub const AF_NETGRAPH: ::c_int = 32;
579+
580+
pub const PF_UNSPEC: ::c_int = AF_UNSPEC;
581+
pub const PF_LOCAL: ::c_int = AF_LOCAL;
582+
pub const PF_UNIX: ::c_int = PF_LOCAL;
583+
pub const PF_INET: ::c_int = AF_INET;
584+
pub const PF_IMPLINK: ::c_int = AF_IMPLINK;
585+
pub const PF_PUP: ::c_int = AF_PUP;
586+
pub const PF_CHAOS: ::c_int = AF_CHAOS;
587+
pub const PF_NETBIOS: ::c_int = AF_NETBIOS;
588+
pub const PF_ISO: ::c_int = AF_ISO;
589+
pub const PF_OSI: ::c_int = AF_ISO;
590+
pub const PF_ECMA: ::c_int = AF_ECMA;
591+
pub const PF_DATAKIT: ::c_int = AF_DATAKIT;
592+
pub const PF_CCITT: ::c_int = AF_CCITT;
593+
pub const PF_SNA: ::c_int = AF_SNA;
594+
pub const PF_DECnet: ::c_int = AF_DECnet;
595+
pub const PF_DLI: ::c_int = AF_DLI;
596+
pub const PF_LAT: ::c_int = AF_LAT;
597+
pub const PF_HYLINK: ::c_int = AF_HYLINK;
598+
pub const PF_APPLETALK: ::c_int = AF_APPLETALK;
599+
pub const PF_ROUTE: ::c_int = AF_ROUTE;
600+
pub const PF_LINK: ::c_int = AF_LINK;
601+
pub const PF_XTP: ::c_int = pseudo_AF_XTP;
602+
pub const PF_COIP: ::c_int = AF_COIP;
603+
pub const PF_CNT: ::c_int = AF_CNT;
604+
pub const PF_SIP: ::c_int = AF_SIP;
605+
pub const PF_IPX: ::c_int = AF_IPX;
606+
pub const PF_RTIP: ::c_int = pseudo_AF_RTIP;
607+
pub const PF_PIP: ::c_int = pseudo_AF_PIP;
608+
pub const PF_ISDN: ::c_int = AF_ISDN;
609+
pub const PF_KEY: ::c_int = pseudo_AF_KEY;
610+
pub const PF_INET6: ::c_int = AF_INET6;
611+
pub const PF_NATM: ::c_int = AF_NATM;
612+
pub const PF_ATM: ::c_int = AF_ATM;
613+
pub const PF_NETGRAPH: ::c_int = AF_NETGRAPH;
614+
615+
pub const SOMAXCONN: ::c_int = 128;
616+
617+
pub const MSG_OOB: ::c_int = 0x00000001;
618+
pub const MSG_PEEK: ::c_int = 0x00000002;
619+
pub const MSG_DONTROUTE: ::c_int = 0x00000004;
620+
pub const MSG_EOR: ::c_int = 0x00000008;
621+
pub const MSG_TRUNC: ::c_int = 0x00000010;
622+
pub const MSG_CTRUNC: ::c_int = 0x00000020;
623+
pub const MSG_WAITALL: ::c_int = 0x00000040;
624+
pub const MSG_DONTWAIT: ::c_int = 0x00000080;
625+
pub const MSG_EOF: ::c_int = 0x00000100;
626+
546627
pub const SOCK_STREAM: ::c_int = 1;
547628
pub const SOCK_DGRAM: ::c_int = 2;
548629
pub const SOCK_RAW: ::c_int = 3;
630+
pub const SOCK_RDM: ::c_int = 4;
549631
pub const SOCK_SEQPACKET: ::c_int = 5;
632+
pub const SOCK_CLOEXEC: ::c_int = 0x10000000;
633+
pub const SOCK_NONBLOCK: ::c_int = 0x20000000;
634+
pub const SOCK_MAXADDRLEN: ::c_int = 255;
550635
pub const IPPROTO_ICMP: ::c_int = 1;
551636
pub const IPPROTO_ICMPV6: ::c_int = 58;
552637
pub const IPPROTO_TCP: ::c_int = 6;
@@ -574,6 +659,9 @@ pub const SO_USELOOPBACK: ::c_int = 0x0040;
574659
pub const SO_LINGER: ::c_int = 0x0080;
575660
pub const SO_OOBINLINE: ::c_int = 0x0100;
576661
pub const SO_REUSEPORT: ::c_int = 0x0200;
662+
pub const SO_TIMESTAMP: ::c_int = 0x0400;
663+
pub const SO_NOSIGPIPE: ::c_int = 0x0800;
664+
pub const SO_ACCEPTFILTER: ::c_int = 0x1000;
577665
pub const SO_SNDBUF: ::c_int = 0x1001;
578666
pub const SO_RCVBUF: ::c_int = 0x1002;
579667
pub const SO_SNDLOWAT: ::c_int = 0x1003;

0 commit comments

Comments
 (0)