ATNetworkTool.cpp revision 617e2443dfc17fe44fd44c0675d6aad2ffc9df42
/*******************************************************************************
* Copyright (C) 2004-2008 Intel Corp. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
*
* - Neither the name of Intel Corp. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ATNetworkTool.h"
#include <sstream>
#include <algorithm>
#include <cerrno>
#include <netdb.h>
#ifdef __sun
#include <stdio.h>
#include <stropts.h>
#else
#include <ifaddrs.h>
#endif // __sun
#include <unistd.h>
#include <fcntl.h>
{
if (domp) {
domp++;
if (*domp) {
#ifdef LMS_NET_DEBUG
#endif
return true;
}
}
return false;
}
{
return false;
}
return false;
}
#ifdef LMS_NET_DEBUG
#endif
return true;
}
#ifdef LMS_NET_DEBUG
#endif
return true;
}
}
}
return false;
}
{
char hbuf[NI_MAXHOST];
NULL, 0,
NI_NAMEREQD))) {
return false;
}
}
{
#ifdef __sun
char buf[1024];
int sock;
int nInterfaces;
int i;
if(sock < 0)
{
perror("socket");
return 1;
}
/* Query available interfaces. */
{
perror("ioctl(SIOCGIFCONF)");
return 1;
}
/* Iterate through the list of interfaces. */
for(i = 0; i < nInterfaces; i++)
{
continue;
}
#else // ! __sun
if (0 != getifaddrs(&ifap)) {
return -1;
}
continue;
}
continue;
}
if ((!withloopback) &&
continue;
}
continue;
}
} else {
continue;
}
}
}
}
#endif // __sun
return 0;
}
{
int ret;
return ret;
}
ait++)
{
}
}
return 0;
}
{
struct sockaddr_storage ss;
return -1;
}
return 1;
}
return 0;
}
{
struct sockaddr_storage ss;
return -1;
}
char hbuf[NI_MAXHOST];
char pbuf[NI_MAXSERV];
0))) {
return -1;
}
} else {
}
return -1;
}
continue;
}
}
if (zeroport) {
} else {
}
}
return 0;
}
{
family, true)) {
return -1;
}
family, true)) {
return -1;
}
return 1;
}
return 0;
}
int ATNetworkTool::CloseSocket(int s)
{
return close(s);
}
{
addr->ai_protocol);
}
int &error,
{
if (s < 0) {
return -1;
}
if (socktype != SOCK_DGRAM) {
linger l;
l.l_onoff = 0;
l.l_linger = 0;
(char *)&l, sizeof(l)) == -1) {
close(s);
return -1;
}
}
close(s);
return -1;
}
return s;
}
{
addr->ai_protocol);
}
{
int oks = -1;
} else {
}
#ifdef AI_NUMERICSERV
#endif
if (!loopback) {
}
return -1;
}
continue;
}
}
if (s < 0) {
continue;
}
ATNetworkTool::CloseSocket(s);
continue;
}
oks = s;
break;
}
return oks;
}
int &error,
bool loopback, bool nonblocking,
int backlog)
{
backlog);
}
int &error,
bool loopback, bool nonblocking,
int backlog)
{
int s = -1;
backlog, true);
s = sockets[0];
}
return s;
}
int &error,
bool loopback, bool nonblocking,
{
}
int &error,
bool loopback, bool nonblocking,
{
int num = 0;
} else {
}
#ifdef AI_NUMERICSERV
#endif
if (!loopback) {
}
return -1;
}
continue;
}
}
backlog);
if (s < 0) {
continue;
}
num++;
if (one) {
break;
}
}
return num;
}
bool nonblocking, int backlog)
{
if (s < 0) {
return -1;
}
if (nonblocking) {
}
ATNetworkTool::CloseSocket(s);
return -1;
}
return s;
}
{
if (block) {
} else {
}
}
{
struct sockaddr_storage ss;
return -1;
}
if (s < 0) {
return -1;
}
return s;
}
int &error,
{
}
int &error,
{
int oks = -1;
if (socktype != SOCK_DGRAM) {
}
} else {
}
#ifdef AI_NUMERICSERV
#endif
} else {
}
#ifdef AI_NUMERICSERV
#endif
return -1;
}
}
continue;
}
}
if (s < 0) {
continue;
}
oks = s;
break;
}
return oks;
}
int &error,
{
}
int &error,
{
int oks = -1;
if (socktype != SOCK_DGRAM) {
}
} else {
}
#ifdef AI_NUMERICSERV
#endif
return -1;
}
continue;
}
}
if (s < 0) {
continue;
}
oks = s;
break;
}
return oks;
}
{
struct sockaddr_storage ss;
return 0;
}
case AF_INET6:
break;
case AF_INET:
break;
}
return 0;
}
int &error, bool nonblocking)
{
struct sockaddr_storage saddr;
if (s_new == -1) {
return -1;
}
return s_new;
}