PATCH - Allow explicit interface selection for multicast socket
Guillaume Foliard <[email protected]> Sat, 27 Jan 2007 22:35:27 +0100
| Newsgroups | gmane.comp.lang.ada.sockets |
|---|---|
| Organization | _ |
| Message-ID | <[email protected]> |
--Boundary-00=_fW8uF+Va48iH+mj
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hello,
Here is a patch which modifies the multicast API so the caller can explicitly
ask for the interface to use when opening a multicast socket.
Reviews and comments are welcome.
Sam is it possible for you to consider this patch and the following one
(entitled "Replace inet_addr with inet_aton") to be part of a new release of
AdaSockets ?
Guillaume
--Boundary-00=_fW8uF+Va48iH+mj
Content-Type: text/x-diff; charset="us-ascii";
name="adasockets-1.8.4.7-multicast.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="adasockets-1.8.4.7-multicast.diff"
diff -ru adasockets-1.8.4.7.orig/src/sockets-multicast.adb adasockets-1.8.4.7p1/src/sockets-multicast.adb
--- adasockets-1.8.4.7.orig/src/sockets-multicast.adb 2004-05-16 20:18:36.000000000 +0200
+++ adasockets-1.8.4.7p1/src/sockets-multicast.adb 2005-02-07 20:21:33.000000000 +0100
@@ -60,7 +60,8 @@
Port : Positive;
Local_Port : Natural;
TTL : Positive := 16;
- Self_Loop : Boolean := True)
+ Self_Loop : Boolean := True;
+ Local_If : String := "0.0.0.0")
return Multicast_Socket_FD;
-----------------------------
@@ -72,7 +73,8 @@
Port : Positive;
Local_Port : Natural;
TTL : Positive := 16;
- Self_Loop : Boolean := True)
+ Self_Loop : Boolean := True;
+ Local_If : String := "0.0.0.0")
return Multicast_Socket_FD
is
Result : Multicast_Socket_FD;
@@ -91,6 +93,7 @@
end if;
Bind (Result, Local_Port);
Mreq.Imr_Multiaddr := To_In_Addr (Address_Of (Group));
+ Mreq.Imr_Interface := To_In_Addr (Address_Of (Local_If));
Setsockopt_Add_Membership (Result, Mreq);
Setsockopt (Result, IPPROTO_IP, IP_MULTICAST_TTL, TTL);
Setsockopt (Result, IPPROTO_IP, IP_MULTICAST_LOOP, C_Self_Loop);
@@ -108,7 +111,8 @@
(Group : String;
Port : Positive;
TTL : Positive := 16;
- Self_Loop : Boolean := True)
+ Self_Loop : Boolean := True;
+ Local_If : String := "0.0.0.0")
return Multicast_Socket_FD
is
begin
@@ -117,7 +121,8 @@
Port => Port,
Local_Port => Port,
TTL => TTL,
- Self_Loop => Self_Loop);
+ Self_Loop => Self_Loop,
+ Local_If => Local_If);
end Create_Multicast_Socket;
-----------------------------
@@ -128,7 +133,8 @@
(Group : String;
Port : Positive;
Local_Port : Natural;
- TTL : Positive := 16)
+ TTL : Positive := 16;
+ Local_If : String := "0.0.0.0")
return Multicast_Socket_FD
is
begin
@@ -137,7 +143,8 @@
Port => Port,
Local_Port => Local_Port,
TTL => TTL,
- Self_Loop => False);
+ Self_Loop => False,
+ Local_If => Local_If);
end Create_Multicast_Socket;
----------
diff -ru adasockets-1.8.4.7.orig/src/sockets-multicast.ads adasockets-1.8.4.7p1/src/sockets-multicast.ads
--- adasockets-1.8.4.7.orig/src/sockets-multicast.ads 2004-05-16 20:18:36.000000000 +0200
+++ adasockets-1.8.4.7p1/src/sockets-multicast.ads 2005-02-07 20:21:33.000000000 +0100
@@ -52,7 +52,8 @@
(Group : String;
Port : Positive;
TTL : Positive := 16;
- Self_Loop : Boolean := True)
+ Self_Loop : Boolean := True;
+ Local_If : String := "0.0.0.0")
return Multicast_Socket_FD;
-- Create a multicast socket
@@ -60,7 +61,8 @@
(Group : String;
Port : Positive;
Local_Port : Natural;
- TTL : Positive := 16)
+ TTL : Positive := 16;
+ Local_If : String := "0.0.0.0")
return Multicast_Socket_FD;
-- Create a multicast socket that can only send data and is bound
-- to the local port Local_Port. Use 0 if you do not care about
--Boundary-00=_fW8uF+Va48iH+mj
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
AdaSockets mailing list
[email protected]
http://lists.rfc1149.net/mailman/listinfo/adasockets
--Boundary-00=_fW8uF+Va48iH+mj--