|
3 | 3 | * is for IP V4 CIDR notation, but prepared for V6: just
|
4 | 4 | * add the necessary bits where the comments indicate.
|
5 | 5 | *
|
6 |
| - * $Id: inet.c,v 1.5 1998/10/17 04:08:40 momjian Exp $ |
| 6 | + * $Id: inet.c,v 1.6 1998/10/20 23:03:19 momjian Exp $ |
7 | 7 | */
|
8 | 8 |
|
9 | 9 | #include <sys/types.h>
|
@@ -312,115 +312,6 @@ inet_masklen(inet *ip)
|
312 | 312 | return ip_bits(ip);
|
313 | 313 | }
|
314 | 314 |
|
315 |
| -text * |
316 |
| -inet_host(inet *ip) |
317 |
| -{ |
318 |
| - char *dst, |
319 |
| - tmp[sizeof("255.255.255.255/32")]; |
320 |
| - |
321 |
| - if (ip_family(ip) == AF_INET) |
322 |
| - { |
323 |
| -#ifdef BAD |
324 |
| - /* It's an IP V4 address: */ |
325 |
| - if (inet_cidr_ntop(AF_INET, &ip_v4addr(ip), 4, -1, |
326 |
| - tmp, sizeof(tmp)) < 0) |
327 |
| - { |
328 |
| - elog(ERROR, "unable to print host (%s)", strerror(errno)); |
329 |
| - return (NULL); |
330 |
| - } |
331 |
| -#endif |
332 |
| - } |
333 |
| - else |
334 |
| - { |
335 |
| - /* Go for an IPV6 address here, before faulting out: */ |
336 |
| - elog(ERROR, "unknown address family (%d)", ip_family(ip)); |
337 |
| - return (NULL); |
338 |
| - } |
339 |
| - dst = palloc(strlen(tmp) + 1); |
340 |
| - if (dst == NULL) |
341 |
| - { |
342 |
| - elog(ERROR, "unable to allocate memory in inet_out()"); |
343 |
| - return (NULL); |
344 |
| - } |
345 |
| - strcpy(dst, tmp); |
346 |
| - return (dst); |
347 |
| - |
348 |
| -} |
349 |
| - |
350 |
| -text * |
351 |
| -inet_network_without_bits(inet *ip) |
352 |
| -{ |
353 |
| - char *dst, |
354 |
| - tmp[sizeof("255.255.255.255/32")]; |
355 |
| - |
356 |
| - if (ip_family(ip) == AF_INET) |
357 |
| - { |
358 |
| - /* It's an IP V4 address: */ |
359 |
| - int addr = ip_v4addr(ip) & (-1 << (32 - ip_bits(ip))); |
360 |
| -#ifdef BAD |
361 |
| - |
362 |
| - if (inet_cidr_ntop(AF_INET, &addr, (int)(ip_bits(ip)/8), -1, |
363 |
| - tmp, sizeof(tmp)) < 0) |
364 |
| - { |
365 |
| - elog(ERROR, "unable to print address (%s)", strerror(errno)); |
366 |
| - return (NULL); |
367 |
| - } |
368 |
| -#endif |
369 |
| - } |
370 |
| - else |
371 |
| - { |
372 |
| - /* Go for an IPV6 address here, before faulting out: */ |
373 |
| - elog(ERROR, "unknown address family (%d)", ip_family(ip)); |
374 |
| - return (NULL); |
375 |
| - } |
376 |
| - dst = palloc(strlen(tmp) + 1); |
377 |
| - if (dst == NULL) |
378 |
| - { |
379 |
| - elog(ERROR, "unable to allocate memory in inet_out()"); |
380 |
| - return (NULL); |
381 |
| - } |
382 |
| - strcpy(dst, tmp); |
383 |
| - return (dst); |
384 |
| - |
385 |
| -} |
386 |
| - |
387 |
| -text * |
388 |
| -inet_network_with_bits(inet *ip) |
389 |
| -{ |
390 |
| - char *dst, |
391 |
| - tmp[sizeof("255.255.255.255/32")]; |
392 |
| - |
393 |
| - if (ip_family(ip) == AF_INET) |
394 |
| - { |
395 |
| - /* It's an IP V4 address: */ |
396 |
| - int addr = ip_v4addr(ip) & (-1 << (32 - ip_bits(ip))); |
397 |
| -#ifdef BAD |
398 |
| - |
399 |
| - if (inet_cidr_ntop(AF_INET, &addr, (int)(ip_bits(ip)/8), |
400 |
| - ip_bits(ip), tmp, sizeof(tmp)) < 0) |
401 |
| - { |
402 |
| - elog(ERROR, "unable to print address (%s)", strerror(errno)); |
403 |
| - return (NULL); |
404 |
| - } |
405 |
| -#endif |
406 |
| - } |
407 |
| - else |
408 |
| - { |
409 |
| - /* Go for an IPV6 address here, before faulting out: */ |
410 |
| - elog(ERROR, "unknown address family (%d)", ip_family(ip)); |
411 |
| - return (NULL); |
412 |
| - } |
413 |
| - dst = palloc(strlen(tmp) + 1); |
414 |
| - if (dst == NULL) |
415 |
| - { |
416 |
| - elog(ERROR, "unable to allocate memory in inet_out()"); |
417 |
| - return (NULL); |
418 |
| - } |
419 |
| - strcpy(dst, tmp); |
420 |
| - return (dst); |
421 |
| - |
422 |
| -} |
423 |
| - |
424 | 315 | text *
|
425 | 316 | inet_broadcast(inet *ip)
|
426 | 317 | {
|
|
0 commit comments