Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 214811 Details for
Bug 239563
can't disable multicast
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
Test program for multicast
bz239563-multicast.c (text/plain), 4.60 KB, created by
Jay Fenlason
on 2007-10-03 16:40:30 UTC
(
hide
)
Description:
Test program for multicast
Filename:
MIME Type:
Creator:
Jay Fenlason
Created:
2007-10-03 16:40:30 UTC
Size:
4.60 KB
patch
obsolete
>/* Test for bz#239563: can't disable multicast */ >/* > >To run this test you need two machines on the same subnet > >To run the test: > >1: On the first machine start a copy of this program with >./bz239563-multicast recvfrom {the first machine's ip address on {iface}} \ > {multicast number (224.1.1.1 for example)} {port number (like 5555)} ... > >2: On the second machine, start a copy of this program with >./bz239563-multicast sendto {the second machine's ip address on {iface}} \ > {multicast number (224.1.1.1 for example)} {port number (like 5555)} ... > >3: confirm that the first machine received the datagram from the second. > >4: On the first machine disable multicast support on the network adapter >with "ifconfig {iface} -multicast" or "ip link set {iface} multicast off" > >5: On the first machine start a copy of this program with >./bz239563-multicast recvfrom {the first machine's ip address on {iface}} \ > {multicast number (224.1.1.1 for example)} {port number (like 5555)} ... > >6: confirm that the multicast join attempt fails. > >7: on the second machine, start a copy of this program with >./bz239563-multicast recvfrom {the second machine's ip address on {iface}} \ > {multicast number (224.1.1.1 for example)} {port number (like 5555)} ... > >8: on the first machine, start a copy of this program with >./bz239563-multicast sendto {the first machine's ip address on {iface}} \ > {multicast number (224.1.1.1 for example)} {port number (like 5555)} ... > >9: confirm that the invocation in step #8 failed. >OR confirm that the invocation from step 7 never received the datagram and >timed out. > >10: ??? > > >*/ > >#include <sys/types.h> >#include <sys/socket.h> >#include <netinet/in.h> >#include <stdio.h> >#include <stdlib.h> >#include <errno.h> >#include <string.h> > >char databuf[128] = "There really should be some data here"; > >int main ( int argc, char **argv ) { > char *whattodo; > char *ipaddrstr; > char *mcastaddrstr; > char *portnostr; > > struct in_addr localnetif; > struct sockaddr_in sa; > int sd; > unsigned long portno; > char *endp; > int status; > > memset ( &sa, 0, sizeof(sa) ); > > if ( argc != 5 ) { > fprintf ( stderr, "invalid arg count: (recvfrom|sendto) {local ip} {multicast ip} {portno}\n" ); > return 1; > } > whattodo = argv[1]; > ipaddrstr = argv[2]; > mcastaddrstr = argv[3]; > portnostr = argv[4]; > > if ( strcmp ( whattodo, "sendto" ) && strcmp ( whattodo, "recvfrom" ) ) { > fprintf ( stderr, "first arg not sendto or recvfrom\n" ); > return 1; > } > > status = inet_aton ( ipaddrstr, &localnetif ); > if ( status == 0 ) { > fprintf ( stderr, "second arg not an ip addr\n" ); > return 1; > } > status = inet_aton ( mcastaddrstr, &sa.sin_addr ); > if ( 0 == status ) { > fprintf ( stderr, "third arg not an ip addr\n" ); > return 1; > } > errno = 0; > portno = strtoul ( portnostr, &endp, 0 ); > if ( errno || ( endp && *endp ) || portno < 0 || portno > USHRT_MAX ) { > fprintf ( stderr, "fourth arg not a valid port number\n" ); > return 1; > } > > sd = socket ( AF_INET, SOCK_DGRAM, 0 ); > if ( sd < 0 ) { > perror ( "socket() failed" ); > return 2; > } > > sa.sin_family = AF_INET; > sa.sin_port = htons ( portno ); > > if ( 0 == strcmp ( whattodo, "sendto" ) ) { > status = setsockopt ( sd, IPPROTO_IP, IP_MULTICAST_IF, &localnetif, sizeof(localnetif) ); > if ( status < 0 ) { > perror ( "set local interface" ); > return 2; > } > status = sendto ( sd, databuf, sizeof(databuf), 0, (struct sockaddr *)&sa, sizeof(sa) ); > if ( status < 0 ) { > perror ( "sendto failed" ); > return 2; > } > } else { > struct sockaddr_in bsa; > struct ip_mreq mreq; > socklen_t len; > ssize_t nread; > char buffer[512]; > > bsa.sin_family = AF_INET; > bsa.sin_port = htons ( portno ); > bsa.sin_addr.s_addr = INADDR_ANY; > status = bind ( sd, (struct sockaddr *)&bsa, sizeof(bsa) ); > if ( status < 0 ) { > perror ( "bind failed" ); > return 2; > } > mreq.imr_interface.s_addr = INADDR_ANY; > status = inet_aton ( mcastaddrstr, &mreq.imr_multiaddr); > if ( status < 0 ) { > fprintf ( stderr, "inet_aton on %s failed\n", mcastaddrstr ); > return 2; > } > status = setsockopt ( sd, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq) ); > if ( status < 0 ) { > perror ( "add membership failed" ); > return 2; > } > len = sizeof(sa); > nread = recvfrom ( sd, buffer, sizeof(buffer), 0, (struct sockaddr *)&sa, &len ); > if ( nread < 0 ) { > perror ( "recvfrom failed" ); > return 2; > } > if ( nread != sizeof(databuf) || memcmp ( databuf, buffer, sizeof(databuf) ) ) { > fprintf ( stderr, "read failure\n" ); > return 2; > } > } > status = close ( sd ); > if ( status < 0 ) { > perror ( "close failed" ); > return 2; > } > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 239563
: 214811