X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=dccp.c;h=62de4f7d6492fee1c616825b554c5276a93f2e0f;hp=b5cf7fd9abd106a5c942c96f0cab9e53445d12de;hb=61b0a431ca3c5dabfa5445355664f00e312c5299;hpb=abbddde3ee707103d5d8b088c8fa6fc53f09ebff diff --git a/dccp.c b/dccp.c index b5cf7fd9..62de4f7d 100644 --- a/dccp.c +++ b/dccp.c @@ -1,21 +1,11 @@ /* - * Copyright (C) 2006 Andre Noll + * Copyright (C) 2006-2007 Andre Noll * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Licensed under the GPL v2. For licencing details see COPYING. */ +/** \file dccp.c common functions of the dccp sender/receiver */ + /* * based on common.c of dccp-cs-0.01.tar.bz2, * (C) 2005 Ian McDonald @@ -24,7 +14,19 @@ #include "para.h" #include "error.h" #include "dccp.h" +#include "fd.h" +/** \cond some magic dccp constants */ +#define SOCK_DCCP 6 +#define IPPROTO_DCCP 33 +/** \endcond */ + +/** + * obtain a dccp socket for sending/receiving + * + * \return the file descriptor of the new socket or \p -E_DCCP_SOCKET + * on errors. + */ int dccp_get_socket(void) { int s = socket(AF_INET, SOCK_DCCP, IPPROTO_DCCP); @@ -34,18 +36,14 @@ int dccp_get_socket(void) return s; } -int dccp_set_socket(int fd) +/** + * prepare a dccp socket + * + * \param fd the file descriptor of the socket + * + * \returns positive on success, negative on errors. + */ +int dccp_set_socket(__a_unused int fd) { - int pkt_size = 256, ret; - - /* hack to get a service code */ - ret = setsockopt(fd, SOL_DCCP, DCCP_SOCKOPT_PACKET_SIZE, - (char*)&pkt_size, sizeof(pkt_size)); - if (ret < 0) - return -E_DCCP_PACKET_SIZE; - ret = setsockopt(fd, SOL_DCCP, DCCP_SOCKOPT_SERVICE, - (char*)&pkt_size, sizeof(pkt_size)); - if (ret < 0) - return -E_DCCP_SERVICE; - return 1; + return 1; /* nothing to do at the moment */ }