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 305466 Details for
Bug 369591
multicast change in behavior
[?]
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.
modified mcsend to set IP_MULTICAST_IF
mcsend.c (text/plain), 3.13 KB, created by
Neil Horman
on 2008-05-15 11:09:21 UTC
(
hide
)
Description:
modified mcsend to set IP_MULTICAST_IF
Filename:
MIME Type:
Creator:
Neil Horman
Created:
2008-05-15 11:09:21 UTC
Size:
3.13 KB
patch
obsolete
>#include <sys/types.h> /* for type definitions */ >#include <sys/socket.h> /* for socket API function calls */ >#include <netinet/in.h> /* for address structs */ >#include <arpa/inet.h> /* for sockaddr_in */ >#include <stdio.h> /* for printf() */ >#include <stdlib.h> /* for atoi() */ >#include <string.h> /* for strlen() */ >#include <unistd.h> /* for close() */ > >#define MAX_LEN 1024 /* maximum string size to send */ >#define MIN_PORT 1024 /* minimum port allowed */ >#define MAX_PORT 65535 /* maximum port allowed */ > >int main(int argc, char *argv[]) { > > int sock; /* socket descriptor */ > char send_str[MAX_LEN]; /* string to send */ > struct sockaddr_in mc_addr; /* socket address structure */ > unsigned int send_len; /* length of string to send */ > char* mc_addr_str; /* multicast IP address */ > char* src_addr_str; /* multicast IP address */ > struct ip_mreqn opt; > unsigned int mc_port; /* multicast port */ > unsigned char mc_ttl=1; /* time to live (hop count) */ > > /* validate number of arguments */ > if (argc != 4) { > fprintf(stderr, > "Usage: %s <Multicast IP> <Multicast Port> <SRc address>\n", > argv[0]); > exit(1); > } > > mc_addr_str = argv[1]; /* arg 1: multicast IP address */ > mc_port = atoi(argv[2]); /* arg 2: multicast port number */ > src_addr_str = argv[3]; /* arg 3: local port to send the frame from */ > > /* validate the port range */ > if ((mc_port < MIN_PORT) || (mc_port > MAX_PORT)) { > fprintf(stderr, "Invalid port number argument %d.\n", > mc_port); > fprintf(stderr, "Valid range is between %d and %d.\n", > MIN_PORT, MAX_PORT); > exit(1); > } > > /* create a socket for sending to the multicast address */ > if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { > perror("socket() failed"); > exit(1); > } > > /* set the TTL (time to live/hop count) for the send */ > if ((setsockopt(sock, IPPROTO_IP, IP_MULTICAST_TTL, > (void*) &mc_ttl, sizeof(mc_ttl))) < 0) { > perror("setsockopt() failed"); > exit(1); > } > > opt.imr_multiaddr.s_addr = inet_addr(mc_addr_str); > opt.imr_address.s_addr = inet_addr(src_addr_str); > opt.imr_ifindex = 0; > > if (setsockopt(sock, IPPROTO_IP, IP_MULTICAST_IF, (void *)&opt, sizeof(struct ip_mreqn)) <0) { > perror("Could not set IP_MULTICAST_IF failed"); > exit(1); > } > > /* construct a multicast address structure */ > memset(&mc_addr, 0, sizeof(mc_addr)); > mc_addr.sin_family = AF_INET; > mc_addr.sin_addr.s_addr = inet_addr(mc_addr_str); > mc_addr.sin_port = htons(mc_port); > > printf("Begin typing (return to send, ctrl-C to quit):\n"); > > /* clear send buffer */ > memset(send_str, 0, sizeof(send_str)); > > while (fgets(send_str, MAX_LEN, stdin)) { > send_len = strlen(send_str); > > /* send string to multicast address */ > if ((sendto(sock, send_str, send_len, 0, > (struct sockaddr *) &mc_addr, > sizeof(mc_addr))) != send_len) { > perror("sendto() sent incorrect number of bytes"); > exit(1); > } > > /* clear send buffer */ > memset(send_str, 0, sizeof(send_str)); > } > > close(sock); > > exit(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 369591
:
250061
|
305204
| 305466