aboutsummaryrefslogtreecommitdiff
path: root/networking/dnsd.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-05-29 06:43:55 +0000
committerRob Landley <rob@landley.net>2006-05-29 06:43:55 +0000
commita6e131dab39ee67522687a56b39ed815b9ae15ec (patch)
tree1ca2de8c070d79096f6db1a4a614d00a0ef7800d /networking/dnsd.c
parentbba7f08d2788bc9bc30a7a60fdfd873a73fead9a (diff)
downloadbusybox-w32-a6e131dab39ee67522687a56b39ed815b9ae15ec.tar.gz
busybox-w32-a6e131dab39ee67522687a56b39ed815b9ae15ec.tar.bz2
busybox-w32-a6e131dab39ee67522687a56b39ed815b9ae15ec.zip
Size reductions, mostly switching things to use libbb functions.
Diffstat (limited to 'networking/dnsd.c')
-rw-r--r--networking/dnsd.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/networking/dnsd.c b/networking/dnsd.c
index b9d022170..58a8fc1d2 100644
--- a/networking/dnsd.c
+++ b/networking/dnsd.c
@@ -82,8 +82,7 @@ static uint32_t ttl = DEFAULT_TTL;
82/* 82/*
83 * Convert host name from C-string to dns length/string. 83 * Convert host name from C-string to dns length/string.
84 */ 84 */
85static void 85static void convname(char *a, uint8_t *q)
86convname(char *a, uint8_t *q)
87{ 86{
88 int i = (q[0] == '.') ? 0 : 1; 87 int i = (q[0] == '.') ? 0 : 1;
89 for(; i < MAX_HOST_LEN-1 && *q; i++, q++) 88 for(; i < MAX_HOST_LEN-1 && *q; i++, q++)
@@ -95,8 +94,7 @@ convname(char *a, uint8_t *q)
95/* 94/*
96 * Insert length of substrings insetad of dots 95 * Insert length of substrings insetad of dots
97 */ 96 */
98static void 97static void undot(uint8_t * rip)
99undot(uint8_t * rip)
100{ 98{
101 int i = 0, s = 0; 99 int i = 0, s = 0;
102 while(rip[i]) i++; 100 while(rip[i]) i++;
@@ -111,8 +109,7 @@ undot(uint8_t * rip)
111/* 109/*
112 * Append message to log file 110 * Append message to log file
113 */ 111 */
114static void 112static void log_message(char *filename, char *message)
115log_message(char *filename, char *message)
116{ 113{
117 FILE *logfile; 114 FILE *logfile;
118 if (!daemonmode) 115 if (!daemonmode)
@@ -133,8 +130,7 @@ log_message(char *filename, char *message)
133 * converting to a length/string substring for that label. 130 * converting to a length/string substring for that label.
134 */ 131 */
135 132
136static int 133static int getfileentry(FILE * fp, struct dns_entry *s, int verb)
137getfileentry(FILE * fp, struct dns_entry *s, int verb)
138{ 134{
139 unsigned int a,b,c,d; 135 unsigned int a,b,c,d;
140 char *r, *name; 136 char *r, *name;
@@ -168,19 +164,16 @@ restart:
168/* 164/*
169 * Read hostname/IP records from file 165 * Read hostname/IP records from file
170 */ 166 */
171static void 167static void dnsentryinit(int verb)
172dnsentryinit(int verb)
173{ 168{
174 FILE *fp; 169 FILE *fp;
175 struct dns_entry *m, *prev; 170 struct dns_entry *m, *prev;
176 prev = dnsentry = NULL; 171 prev = dnsentry = NULL;
177 172
178 if(!(fp = fopen(fileconf, "r"))) 173 fp = bb_xfopen(fileconf, "r");
179 bb_perror_msg_and_die("open %s",fileconf);
180 174
181 while (1) { 175 while (1) {
182 if(!(m = (struct dns_entry *)malloc(sizeof(struct dns_entry)))) 176 m = xmalloc(sizeof(struct dns_entry));
183 bb_perror_msg_and_die("malloc dns_entry");
184 177
185 m->next = NULL; 178 m->next = NULL;
186 if (getfileentry(fp, m, verb)) 179 if (getfileentry(fp, m, verb))
@@ -199,8 +192,7 @@ dnsentryinit(int verb)
199/* 192/*
200 * Set up UDP socket 193 * Set up UDP socket
201 */ 194 */
202static int 195static int listen_socket(char *iface_addr, int listen_port)
203listen_socket(char *iface_addr, int listen_port)
204{ 196{
205 struct sockaddr_in a; 197 struct sockaddr_in a;
206 char msg[100]; 198 char msg[100];
@@ -228,8 +220,7 @@ listen_socket(char *iface_addr, int listen_port)
228 * Look query up in dns records and return answer if found 220 * Look query up in dns records and return answer if found
229 * qs is the query string, first byte the string length 221 * qs is the query string, first byte the string length
230 */ 222 */
231static int 223static int table_lookup(uint16_t type, uint8_t * as, uint8_t * qs)
232table_lookup(uint16_t type, uint8_t * as, uint8_t * qs)
233{ 224{
234 int i; 225 int i;
235 struct dns_entry *d=dnsentry; 226 struct dns_entry *d=dnsentry;
@@ -269,8 +260,7 @@ table_lookup(uint16_t type, uint8_t * as, uint8_t * qs)
269 * Decode message and generate answer 260 * Decode message and generate answer
270 */ 261 */
271#define eret(s) do { fprintf (stderr, "%s\n", s); return -1; } while (0) 262#define eret(s) do { fprintf (stderr, "%s\n", s); return -1; } while (0)
272static int 263static int process_packet(uint8_t * buf)
273process_packet(uint8_t * buf)
274{ 264{
275 struct dns_head *head; 265 struct dns_head *head;
276 struct dns_prop *qprop; 266 struct dns_prop *qprop;
@@ -367,8 +357,7 @@ process_packet(uint8_t * buf)
367/* 357/*
368 * Exit on signal 358 * Exit on signal
369 */ 359 */
370static void 360static void interrupt(int x)
371interrupt(int x)
372{ 361{
373 unlink(LOCK_FILE); 362 unlink(LOCK_FILE);
374 write(2, "interrupt exiting\n", 18); 363 write(2, "interrupt exiting\n", 18);