wg-multicast - Re: example of proper use of igmp v3 SSM setsockopt on Linux 2.6 kernel?
Subject: All things related to multicast
List archive
- From: Hoerdt Mickael <>
- To: Alan Crosswell <>
- Cc: wg-multicast <>
- Subject: Re: example of proper use of igmp v3 SSM setsockopt on Linux 2.6 kernel?
- Date: Wed, 17 Nov 2004 10:15:20 +0100
Hi Alan,
You shouln't bind your socket before joining the SSM channel I think, try to bind it after or better,
try to bind it outside of the openSSM function : joining an SSM channel is an IP operation, which
is not related to socket binding (ususally related to transport operation).
Also, do not forget that the group_source_req structure is the following :
struct group_source_req
{
__u32 gsr_interface; /* interface index */
struct sockaddr_storage gsr_group; /* group address */
struct sockaddr_storage gsr_source; /* source address */
};
Which means that gsr_group and gsr_source are address family independant (IPv4/IPv6). Usually
the best way to use it is to have a sockaddr_in * and a sockaddr_in6 *, both pointing to the
same sockaddr_storage structure and to fill the required fields : sin4/6_family and sin4/6_add
and sin4/6_len (not under linux). gsr_interface is an integer corresponding to the whished interface
index.
<marketing>
For an excellent documentation (including multicast) see Richard Stevens TCP/IP Networking book,
also for a quick SSM test prog you can take a look at Source Specific Multicast Source Discovery Protocol implementation which offers an open source SSM test prog called test_msf (test multicast
socket filter) in src/examples, this program rely on the libmcast library. I used Richard stevens
book to write this library =>http://clarinet.u-strasbg.fr/~hoerdt/libssmsdp/
</marketing>
Cheers,
Hoerdt Mickael
Alan Crosswell a écrit :
Does anyone have a working example of doing an (S,G) join on Linux 2.6? I'm trying this and getting the always-helpful "Invalid argument" error. Before I add printf's to the kernel I thought I'd ask.... Is there a better list to ask this on?
The following code snippet is derived from rtpqual.c:
int openSSM(source, name, port)
char *source;
char *name;
int port;
{
struct group_source_req greq;
struct sockaddr_in sin;
struct hostent *hp;
int fd, one=1;
bzero(&greq, sizeof(struct group_source_req));
bzero(&sin, sizeof(struct sockaddr_in));
greq.gsr_interface = 1; /* default intf XXXX */
if (isdigit(*name)) {
sin.sin_addr.s_addr = inet_addr(name);
}
else if (hp = gethostbyname(name)) {
bcopy(hp->h_addr, (char *)&sin.sin_addr.s_addr, hp->h_length);
}
else {
printf("I Don't understand session name %s\n",name);
exit(1);
}
sin.sin_family = AF_INET;
sin.sin_port = port;
if (!IN_MULTICAST(ntohl(sin.sin_addr.s_addr))) {
printf("%s is not a multicast session\n", name);
exit(1);
}
greq.gsr_group.sin_addr.s_addr = sin.sin_addr.s_addr;
// greq.gsr_interface.s_addr = INADDR_ANY;
if (isdigit(*source)) {
greq.gsr_source.sin_addr.s_addr = inet_addr(source);
}
else if (hp = gethostbyname(source)) {
bcopy(hp->h_addr, (char *)&greq.gsr_source.sin_addr.s_addr, hp->h_length);
}
else {
printf("I Don't understand source name %s\n",source);
exit(1);
}
NOERROR(fd = socket(AF_INET, SOCK_DGRAM, 0), "socket");
NOERROR(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)),
"SO_REUSEADDR");
if (bind(fd, &sin, sizeof(sin)) == -1) {
perror("Warning - Using INADDR_ANY because");
sin.sin_addr.s_addr = INADDR_ANY;
NOERROR(bind(fd, &sin, sizeof(sin)), "bind");
}
NOERROR(setsockopt(fd, IPPROTO_IP, MCAST_JOIN_SOURCE_GROUP, &greq, sizeof(greq)),
"MCAST_JOIN_SOURCE_GROUP");
return(fd);
}
- example of proper use of igmp v3 SSM setsockopt on Linux 2.6 kernel?, Alan Crosswell, 11/16/2004
- Re: example of proper use of igmp v3 SSM setsockopt on Linux 2.6 kernel?, Stig Venaas, 11/16/2004
- Re: example of proper use of igmp v3 SSM setsockopt on Linux 2.6 kernel?, Alan Crosswell, 11/17/2004
- Re: example of proper use of igmp v3 SSM setsockopt on Linux 2.6 kernel?, Hoerdt Mickael, 11/17/2004
- Re: example of proper use of igmp v3 SSM setsockopt on Linux 2.6 kernel?, Stig Venaas, 11/17/2004
- Re: example of proper use of igmp v3 SSM setsockopt on Linux 2.6 kernel?, Hoerdt Mickael, 11/17/2004
- Re: example of proper use of igmp v3 SSM setsockopt on Linux 2.6 kernel?, Stig Venaas, 11/17/2004
- Re: example of proper use of igmp v3 SSM setsockopt on Linux 2.6 kernel?, Stig Venaas, 11/16/2004
Archive powered by MHonArc 2.6.16.