First draft of the dccp sender/receiver pair.
[paraslash.git] / dccp.c
1 #include "para.h"
2 #include "error.h"
3 #include "dccp.h"
4
5 int dccp_get_socket(void)
6 {
7 int s = socket(AF_INET, SOCK_DCCP, IPPROTO_DCCP);
8
9 if (s < 0)
10 return -E_DCCP_SOCKET;
11 return s;
12 }
13
14 int dccp_set_socket(int fd)
15 {
16 int pkt_size = 256, ret;
17
18 /* hack to get a service code */
19 ret = setsockopt(fd, SOL_DCCP, DCCP_SOCKOPT_PACKET_SIZE,
20 (char*)&pkt_size, sizeof(pkt_size));
21 if (ret < 0)
22 return -E_DCCP_PACKET_SIZE;
23 ret = setsockopt(fd, SOL_DCCP, DCCP_SOCKOPT_SERVICE,
24 (char*)&pkt_size, sizeof(pkt_size));
25 if (ret < 0)
26 return -E_DCCP_SERVICE;
27 return 1;
28 }