[asterisk-commits] file: branch group/dns_srv r433302 - /team/group/dns_srv/main/dns_srv.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Mar 23 10:14:59 CDT 2015
Author: file
Date: Mon Mar 23 10:14:57 2015
New Revision: 433302
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=433302
Log:
Clean up code, actually put hostname in, and lessen the ntohs.
Modified:
team/group/dns_srv/main/dns_srv.c
Modified: team/group/dns_srv/main/dns_srv.c
URL: http://svnview.digium.com/svn/asterisk/team/group/dns_srv/main/dns_srv.c?view=diff&rev=433302&r1=433301&r2=433302
==============================================================================
--- team/group/dns_srv/main/dns_srv.c (original)
+++ team/group/dns_srv/main/dns_srv.c Mon Mar 23 10:14:57 2015
@@ -47,14 +47,13 @@
char *srv_offset;
char *srv_search_base = (char *)query->result->answer;
size_t remaining_size = query->result->answer_size;
- char *buffer;
size_t remaining = size;
struct ast_dns_srv_record *srv;
- unsigned short priority;
- unsigned short weight;
- unsigned short port;
+ uint16_t priority;
+ uint16_t weight;
+ uint16_t port;
int host_size;
- char host[256] = "";
+ char host[NI_MAXHOST] = "";
while (1) {
srv_offset = memchr(srv_search_base, data[0], remaining_size);
@@ -108,16 +107,15 @@
return NULL;
}
- srv->priority = ntohs(priority);
- srv->weight = ntohs(weight);
- srv->port = ntohs(port);
-
- buffer = srv->data;
- strcpy(buffer, host); /* SAFE */
- buffer[host_size] = '\0';
- buffer += host_size + 1;
-
- srv->generic.data_ptr = buffer;
+ srv->priority = priority;
+ srv->weight = weight;
+ srv->port = port;
+
+ srv->host = srv->data + size;
+ strcpy((char *)srv->host, host); /* SAFE */
+ ((char *)srv->host)[host_size] = '\0';
+
+ srv->generic.data_ptr = srv->data;
return (struct ast_dns_record *)srv;
}
More information about the asterisk-commits
mailing list