From 810097a72d1767627d2439bb94627b443f41bf7f Mon Sep 17 00:00:00 2001 From: Dmitriy Anisimkov Date: Thu, 11 Jul 2019 08:02:49 +0000 Subject: [PATCH] [Ada] GNAT.Sockets: support ICMP, IGMP and RAW IP protocol levels 2019-07-11 Dmitriy Anisimkov 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 | 9 +++ gcc/ada/libgnat/g-socket.adb | 5 +- gcc/ada/libgnat/g-socket.ads | 5 +- gcc/ada/s-oscons-tmplt.c | 105 +++++++++++++++++++++++++++++++++++ 4 files changed, 122 insertions(+), 2 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 2f8ad77e540..3b04ce8463f 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,12 @@ +2019-07-11 Dmitriy Anisimkov + + * 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 * libgnat/a-cfhama.adb, libgnat/a-cfhase.adb (Free): Do not diff --git a/gcc/ada/libgnat/g-socket.adb b/gcc/ada/libgnat/g-socket.adb index 689389f9cc8..ceb2cb03c6a 100644 --- a/gcc/ada/libgnat/g-socket.adb +++ b/gcc/ada/libgnat/g-socket.adb @@ -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, diff --git a/gcc/ada/libgnat/g-socket.ads b/gcc/ada/libgnat/g-socket.ads index 342577a4ae3..acd72f1e650 100644 --- a/gcc/ada/libgnat/g-socket.ads +++ b/gcc/ada/libgnat/g-socket.ads @@ -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 diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c index 1e883b9f69c..655d68a79f2 100644 --- a/gcc/ada/s-oscons-tmplt.c +++ b/gcc/ada/s-oscons-tmplt.c @@ -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") + /* ------------------- -- 2.30.2