PadicoTM

Documentation

« back to PM2 home.
Topology-internals.h
Go to the documentation of this file.
1/*
2 * Padico -- a High Performance Parallel and Distributed Computing Environment
3 * Copyright (c) 2002-2025 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
30#ifndef TOPOLOGY_INTERNALS_H
31#define TOPOLOGY_INTERNALS_H
32
33#include <Padico/Puk.h>
34#include <Padico/PadicoTM.h>
35#include "Topology.h"
36
37#include <netdb.h>
38#ifdef HAVE_LINUX_IF_H
39#include <linux/if.h>
40#else
41#include <net/if.h>
42#endif /* HAVE_LINUX_IF_H */
43#include <net/if_arp.h>
44
45/* *** Topology model ************************************** */
46
47
49
51#define TOPO_HWADDR_PADDING 16
52
53#ifdef IFNAMSIZ
54#define TOPO_HWADDR_NAMSIZ IFNAMSIZ
55#else
56#warning IFNAMSIZ undefined.
57#define TOPO_HWADDR_NAMSIZ 16
58#endif
59
66
69{
70 int family;
71 int size;
72 char _addr_storage[1];
73};
74
77{
79 char name[1];
80};
81
89
92{
93 int lat;
94 int bw;
95};
96
116
132
134{
136 union
137 {
138 struct
139 {
142 struct
143 {
146 struct
147 {
151 struct
152 {
155 struct
156 {
159 struct
160 {
161 char*name;
163 struct
164 {
168 struct
169 {
172 struct
173 {
176 struct
177 {
178 char*label;
179 char*value;
182};
184
192
194{
195 char*name;
197};
199
210
220
223{
225 int index;
226 unsigned short int type;
227 size_t len;
229};
230
237
249
250/* hashing functions for UUID */
251
252static inline int topo_uuid_eq(const struct topo_uuid_s*uuid1, const struct topo_uuid_s*uuid2)
253{
254 return (memcmp(uuid1, uuid2, PADICO_TOPO_UUID_SIZE) == 0);
255}
256static inline uint32_t topo_uuid_hash(const struct topo_uuid_s*uuid)
257{
259}
260
263
266
269
270
284
286
287
288/* ********************************************************* */
289
292
295 const char*uuid, const char*boot_id);
297
306
307/* ********************************************************* */
308/* ** hwaddr toolbox */
309
311{
314 {
315 if(strcmp(name, (*i)->name) == 0)
316 return *i;
317 }
318 return NULL;
319}
321{
324 {
325 if((*i)->index == index)
326 return *i;
327 }
328 return NULL;
329}
330
331/* ********************************************************* */
332/* ** filter toolbox */
333
334static const char*topo_filter_policy_names[] =
335 {
337 [PADICO_TOPO_FILTER_BLOCK_IN] = "block-input",
338 [PADICO_TOPO_FILTER_BLOCK_OUT] = "block-output",
339 [PADICO_TOPO_FILTER_ALLOW_IN] = "allow-input",
340 [PADICO_TOPO_FILTER_ALLOW_OUT] = "allow-output",
342 };
343
345{
348 {
351 {
352 return i;
353 }
354 }
356}
357
359{
361 return topo_filter_policy_names[(int)policy];
362 else
363 return NULL;
364}
365
367static inline int topo_filter_protocol_getnumber(const char*proto_name)
368{
369 if(strcmp(proto_name, "tcp") == 0)
370 return IPPROTO_TCP;
371 else if(strcmp(proto_name, "udp") == 0)
372 return IPPROTO_UDP;
373 else
374 {
376 if(p)
377 return p->p_proto;
378 else
379 {
380 padico_warning("unknown protocol name %s\n", proto_name);
381 return -1;
382 }
383 }
384}
385
387static inline const char*topo_filter_protocol_getname(int protocol)
388{
389 if(protocol == IPPROTO_TCP)
390 return "tcp";
391 else if(protocol == IPPROTO_UDP)
392 return "udp";
393 else
394 {
395 const struct protoent*p = getprotobynumber(protocol);
396 if(p)
397 return p->p_name;
398 else
399 {
400 padico_warning("unknown protocol number %d\n", protocol);
401 return "[unknown]";
402 }
403 }
404}
405
406/* ********************************************************* */
407/* ** addr */
408
409static inline const struct in_addr*topo_address_as_inaddr(padico_topo_address_t addr)
410{
411 assert(addr->family == AF_INET);
412 assert(addr->size == sizeof(struct in_addr));
413 return (struct in_addr*)&addr->_addr_storage[0];
414}
415
416/* ********************************************************* */
417/* ** binding toolbox */
418
420{
421 struct topo_binding_s*binding = padico_malloc(sizeof(struct topo_binding_s));
422 binding->entity.kind = TOPO_ENTITY_NONE;
423 binding->entity.as_ptr = NULL;
424 binding->network = network;
427 return binding;
428}
429
430
431#endif /* TOPOLOGY_INTERNALS_H */
return NULL
Definition Shm.h:88
puk_tagged_ptr_t p
Definition Shm.h:88
assert(slab_size > 0)
static const char * topo_filter_policy_names[]
static uint32_t topo_uuid_hash(const struct topo_uuid_s *uuid)
static const struct in_addr * topo_address_as_inaddr(padico_topo_address_t addr)
padico_topo_host_t host
static padico_topo_binding_t topo_binding_create(padico_topo_network_t network)
padico_topo_node_t node
padico_topo_host_t const char const char * boot_id
static padico_topo_hwaddr_t topo_hwaddr_getbyindex(padico_topo_host_t host, int index)
static padico_topo_filter_policy_t topo_filter_policy_getbyname(const char *name)
topo_property_kind_t
@ TOPO_PROPERTY_MISC
arbitrary attribute (string), without semantics
@ TOPO_PROPERTY_PERF
performance properties- TODO
@ TOPO_PROPERTY_HWADDR
hardware address/iface
@ TOPO_PROPERTY_ADDR
protocol address for the binding
@ TOPO_PROPERTY_FILTER
filtering- TODO
@ TOPO_PROPERTY_ROUTE
describe a route between private networks
@ TOPO_PROPERTY_GW_HWADDR
hardware address of the gateway
@ TOPO_PROPERTY_GW_ADDR
IPv4 address of the gateway.
@ TOPO_PROPERTY_HOSTNAME
name of the host on the network
@ TOPO_PROPERTY_GW_HOST
gateway as a host
@ TOPO_PROPERTY_INDEX
index of the board or port number
@ TOPO_PROPERTY_SERVICE
service which run on a host
padico_topo_binding_t b2
static const char * topo_filter_policy_getname(padico_topo_filter_policy_t policy)
padico_topo_host_t const char * uuid
static int topo_filter_protocol_getnumber(const char *proto_name)
frontend for getprotobyname(), working even in the absence of /etc/protocols
static const char * topo_filter_protocol_getname(int protocol)
frontend for getprotobynumber(), working even in the absence of /etc/protocols
#define TOPO_HWADDR_NAMSIZ
static padico_topo_hwaddr_t topo_hwaddr_getbyname(padico_topo_host_t host, const char *name)
static int topo_uuid_eq(const struct topo_uuid_s *uuid1, const struct topo_uuid_s *uuid2)
Topology description API.
static int done
Definition console-mod.c:49
char * name
Definition PadicoTM.h:168
#define PADICO_TOPO_UUID_SIZE
Definition Topology.h:73
padico_topo_filter_policy_t
Definition Topology.h:109
padico_topo_binding_scope_t
Definition Topology.h:92
typdef struct padico_topo_network_vect_s * padico_topo_network_vect_t
Definition Topology.h:85
@ PADICO_TOPO_FILTER_ALLOW_OUT
Definition Topology.h:114
@ _PADICO_TOPO_FILTER_MAX
Definition Topology.h:115
@ PADICO_TOPO_FILTER_BLOCK_OUT
Definition Topology.h:112
@ PADICO_TOPO_FILTER_BLOCK_IN
Definition Topology.h:111
@ PADICO_TOPO_FILTER_ALLOW_IN
Definition Topology.h:113
@ _PADICO_TOPO_FILTER_NONE
Definition Topology.h:110
padico_topo_network_t network
Definition psp-mx.c:113
padico_topo_binding_scope_t scope
Shared structure to describes the "known world".
padico_topo_network_t inet6
global network- IPv6 internet
struct topo_host_by_name_hashtable_s hostsbyname
index of hosts, hashed by name (there may be duplicate entries)
padico_topo_network_t inet
global network- public IPv4 internet
padico_topo_node_t local_node
local node descriptor
padico_topo_network_vect_t networks
vector of known networks
struct topo_node_by_name_hashtable_s nodesbyname
index of nodes, hashed by nodename (canonical+alias, there may be duplicate entries)
struct topo_host_by_name_hashtable_s host_table
index of hosts, hashed by fqdn
struct topo_node_by_uuid_hashtable_s node_table
index of node, hashed by UUID
a network address used in bindings
char _addr_storage[1]
placeholder for address- more bytes are actually allocated
int size
address size, used for hashing
int family
address family, using AF_*
a binding of an entity with a network (protocol level)
struct topo_property_vect_s props
binding properties, e.g.
padico_topo_network_t network
container network
topo_net_entity_t entity
contained entity
a filter rule, i.e a port number, and a policy
padico_topo_filter_policy_t policy
struct topo_hostname_vect_s hnames
names of the host, including short hostname and fqdn
struct padico_topo_node_vect_s nodes
nodes on this host
struct topo_property_vect_s props
host properties, e.g service
struct padico_topo_binding_vect_s bindings
protocol bindings
const char * hostname
canonical fully qualified domain name, as reported by gethostbyname(3)
struct topo_hwaddr_vect_s hwaddrs
hardware addresses
a hardware address- identifies a host
char name[16]
hw interface name, as seen through netdevice interface
unsigned short int type
ARPHRD_* as defined in <net/if_arp.h>
char _hwaddr_storage[1]
placeholder area for address
int index
hw interface number, as seen through rtnetlink interface
size_t len
actual length of hardware address
an entity that can be member of a network through a binding
padico_topo_node_t node
enum topo_net_entity_s::@87 kind
padico_topo_host_t host
padico_topo_network_t network
a network, containing entities with bindings
size_t addr_size
size of the addresses on the given network
int family
address family used on tyhe network- AF_UNSPEC if unknown
padico_topo_binding_scope_t scope
scope (host/node) of the bindings on this network
const char * network_id
session ID of the network
struct topo_perf_s perf
estimated network performance
struct topo_binding_s * uplink
uplink to another network, if any
struct padico_topo_binding_vect_s bindings
bindings (nodes/hosts) of this network
padico_topo_host_t host
host containing this node
const char * canonical_nodename
fqdn_hostname:num
struct padico_topo_binding_vect_s bindings
network bindings of the node
const char * boot_id
session ID identifying our 'padico-launch' instance
struct topo_uuid_s uuid
universally unique ID for the node
performance information about link, i.e estimated latency and bandwidth
int bw
network bandwidth in KB/s
int lat
network latency in nanoseconds
struct topo_property_s::@90::@98 PERF
struct topo_property_s::@90::@93 GW_HWADDR
for HWADDR
struct topo_address_s gw
padico_topo_hwaddr_t hwaddr
pointer to hwaddr allocated in host
struct topo_property_s::@90::@94 GW_HOST
struct topo_address_s addr
struct topo_property_s::@90::@97 ROUTE
char ifname[16]
ifname, when hwaddr is unresolved
union topo_property_s::@90 content
struct topo_property_s::@90::@96 HOSTNAME
struct topo_property_s::@90::@92 FILTER
for FILTER*
padico_topo_host_t gw_host
struct topo_property_s::@90::@99 INDEX
struct topo_property_s::@90::@95 SERVICE
struct topo_service_s service
struct topo_filter_s filter
padico_topo_network_t dest
struct topo_property_s::@90::@91 GW_ADDR
for ADDR
struct topo_perf_s perf
topo_property_kind_t kind
struct topo_property_s::@90::@93 HWADDR
struct topo_property_s::@90::@91 ADDR
struct topo_property_s::@90::@100 MISC
for MISC
a service which running on a host
Node UUID, in plain text (hex encoding)
struct padico_topology_s * topology_get(void)
Definition topology.c:86
void topo_binding_merge(padico_topo_binding_t binding, padico_topo_binding_t b2)
merge properties from b2 into 'binding', then destroy b2
Definition topology.c:1658
void topo_binding_bind_node(padico_topo_binding_t *_binding, padico_topo_node_t node)
Definition topology.c:1783
void topo_binding_bind_host(padico_topo_binding_t *_binding, padico_topo_host_t host)
Definition topology.c:1747
padico_topo_node_t topo_node_create(const char *name, padico_topo_host_t host, const char *uuid, const char *boot_id)
Create a new node, either locally or received as XML description.
Definition topology.c:1812
void topo_property_destroy(struct topo_property_s *prop)
Definition topology.c:1637
void topo_binding_destroy(struct topo_binding_s *binding)
Definition topology.c:1626
padico_topo_host_t topo_host_lookup(const char *hostname)
Definition topology.c:1510
void topo_node_destroy(padico_topo_node_t node)
Definition topology.c:1840