FreeBSD Bugzilla – Attachment 157025 Details for
Bug 200379
SCTP stack is not FIB aware
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
client.c
client.c (text/plain), 2.32 KB, created by
Craig Rodrigues
on 2015-05-22 01:44:42 UTC
(
hide
)
Description:
client.c
Filename:
MIME Type:
Creator:
Craig Rodrigues
Created:
2015-05-22 01:44:42 UTC
Size:
2.32 KB
patch
obsolete
>#include <sys/types.h> >#include <sys/socket.h> >#include <netinet/in.h> >#include <netinet/sctp.h> >#include <arpa/inet.h> >#include <string.h> >#include <stdio.h> >#include <stdlib.h> >#include <unistd.h> > >#define PORT 8888 >//#define ADDR "169.254.0.25" >//#define ADDR "127.0.0.1" >//#define ADDR "10.47.250.26" >#define SIZE_OF_MESSAGE 65000 >#define NUMBER_OF_MESSAGES 20 >#define PPID 1234 > >void >usage(const char *prog_name) >{ > printf("%s [local address] [remote address] [fib]\n", prog_name); >} > >int >main(int argc, char *argv[]) >{ > > unsigned int i; > int ret; > int fd; > int fib; > struct sockaddr_in local_addr; > struct sockaddr_in remote_addr; > > char buffer [SIZE_OF_MESSAGE]; > > struct iovec iov; > struct msghdr m; > char *LOCAL_ADDR = NULL; > char *REMOTE_ADDR = NULL; > > if (argc < 4) { > usage(argv[0]); > exit(1); > } > LOCAL_ADDR = strdup(argv[1]); > REMOTE_ADDR = strdup(argv[2]); > fib = atoi(argv[3]); > > memset((void * )buffer, 'A', SIZE_OF_MESSAGE); > > if ((fd = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) < 0) { > perror("socket"); > exit(-1); > } > > if (fib >= 0) { > ret = setfib(fib); > if (ret == -1){ > perror("SO_SETFIB"); > exit(1); > } > } > > memset((void * )&local_addr, 0, sizeof(struct sockaddr_in)); > local_addr.sin_len = sizeof(struct sockaddr_in); > local_addr.sin_family = AF_INET; > local_addr.sin_port = 0; > local_addr.sin_addr.s_addr = inet_addr(LOCAL_ADDR); > memset((void * )&remote_addr, 0, sizeof(struct sockaddr_in)); > remote_addr.sin_len = sizeof(struct sockaddr_in); > remote_addr.sin_family = AF_INET; > remote_addr.sin_port = htons(PORT); > remote_addr.sin_addr.s_addr = inet_addr(REMOTE_ADDR); > > if (bind(fd, (struct sockaddr * )&local_addr, sizeof(struct sockaddr_in)) < 0) { > perror("bind"); > exit(1); > } > > for (i = 0; i < NUMBER_OF_MESSAGES; i++) { > bzero(&m, sizeof(m)); > iov.iov_base = buffer; > iov.iov_len = SIZE_OF_MESSAGE; > m.msg_name = &remote_addr; > m.msg_namelen = sizeof(remote_addr); > m.msg_iov = &iov; > m.msg_iovlen = 1; > > ret = sendmsg(fd, &m, 0); > if (ret == -1) { > perror("send"); > } else { > printf("Wrote: %d\n", ret); > > } > } > > if (close(fd) < 0) { > perror("close"); > } > 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 200379
:
157024
| 157025