|
xorp
|
00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- 00002 // vim:set sts=4 ts=8: 00003 00004 // Copyright (c) 2001-2011 XORP, Inc and Others 00005 // 00006 // This program is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU Lesser General Public License, Version 00008 // 2.1, June 1999 as published by the Free Software Foundation. 00009 // Redistribution and/or modification of this program under the terms of 00010 // any other version of the GNU Lesser General Public License is not 00011 // permitted. 00012 // 00013 // This program is distributed in the hope that it will be useful, but 00014 // WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, 00016 // see the GNU Lesser General Public License, Version 2.1, a copy of 00017 // which can be found in the XORP LICENSE.lgpl file. 00018 // 00019 // XORP, Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; 00020 // http://xorp.net 00021 00022 // $XORP: xorp/libxipc/sockutil.hh,v 1.16 2008/10/02 21:57:21 bms Exp $ 00023 00024 /* Some helper functions for sockets */ 00025 00026 #ifndef __LIBXIPC_SOCKUTIL_HH__ 00027 #define __LIBXIPC_SOCKUTIL_HH__ 00028 00029 #include "libxorp/xorp.h" 00030 00031 00032 00033 00034 #ifdef HAVE_SYS_TYPES_H 00035 #include <sys/types.h> 00036 #endif 00037 #ifdef HAVE_SYS_PARAM_H 00038 #include <sys/param.h> 00039 #endif 00040 #ifdef HAVE_NETINET_IN_H 00041 #include <netinet/in.h> 00042 #endif 00043 #ifdef HAVE_SYS_SOCKET_H 00044 #include <sys/socket.h> 00045 #endif 00046 00047 #include "libxorp/ipv4.hh" 00048 00055 XorpFd create_connected_tcp4_socket(const string& addr_slash_port); 00056 00064 bool get_local_socket_details(XorpFd fd, string& addr, uint16_t& port); 00065 00074 bool get_remote_socket_details(XorpFd fd, string& addr, uint16_t& port); 00075 00083 string address_slash_port(const string& addr, uint16_t port); 00084 00088 bool split_address_slash_port(const string& address_slash_port, 00089 string& address, uint16_t& port); 00090 00098 bool address_lookup(const string& addr, in_addr& ia); 00099 00108 bool is_ip_configured(const in_addr& ia); 00109 00117 bool set_preferred_ipv4_addr(in_addr addr); 00118 00127 in_addr get_preferred_ipv4_addr(); 00128 00129 /* 00130 * Get a list of of active and configured IPv4 addresses on the system. 00131 * 00132 * @param addrs empty vector of IPv4 addresses 00133 */ 00134 void get_active_ipv4_addrs(vector<IPv4>& addrs); 00135 00136 #endif // __LIBXIPC_SOCKUTIL_HH__