mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +01:00
daemon: netaddr
Structure for a net address. We can expand it later to cover exotic address types (Tor?). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
29
daemon/netaddr.h
Normal file
29
daemon/netaddr.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef LIGHTNING_DAEMON_NETADDR_H
|
||||
#define LIGHTNING_DAEMON_NETADDR_H
|
||||
#include "config.h"
|
||||
#include <ccan/tal/tal.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
struct addrinfo;
|
||||
|
||||
/* This can be extended to support other protocols in future. */
|
||||
struct netaddr {
|
||||
int type; /* See socket(2): SOCK_STREAM currently */
|
||||
int protocol; /* See socket(2): 0 currently */
|
||||
socklen_t addrlen;
|
||||
union {
|
||||
struct sockaddr s;
|
||||
struct sockaddr_in ipv4;
|
||||
struct sockaddr_in6 ipv6;
|
||||
} saddr;
|
||||
};
|
||||
|
||||
/* Get the name for this netaddr. */
|
||||
char *netaddr_name(const tal_t *ctx, const struct netaddr *a);
|
||||
|
||||
/* Create a addrinfo (as wanted by io_connect) for this address. */
|
||||
void netaddr_to_addrinfo(struct addrinfo *ai, const struct netaddr *a);
|
||||
|
||||
#endif /* LIGHTNING_DAEMON_NETADDR_H */
|
||||
Reference in New Issue
Block a user