#include "dccp.h" #include #include #include #include #include #include #include int dccp_send(int sockfd, char* buffer, int bufsize, int priority) { struct msghdr msg; struct iovec iov[1]; iov[0].iov_base=buffer; iov[0].iov_len=bufsize; msg.msg_iov=iov; msg.msg_iovlen=1; msg.msg_name=NULL; msg.msg_namelen=0; struct cmsghdr *cmsg; uint8_t cmsg_area[CMSG_SPACE(sizeof(__u32))]; /* Fill ins information required by CMSG_FIRSTHDR() */ msg.msg_control = cmsg_area; msg.msg_controllen = sizeof cmsg_area; cmsg = CMSG_FIRSTHDR(&msg); cmsg->cmsg_level = SOL_DCCP; cmsg->cmsg_type = DCCP_SCM_PRIORITY; cmsg->cmsg_len = CMSG_LEN(sizeof(__u32)); /* update the total length value */ msg.msg_controllen = cmsg->cmsg_len; __u32 *prio = (__u32*)CMSG_DATA(cmsg); *prio=priority; errno=0; return sendmsg(sockfd, &msg, 0); } int dccp_connect(int sockfd, char* address, char* port) { struct addrinfo *hostinfo; getaddrinfo(address, port, NULL, &hostinfo); return connect(sockfd, hostinfo->ai_addr, hostinfo->ai_addrlen); }