Deleted Added
full compact
getnetbydns.c (145626) getnetbydns.c (146244)
1/*-
2 * Copyright (c) 1985, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 48 unchanged lines hidden (view full) ---

57 * purpose with or without fee is hereby granted, provided that the above
58 * copyright notice and this permission notice appear in all copies.
59 */
60
61#if defined(LIBC_SCCS) && !defined(lint)
62static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
63#endif /* LIBC_SCCS and not lint */
64#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1985, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 48 unchanged lines hidden (view full) ---

57 * purpose with or without fee is hereby granted, provided that the above
58 * copyright notice and this permission notice appear in all copies.
59 */
60
61#if defined(LIBC_SCCS) && !defined(lint)
62static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
63#endif /* LIBC_SCCS and not lint */
64#include <sys/cdefs.h>
65__FBSDID("$FreeBSD: head/lib/libc/net/getnetbydns.c 145626 2005-04-28 15:32:55Z ume $");
65__FBSDID("$FreeBSD: head/lib/libc/net/getnetbydns.c 146244 2005-05-15 20:15:15Z ume $");
66
67#include <sys/param.h>
68#include <sys/socket.h>
69#include <netinet/in.h>
70#include <arpa/inet.h>
71#include <arpa/nameser.h>
72
73#include <errno.h>

--- 180 unchanged lines hidden (view full) ---

254 errno = ENOBUFS;
255 return -1;
256 }
257 ipreverse(in, aux);
258 ne->n_net = inet_network(aux);
259 break;
260 }
261 ne->n_aliases++;
66
67#include <sys/param.h>
68#include <sys/socket.h>
69#include <netinet/in.h>
70#include <arpa/inet.h>
71#include <arpa/nameser.h>
72
73#include <errno.h>

--- 180 unchanged lines hidden (view full) ---

254 errno = ENOBUFS;
255 return -1;
256 }
257 ipreverse(in, aux);
258 ne->n_net = inet_network(aux);
259 break;
260 }
261 ne->n_aliases++;
262#if __LONG_BIT == 64
263 ne->__n_pad0 = 0; /* ABI compatibility */
264#endif
262 return 0;
263 }
264 h_errno = TRY_AGAIN;
265 return -1;
266}
267
268int
269_dns_getnetbyaddr(void *rval, void *cb_data, va_list ap)
270{
265 return 0;
266 }
267 h_errno = TRY_AGAIN;
268 return -1;
269}
270
271int
272_dns_getnetbyaddr(void *rval, void *cb_data, va_list ap)
273{
271 unsigned long net;
274 uint32_t net;
272 int net_type;
273 struct netent *ne;
274 struct netent_data *ned;
275 unsigned int netbr[4];
276 int nn, anslen, error;
277 querybuf *buf;
278 char qbuf[MAXDNAME];
275 int net_type;
276 struct netent *ne;
277 struct netent_data *ned;
278 unsigned int netbr[4];
279 int nn, anslen, error;
280 querybuf *buf;
281 char qbuf[MAXDNAME];
279 unsigned long net2;
282 uint32_t net2;
280
283
281 net = va_arg(ap, unsigned long);
284 net = va_arg(ap, uint32_t);
282 net_type = va_arg(ap, int);
283 ne = va_arg(ap, struct netent *);
284 ned = va_arg(ap, struct netent_data *);
285
286 if (net_type != AF_INET)
287 return NS_UNAVAIL;
288
289 for (nn = 4, net2 = net; net2; net2 >>= 8)

--- 32 unchanged lines hidden (view full) ---

322 if (_res.options & RES_DEBUG)
323 printf("res_search static buffer too small\n");
324#endif
325 return NS_UNAVAIL;
326 }
327 error = getnetanswer(buf, anslen, BYADDR, ne, ned);
328 free(buf);
329 if (error == 0) {
285 net_type = va_arg(ap, int);
286 ne = va_arg(ap, struct netent *);
287 ned = va_arg(ap, struct netent_data *);
288
289 if (net_type != AF_INET)
290 return NS_UNAVAIL;
291
292 for (nn = 4, net2 = net; net2; net2 >>= 8)

--- 32 unchanged lines hidden (view full) ---

325 if (_res.options & RES_DEBUG)
326 printf("res_search static buffer too small\n");
327#endif
328 return NS_UNAVAIL;
329 }
330 error = getnetanswer(buf, anslen, BYADDR, ne, ned);
331 free(buf);
332 if (error == 0) {
330 unsigned u_net = net; /* maybe net should be unsigned ? */
331
332 /* Strip trailing zeros */
333 /* Strip trailing zeros */
333 while ((u_net & 0xff) == 0 && u_net != 0)
334 u_net >>= 8;
335 ne->n_net = u_net;
334 while ((net & 0xff) == 0 && net != 0)
335 net >>= 8;
336 ne->n_net = net;
337#if __LONG_BIT == 64
338 ne->__n_pad0 = 0; /* ABI compatibility */
339#endif
336 return NS_SUCCESS;
337 }
338 return NS_NOTFOUND;
339}
340
341int
342_dns_getnetbyname(void *rval, void *cb_data, va_list ap)
343{

--- 56 unchanged lines hidden ---
340 return NS_SUCCESS;
341 }
342 return NS_NOTFOUND;
343}
344
345int
346_dns_getnetbyname(void *rval, void *cb_data, va_list ap)
347{

--- 56 unchanged lines hidden ---