]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/resolve/dns-type.c
resolved: move dns_type_to_af() to dns-type.c
[thirdparty/systemd.git] / src / resolve / dns-type.c
index 058d14009abff7310ca2e35f7c8e81c7cebcd674..56720646caeacd6245234ca350ed17e53a675fe2 100644 (file)
@@ -19,6 +19,8 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#include <sys/socket.h>
+
 #include "dns-type.h"
 #include "string-util.h"
 
@@ -183,6 +185,23 @@ bool dns_type_is_obsolete(uint16_t type) {
                       DNS_TYPE_NULL);
 }
 
+int dns_type_to_af(uint16_t t) {
+        switch (t) {
+
+        case DNS_TYPE_A:
+                return AF_INET;
+
+        case DNS_TYPE_AAAA:
+                return AF_INET6;
+
+        case DNS_TYPE_ANY:
+                return AF_UNSPEC;
+
+        default:
+                return -EINVAL;
+        }
+}
+
 const char *dns_class_to_string(uint16_t class) {
 
         switch (class) {