FreeBSD Bugzilla – Attachment 157024 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]
server.c
server.c (text/plain), 2.09 KB, created by
Craig Rodrigues
on 2015-05-22 01:44:17 UTC
(
hide
)
Description:
server.c
Filename:
MIME Type:
Creator:
Craig Rodrigues
Created:
2015-05-22 01:44:17 UTC
Size:
2.09 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 BUFFER_SIZE (1<<16) >#define PORT 8888 >//#define ADDR "169.254.0.35" >//#define ADDR "169.254.0.25" >//#define ADDR "10.47.250.26" >//#define ADDR "127.0.0.1" > >void >usage(const char *name) >{ > printf("%s [address] [fib]\n", name); >} > >int >main(int argc, char *argv[]) >{ > int fd , n, flags; > struct sockaddr_in addr; > socklen_t from_len; > struct sctp_sndrcvinfo sinfo; > char buffer [BUFFER_SIZE]; > struct sctp_event_subscribe event; > char *ADDR = NULL; > int fib = -1; > int ret; > > if (argc < 3) { > usage(argv[0]); > exit(1); > } > ADDR = strdup(argv[1]); > fib = atoi(argv[2]); > > 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 * )&addr, 0, sizeof(struct sockaddr_in)); > addr.sin_len = sizeof(struct sockaddr_in); > addr.sin_family = AF_INET; > addr.sin_port = htons(PORT); > addr.sin_addr.s_addr = inet_addr(ADDR); > if (bind(fd, (struct sockaddr * )&addr, sizeof(struct sockaddr_in)) < 0) { > perror("bind"); > } > if (listen(fd, 1) < 0) { > perror("listen"); > exit(-1); > } > while (1) { > flags = 0; > memset((void * )&addr, 0, sizeof(struct sockaddr_in)); > from_len = (socklen_t) sizeof(struct sockaddr_in); > memset((void * )&sinfo, 0, sizeof(struct sctp_sndrcvinfo)); > n = sctp_recvmsg(fd, (void * )buffer, BUFFER_SIZE, > (struct sockaddr * )&addr, &from_len, > &sinfo, &flags); > if (flags & MSG_NOTIFICATION) { > printf("Notification received.\n"); > } else { > printf("Msg of length %d received from %s:%u on stream %d, PPID %d.\n", > n, inet_ntoa(addr.sin_addr), ntohs(addr.sin_port), > sinfo.sinfo_stream, ntohl(sinfo.sinfo_ppid)); > } > } > 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