From d6f3a46ef5df412d6549caf94144c303235feaa9 Mon Sep 17 00:00:00 2001 From: xengineering Date: Fri, 25 Nov 2022 19:04:18 +0100 Subject: Implement dummy DNS resolution This is not by far complete DNS handling but demonstrates that name resolution works by printing the IP address type (IPv4 or IPv6) for each found IP address. --- xmpp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'xmpp.c') diff --git a/xmpp.c b/xmpp.c index e1ab985..62fd142 100644 --- a/xmpp.c +++ b/xmpp.c @@ -5,13 +5,15 @@ #include #include #include +#include /* - * Get the domainpart of the Jabber ID (JID). + * Get the domainpart of the Jabber ID (JID) + * * See https://datatracker.ietf.org/doc/html/rfc7622#section-3.2 for details. */ -char *domainpart(char *jid) +char *get_domainpart(char *jid) { int start = 0; // inclusive int stop = strlen(jid); // exclusive @@ -78,10 +80,11 @@ void xmpp_connect(void) { printf("net_init()\n"); - char* user_str = getenv("LIMOX_USER"); - char* pwd_str = getenv("LIMOX_PWD"); - char *domain = domainpart(user_str); - printf("Trying to connect as '%s' with '%s'.\n", user_str, pwd_str); + char *jid = getenv("LIMOX_USER"); + char *pwd = getenv("LIMOX_PWD"); + printf("Trying to connect as '%s' with '%s'.\n", jid, pwd); + + char *domain = get_domainpart(jid); printf("Domainpart is '%s'.\n", domain); get_addrinfo(domain); -- cgit v1.2.3-70-g09d2