service: simplify and remove more code duplication
authorFelix Fietkau <nbd@openwrt.org>
Mon, 9 Jun 2014 21:14:53 +0000 (23:14 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 9 Jun 2014 21:14:53 +0000 (23:14 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
service.c

index f60431d350d27c708ed9b32373f4000149914e86..1cf50e3b8119f4e9177c768a46e9bb16c5076c8f 100644 (file)
--- a/service.c
+++ b/service.c
@@ -94,19 +94,6 @@ service_add_ptr(const char *host)
        dns_add_answer(TYPE_PTR, buffer, len);
 }
 
-static void
-service_send_a(struct interface *iface)
-{
-       unsigned char buffer[MAX_NAME_LEN];
-       char *host = service_name("local");
-       int len = dn_comp(host, buffer, MAX_NAME_LEN, NULL, NULL);
-
-       if (len < 1)
-               return;
-
-       dns_add_answer(TYPE_A, (uint8_t *) &iface->v4_addr.s_addr, 4);
-}
-
 static void
 service_add_srv(struct service *s)
 {
@@ -151,7 +138,7 @@ service_reply_a(struct interface *iface, int type)
                return;
 
        dns_init_answer();
-       service_send_a(iface);
+       dns_add_answer(TYPE_A, (uint8_t *) &iface->v4_addr.s_addr, 4);
        dns_send_answer(iface, service_name("local"));
 }
 
@@ -186,9 +173,7 @@ service_reply(struct interface *iface, const char *match)
        if (match)
                return;
 
-       dns_init_answer();
-       service_send_a(iface);
-       dns_send_answer(iface, service_name("local"));
+       service_reply_a(iface, TYPE_A);
 }
 
 void