From 96af1d7e02ac1734b562d07a03c4d7a53abafb3c Mon Sep 17 00:00:00 2001 Message-Id: <96af1d7e02ac1734b562d07a03c4d7a53abafb3c.1715356324.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 10 Nov 2013 13:57:26 +0000 Subject: [PATCH] client.c: new disorder_client_af reveals connectivity type Organization: Straylight/Edgeware From: Richard Kettlewell --- lib/client.c | 9 +++++++++ lib/client.h | 1 + 2 files changed, 10 insertions(+) diff --git a/lib/client.c b/lib/client.c index 55cfe1c..09e5426 100644 --- a/lib/client.c +++ b/lib/client.c @@ -66,6 +66,8 @@ struct disorder_client { int verbose; /** @brief Last error string */ const char *last; + /** @brief Address family */ + int family; }; /** @brief Create a new client @@ -80,9 +82,15 @@ disorder_client *disorder_new(int verbose) { disorder_client *c = xmalloc(sizeof (struct disorder_client)); c->verbose = verbose; + c->family = -1; return c; } +/** @brief Return the address family used by this client */ +int disorder_client_af(disorder_client *c) { + return c->family; +} + /** @brief Read a response line * @param c Client * @param rp Where to store response, or NULL (UTF-8) @@ -407,6 +415,7 @@ int disorder_connect_generic(struct config *conf, disorder_error(errno, "error calling socket"); return -1; } + c->family = sa->sa_family; if(connect(fd, sa, salen) < 0) { byte_xasprintf((char **)&c->last, "connect: %s", strerror(errno)); disorder_error(errno, "error calling connect"); diff --git a/lib/client.h b/lib/client.h index 2513a89..c7964d6 100644 --- a/lib/client.h +++ b/lib/client.h @@ -39,6 +39,7 @@ struct kvp; struct sink; disorder_client *disorder_new(int verbose); +int disorder_client_af(disorder_client *c); int disorder_connect(disorder_client *c); int disorder_connect_user(disorder_client *c, const char *username, -- [mdw]