PadicoTM

Documentation

« back to PM2 home.
padico-resolve.c
Go to the documentation of this file.
1/*
2 * Padico -- a High Performance Parallel and Distributed Computing Environment
3 * Copyright (c) 2002-2024 INRIA and the University of Rennes 1
4 * Alexandre DENIS <Alexandre.Denis@inria.fr>
5 * Christian PEREZ <Christian.Perez@inria.fr>
6 *
7 * The software has been registered at the Agency for the Protection of
8 * Programs (APP) under the number IDDN.FR.001.260013.000.S.P.2002.000.10000.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25#include <Padico/Puk.h>
26#include <Padico/PadicoTM.h>
27#include <Padico/Module.h>
28#include <Padico/Topology.h>
29
30#include <sys/types.h>
31#include <sys/socket.h>
32#include <netinet/in.h>
33#include <arpa/inet.h>
34#include <netdb.h>
35
36static int padico_resolve_init(void);
37
39
40static int isaddr(const char *hostname)
41{
42 if(hostname)
43 {
44 struct sockaddr_in inaddr;
45 if (inet_pton(AF_INET, hostname, &inaddr)==1)
46 return 1;
47 struct sockaddr_in6 in6addr;
48 if (inet_pton(AF_INET6, hostname, &in6addr)==1)
49 return 1;
50 return 0;
51 }
52 return -1;
53}
54
55static char* nametoipv4(const char * name)
56{
59 const struct in_addr* iphost = padico_topo_host_getaddr(h);
60 if(iphost)
62 else
63 {
65 ipstr = NULL;
66 }
67 return ipstr;
68}
69
70int padico_getaddrinfo(const char *node, const char *service,
71 const struct addrinfo *hints, struct addrinfo **res)
72{
73 int rc = isaddr(node);
74 if(rc == 0)
75 {
76 char* ipstr = nametoipv4(node);
77 if(ipstr)
78 {
81 return rc;
82 }
83 }
84 return PUK_ABI_RESOLV_WRAP(getaddrinfo)(node, service, hints, res);
85}
86
87struct hostent *padico_gethostbyname(const char *name)
88{
89 int rc = isaddr(name);
90 if(rc == 0)
91 {
92 char* ipstr = nametoipv4(name);
93 if(ipstr)
94 {
97 return tmp;
98 }
99 }
101}
102
104 struct hostent *ret, char *buf, size_t buflen,
105 struct hostent **result, int *h_errnop)
106{
107 int rc = isaddr(name);
108 if(rc == 0)
109 {
110 char* ipstr = nametoipv4(name);
111 if(ipstr)
112 {
115 return rc;
116 }
117 }
119}
120
121int padico_gethostbyname2_r(const char *name, int af,
122 struct hostent *ret, char *buf, size_t buflen,
123 struct hostent **result, int *h_errnop)
124{
125 int rc = isaddr(name);
126 if(rc == 0 && af == AF_INET)
127 {
128 char* ipstr = nametoipv4(name);
129 if(ipstr)
130 {
133 return rc;
134 }
135 }
137}
138
139static int padico_resolve_init(void)
140{
141#ifdef PUKABI_ENABLE_RESOLV
146#endif /* PUKABI_ENABLE_RESOLV */
147
148 return 0;
149}
ns_rulebucket_hashtable_t h
return NULL
Definition Shm.h:88
static int done
Definition console-mod.c:49
char * name
Definition PadicoTM.h:168
#define PUK_ABI_RESOLV_WRAP(SYM)
Definition PadicoTM.h:94
#define puk_abi_set_virtual(F, PTR)
Definition PadicoTM.h:99
padico_rc_t rc
Definition PadicoTM.h:146
const struct in_addr * padico_topo_host_getaddr(padico_topo_host_t host)
Get the canonical IP address of a host.
Definition topology.c:1977
padico_topo_host_t padico_topo_host_resolvebyname(const char *hostname)
resolve a host from name
Definition topology.c:2681
padico_topo_node_t node
Definition na-control.c:65
static int isaddr(const char *hostname)
struct hostent * padico_gethostbyname(const char *name)
int padico_gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop)
int padico_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res)
int padico_gethostbyname2_r(const char *name, int af, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop)
static char * nametoipv4(const char *name)
static int padico_resolve_init(void)