[Ada] GNAT.Sockets: support ICMP, IGMP and RAW IP protocol levels
authorDmitriy Anisimkov <anisimko@adacore.com>
Thu, 11 Jul 2019 08:02:49 +0000 (08:02 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Thu, 11 Jul 2019 08:02:49 +0000 (08:02 +0000)
2019-07-11  Dmitriy Anisimkov  <anisimko@adacore.com>

gcc/ada/

* libgnat/g-socket.ads (Level_Type): Add enumerators for
IP_Protocol_For_ICMP, IP_Protocol_For_IGMP,
IP_Protocol_For_RAW_Level.
* libgnat/g-socket.adb (Levels): Handle them.
* s-oscons-tmplt.c: Import socket protocols defined in
netinet/in.h.

From-SVN: r273398

gcc/ada/ChangeLog
gcc/ada/libgnat/g-socket.adb
gcc/ada/libgnat/g-socket.ads
gcc/ada/s-oscons-tmplt.c

index 2f8ad77..3b04ce8 100644 (file)
@@ -1,3 +1,12 @@
+2019-07-11  Dmitriy Anisimkov  <anisimko@adacore.com>
+
+       * libgnat/g-socket.ads (Level_Type): Add enumerators for
+       IP_Protocol_For_ICMP, IP_Protocol_For_IGMP,
+       IP_Protocol_For_RAW_Level.
+       * libgnat/g-socket.adb (Levels): Handle them.
+       * s-oscons-tmplt.c: Import socket protocols defined in
+       netinet/in.h.
+
 2019-07-11  Claire Dross  <dross@adacore.com>
 
        * libgnat/a-cfhama.adb, libgnat/a-cfhase.adb (Free): Do not
index 689389f..ceb2cb0 100644 (file)
@@ -73,7 +73,10 @@ package body GNAT.Sockets is
                IP_Protocol_For_IP_Level   => SOSC.IPPROTO_IP,
                IP_Protocol_For_IPv6_Level => SOSC.IPPROTO_IPV6,
                IP_Protocol_For_UDP_Level  => SOSC.IPPROTO_UDP,
-               IP_Protocol_For_TCP_Level  => SOSC.IPPROTO_TCP);
+               IP_Protocol_For_TCP_Level  => SOSC.IPPROTO_TCP,
+               IP_Protocol_For_ICMP_Level => SOSC.IPPROTO_ICMP,
+               IP_Protocol_For_IGMP_Level => SOSC.IPPROTO_IGMP,
+               IP_Protocol_For_RAW_Level  => SOSC.IPPROTO_RAW);
 
    Modes : constant array (Mode_Type) of C.int :=
              (Socket_Stream   => SOSC.SOCK_STREAM,
index 342577a..acd72f1 100644 (file)
@@ -773,7 +773,10 @@ package GNAT.Sockets is
       IP_Protocol_For_IP_Level,
       IP_Protocol_For_IPv6_Level,
       IP_Protocol_For_UDP_Level,
-      IP_Protocol_For_TCP_Level);
+      IP_Protocol_For_TCP_Level,
+      IP_Protocol_For_ICMP_Level,
+      IP_Protocol_For_IGMP_Level,
+      IP_Protocol_For_RAW_Level);
 
    --  There are several options available to manipulate sockets. Each option
    --  has a name and several values available. Most of the time, the value
index 1e883b9..655d68a 100644 (file)
@@ -1292,6 +1292,111 @@ CND(IPPROTO_UDP, "UDP")
 #endif
 CND(IPPROTO_TCP, "TCP")
 
+#ifndef IPPROTO_ICMP
+# define IPPROTO_ICMP -1
+#endif
+CND(IPPROTO_ICMP, "Internet Control Message Protocol")
+
+#ifndef IPPROTO_IGMP
+# define IPPROTO_IGMP -1
+#endif
+CND(IPPROTO_IGMP, "Internet Group Management Protocol")
+
+#ifndef IPPROTO_IPIP
+# define IPPROTO_IPIP -1
+#endif
+CND(IPPROTO_IPIP, "IPIP tunnels (older KA9Q tunnels use 94)")
+
+#ifndef IPPROTO_EGP
+# define IPPROTO_EGP -1
+#endif
+CND(IPPROTO_EGP, "Exterior Gateway Protocol")
+
+#ifndef IPPROTO_PUP
+# define IPPROTO_PUP -1
+#endif
+CND(IPPROTO_PUP, "PUP protocol")
+
+#ifndef IPPROTO_IDP
+# define IPPROTO_IDP -1
+#endif
+CND(IPPROTO_IDP, "XNS IDP protocol")
+
+#ifndef IPPROTO_TP
+# define IPPROTO_TP -1
+#endif
+CND(IPPROTO_TP, "SO Transport Protocol Class 4")
+
+#ifndef IPPROTO_DCCP
+# define IPPROTO_DCCP -1
+#endif
+CND(IPPROTO_DCCP, "Datagram Congestion Control Protocol")
+
+#ifndef IPPROTO_RSVP
+# define IPPROTO_RSVP -1
+#endif
+CND(IPPROTO_RSVP, "Reservation Protocol")
+
+#ifndef IPPROTO_GRE
+# define IPPROTO_GRE -1
+#endif
+CND(IPPROTO_GRE, "General Routing Encapsulation")
+
+#ifndef IPPROTO_ESP
+# define IPPROTO_ESP -1
+#endif
+CND(IPPROTO_ESP, "encapsulating security payload")
+
+#ifndef IPPROTO_AH
+# define IPPROTO_AH -1
+#endif
+CND(IPPROTO_AH, "authentication header")
+
+#ifndef IPPROTO_MTP
+# define IPPROTO_MTP -1
+#endif
+CND(IPPROTO_MTP, "Multicast Transport Protocol")
+
+#ifndef IPPROTO_BEETPH
+# define IPPROTO_BEETPH -1
+#endif
+CND(IPPROTO_BEETPH, "IP option pseudo header for BEET")
+
+#ifndef IPPROTO_ENCAP
+# define IPPROTO_ENCAP -1
+#endif
+CND(IPPROTO_ENCAP, "Encapsulation Header")
+
+#ifndef IPPROTO_PIM
+# define IPPROTO_PIM -1
+#endif
+CND(IPPROTO_PIM, "Protocol Independent Multicast")
+
+#ifndef IPPROTO_COMP
+# define IPPROTO_COMP -1
+#endif
+CND(IPPROTO_COMP, "Compression Header Protocol")
+
+#ifndef IPPROTO_SCTP
+# define IPPROTO_SCTP -1
+#endif
+CND(IPPROTO_SCTP, "Stream Control Transmission Protocol")
+
+#ifndef IPPROTO_UDPLITE
+# define IPPROTO_UDPLITE -1
+#endif
+CND(IPPROTO_UDPLITE, "UDP-Lite protocol")
+
+#ifndef IPPROTO_MPLS
+# define IPPROTO_MPLS -1
+#endif
+CND(IPPROTO_MPLS, "MPLS in IP")
+
+#ifndef IPPROTO_RAW
+# define IPPROTO_RAW -1
+#endif
+CND(IPPROTO_RAW, "Raw IP packets")
+
 /*
 
    -------------------