summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2022-11-25 19:04:18 +0100
committerxengineering <me@xengineering.eu>2022-11-27 19:11:02 +0100
commitd6f3a46ef5df412d6549caf94144c303235feaa9 (patch)
treee0002a870131c1614ad21554f15a23c9af397535
parent2efc9022bf064136bb7cd25bd59971f2b419ff48 (diff)
downloadlimox-d6f3a46ef5df412d6549caf94144c303235feaa9.tar
limox-d6f3a46ef5df412d6549caf94144c303235feaa9.tar.zst
limox-d6f3a46ef5df412d6549caf94144c303235feaa9.zip
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.
-rw-r--r--xmpp.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/xmpp.c b/xmpp.c
index e1ab985..62fd142 100644
--- a/xmpp.c
+++ b/xmpp.c
@@ -5,13 +5,15 @@
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <netdb.h>
/*
- * 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);