chiark / gitweb /
server/: Calculate address size on demand, rather than tracking it.
[tripe] / server / servutil.c
index e4772c4c025c9bf1cf0d16ef16d8f06e62717f41..707213968f9dd2be252e7485c313c3bbbce7e4e5 100644 (file)
@@ -121,4 +121,19 @@ int mystrieq(const char *x, const char *y)
   }
 }
 
+/* --- @addrsz@ --- *
+ *
+ * Arguments:  @const addr *a@ = a network address
+ *
+ * Returns:    The size of the address, for passing into the sockets API.
+ */
+
+socklen_t addrsz(const addr *a)
+{
+  switch (a->sa.sa_family) {
+    case AF_INET: return (sizeof(a->sin));
+    default: abort();
+  }
+}
+
 /*----- That's all, folks -------------------------------------------------*/