1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-26 09:46:09 +00:00
freebsd-ports/net/anet/files/patch-src_anet-sockets.adb
John Marino 55e2264671 Add new port net/anet (Ada IPv4 and IPv6 sockets binding library)
The ANet library was created on Linux and the unfortunate result is that
it is highly Linux-specific.  Luckily it has an implementation testsuite,
so patches to make it work on BSD can be reasonably tested.  The current
status is annoted in pkg-message:

=========================================================================
Beware of the IPv6 multicast functions.  Sending does work, but the
default interface effectively is invalid on *BSD.  A specific interface
needs to be provided rather than leaving interface blank (zero).

Multicast receiving may not currently work.  The test for IPv6 multicast
fails.  The test chunk is sent (verified with separate monitoring tool)
but never detected.  Hopefully the cause will be understood and fixed
soon.

AF_NETLINK and AF_PACKET protocols are not supported by *BSD, so the
associated tests have been removed.  Every test other than IPv6 Multicast
passes.  You may want to replace "em0" with this system's interface in
the test suite is to be run (see files/patch-tests_socket__tests.adb).
2014-02-25 14:57:07 +00:00

72 lines
2.2 KiB
Ada

--- src/anet-sockets.adb.orig 2013-12-04 09:55:07.000000000 +0000
+++ src/anet-sockets.adb
@@ -54,7 +54,7 @@ package body Anet.Sockets is
procedure Check_Complete_Send
(Item : Ada.Streams.Stream_Element_Array;
- Result : Interfaces.C.int;
+ Result : Interfaces.C.long;
Error_Msg : String)
is
use Ada.Streams;
@@ -197,7 +197,8 @@ package body Anet.Sockets is
(Socket : Socket_Type;
Item : Ada.Streams.Stream_Element_Array)
is
- Res : C.int;
+ use Interfaces.C;
+ Res : C.long;
begin
Res := Thin.C_Send (S => Socket.Sock_FD,
Buf => Item'Address,
@@ -217,6 +218,49 @@ package body Anet.Sockets is
-------------------------------------------------------------------------
+ procedure Set_Multicast_Interface
+ (Socket : Socket_Type;
+ IPAddr : IPv4_Addr_Type)
+ is
+ Res : C.int;
+ begin
+ Res := Thin.C_Setsockopt
+ (S => Socket.Sock_FD,
+ Level => Constants.Sys.IPPROTO_IP,
+ Optname => Constants.Sys.IP_MULTICAST_IF,
+ Optval => IPAddr'Address,
+ Optlen => 4);
+
+ if Res = C_Failure then
+ raise Socket_Error with "Unable set IPv4 Multicast IF option "
+ & " on '" & To_String (IPAddr) & "': " & Get_Errno_String;
+ end if;
+ end Set_Multicast_Interface;
+
+ -------------------------------------------------------------------------
+
+ procedure Set_Multicast_Interface
+ (Socket : Socket_Type;
+ Idx : Natural)
+ is
+ Res : C.int;
+ IF_Index : constant C.unsigned := C.unsigned (Idx);
+ begin
+ Res := Thin.C_Setsockopt
+ (S => Socket.Sock_FD,
+ Level => Constants.IPPROTO_IPV6,
+ Optname => Constants.IPV6_MULTICAST_IF,
+ Optval => IF_Index'Address,
+ Optlen => 4);
+
+ if Res = C_Failure then
+ raise Socket_Error with "Unable set IPv6 Multicast IF option"
+ & " on interface'" & Idx'Img & "': " & Get_Errno_String;
+ end if;
+ end Set_Multicast_Interface;
+
+ -------------------------------------------------------------------------
+
procedure Set_Socket_Option
(Socket : Socket_Type;
Option : Option_Name_Bool;