00001 /** 00002 * @file ccn/sockcreate.h 00003 * 00004 * Part of the CCNx C Library. 00005 * 00006 * Copyright (C) 2009-2010 Palo Alto Research Center, Inc. 00007 * 00008 * This library is free software; you can redistribute it and/or modify it 00009 * under the terms of the GNU Lesser General Public License version 2.1 00010 * as published by the Free Software Foundation. 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. You should have received 00015 * a copy of the GNU Lesser General Public License along with this library; 00016 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 00017 * Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 00020 #ifndef CCN_SOCKCREATE_DEFINED 00021 #define CCN_SOCKCREATE_DEFINED 00022 #include <sys/types.h> 00023 #include <sys/socket.h> 00024 00025 /** 00026 * Holds a pair of socket file descriptors. 00027 * 00028 * Some platforms/modes of operations require separate sockets for sending 00029 * and receiving, so we accomodate that with this pairing. It is fine for 00030 * the two file descriptors to be the same. 00031 */ 00032 struct ccn_sockets { 00033 int recving; /**< file descriptor to use for input (recv) */ 00034 int sending; /**< file descriptor to use for output (send) */ 00035 }; 00036 00037 /** 00038 * Text-friendly description of a socket (IPv4 or IPv6). 00039 */ 00040 00041 struct ccn_sockdescr { 00042 int ipproto; /**< as per http://www.iana.org/assignments/protocol-numbers - 00043 should match IPPROTO_* in system headers */ 00044 const char *address; /**< acceptable to getaddrinfo */ 00045 const char *port; /**< service name or number */ 00046 const char *source_address; /**< may be needed for multicast */ 00047 int mcast_ttl; /**< may be needed for multicast */ 00048 }; 00049 00050 int ccn_setup_socket(const struct ccn_sockdescr *descr, 00051 void (*logger)(void *, const char *, ...), 00052 void *logdat, 00053 int (*getbound)(void *, struct sockaddr *, socklen_t), 00054 void *getbounddat, 00055 struct ccn_sockets *socks); 00056 00057 #endif