1 |
/* This file is part of GNU RADIUS. |
/* This file is part of GNU Radius. |
2 |
Copyright (C) 2000, Sergey Poznyakoff |
Copyright (C) 2000,2001,2002,2003 Sergey Poznyakoff |
3 |
|
|
4 |
This program is free software; you can redistribute it and/or modify |
GNU Radius is free software; you can redistribute it and/or modify |
5 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
6 |
the Free Software Foundation; either version 2 of the License, or |
the Free Software Foundation; either version 2 of the License, or |
7 |
(at your option) any later version. |
(at your option) any later version. |
8 |
|
|
9 |
This program is distributed in the hope that it will be useful, |
GNU Radius is distributed in the hope that it will be useful, |
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
GNU General Public License for more details. |
GNU General Public License for more details. |
13 |
|
|
14 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
15 |
along with this program; if not, write to the Free Software Foundation, |
along with GNU Radius; if not, write to the Free Software Foundation, |
16 |
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
17 |
|
|
|
#ifndef lint |
|
|
static char rcsid[] = |
|
|
"$Id$"; |
|
|
#endif |
|
|
|
|
18 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
19 |
# include <config.h> |
# include <config.h> |
20 |
#endif |
#endif |
41 |
* for the supplied IP address. |
* for the supplied IP address. |
42 |
*/ |
*/ |
43 |
char * |
char * |
44 |
ip_gethostname(ipaddr, namebuf, size) |
ip_gethostname(UINT4 ipaddr, char *namebuf, size_t size) |
|
UINT4 ipaddr; |
|
|
char *namebuf; |
|
|
size_t size; |
|
45 |
{ |
{ |
46 |
struct hostent *hp, hent; |
struct hostent *hp, hent; |
47 |
char buffer[512]; |
char buffer[512]; |
70 |
* name or address in dot notation. |
* name or address in dot notation. |
71 |
*/ |
*/ |
72 |
UINT4 |
UINT4 |
73 |
ip_gethostaddr(host) |
ip_gethostaddr(char *host) |
|
char *host; |
|
74 |
{ |
{ |
75 |
struct hostent *hp, hent; |
struct hostent *hp, hent; |
76 |
char buffer[512]; |
char buffer[512]; |
89 |
* Check for valid IP address in standard dot notation. |
* Check for valid IP address in standard dot notation. |
90 |
*/ |
*/ |
91 |
int |
int |
92 |
good_ipaddr(addr) |
good_ipaddr(char *addr) |
|
char *addr; |
|
93 |
{ |
{ |
94 |
int dot_count; |
int dot_count; |
95 |
int digit_count; |
int digit_count; |
115 |
* provided address in host long notation. |
* provided address in host long notation. |
116 |
*/ |
*/ |
117 |
char * |
char * |
118 |
ip_iptostr(ipaddr, buffer) |
ip_iptostr(UINT4 ipaddr, char *buffer) |
|
UINT4 ipaddr; |
|
|
char *buffer; |
|
119 |
{ |
{ |
120 |
sprintf(buffer, "%u.%u.%u.%u", |
sprintf(buffer, "%u.%u.%u.%u", |
121 |
(u_int) ((ipaddr >> 24) & 0xff), |
(u_int) ((ipaddr >> 24) & 0xff), |
130 |
* one supplied in standard dot notation. |
* one supplied in standard dot notation. |
131 |
*/ |
*/ |
132 |
UINT4 |
UINT4 |
133 |
ip_strtoip(ip_str) |
ip_strtoip(char *ip_str) |
|
char *ip_str; |
|
134 |
#ifdef HAVE_INET_ATON |
#ifdef HAVE_INET_ATON |
135 |
{ |
{ |
136 |
struct in_addr in; |
struct in_addr in; |