PostgreSQL Source Code: src/backend/utils/adt/network.c Source File (original) (raw)
1
2
3
4
5
6
7
8
10
14
26#include "utils/fmgroids.h"
31
32
33
34
35
36
37
38
39
40#define ABBREV_BITS_INET4_NETMASK_SIZE 6
41#define ABBREV_BITS_INET4_SUBNET 25
42
43
51
58 int indexarg,
59 Oid funcid,
60 Oid opfamily);
64 Oid opfamily);
65static bool addressOK(unsigned char *a, int bits, int family);
67
68
69
70
71
74{
75 int bits;
77
79
80
81
82
83
84
85
88 else
90
96
97 errmsg("invalid input syntax for type %s: \"%s\"",
98 is_cidr ? "cidr" : "inet", src)));
99
100
101
102
104 {
108 errmsg("invalid cidr value: \"%s\"", src),
109 errdetail("Value has bits set to right of mask.")));
110 }
111
114
115 return dst;
116}
117
125
133
134
135
136
137
138static char *
140{
141 char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
142 char *dst;
144
146 tmp, sizeof(tmp));
150 errmsg("could not format inet value: %m")));
151
152
154 {
157 }
158
160}
161
169
177
178
179
180
181
182
183
184
185
186
187
188
191{
194 int bits;
195 int nb,
196 i;
197
198
200
206
207 errmsg("invalid address family in external \"%s\" value",
208 is_cidr ? "cidr" : "inet")));
213
214 errmsg("invalid bits in external \"%s\" value",
215 is_cidr ? "cidr" : "inet")));
222
223 errmsg("invalid length in external \"%s\" value",
224 is_cidr ? "cidr" : "inet")));
225
229
230
231
232
234 {
238 errmsg("invalid external \"cidr\" value"),
239 errdetail("Value has bits set to right of mask.")));
240 }
241
243
244 return addr;
245}
246
254
262
263
264
265
266
269{
272 int nb,
273 i;
274
285}
286
294
302
303
306{
308 int bits;
309
311
312
313 if ((bits < 0) || (bits > ip_maxbits(src)))
314 elog(ERROR, "invalid inet bit length: %d", bits);
315
317}
318
321{
325
326 if (bits == -1)
328
329 if ((bits < 0) || (bits > ip_maxbits(src)))
332 errmsg("invalid mask length: %d", bits)));
333
334
337
339
341}
342
345{
348
349 if (bits == -1)
351
352 if ((bits < 0) || (bits > ip_maxbits(src)))
355 errmsg("invalid mask length: %d", bits)));
356
358}
359
360
361
362
365{
367
370
371 if (bits > 0)
372 {
374
375
377
378
379 if (bits % 8)
380 ip_addr(dst)[bits / 8] &= ~(0xFF >> (bits % 8));
381 }
382
383
385
386 return dst;
387}
388
389
390
391
392
393
394
395
396
397
398
399
402{
404 {
405 int order;
406
409 if (order != 0)
410 return order;
412 if (order != 0)
413 return order;
415 }
416
418}
419
428
429
430
431
434{
436
439
441 {
444
446
448 uss->input_count = 0;
449 uss->estimating = true;
451
453
458
460 }
461
463}
464
465
466
467
468static int
476
477
478
479
480
481
482
483static bool
485{
487 double abbr_card;
488
490 return false;
491
493
494
495
496
497
498
499
500 if (abbr_card > 100000.0)
501 {
504 "network_abbrev: estimation ends at cardinality %f"
506 abbr_card, uss->input_count, memtupcount);
507 uss->estimating = false;
508 return false;
509 }
510
511
512
513
514
515
516
518 {
521 "network_abbrev: aborting abbreviation at cardinality %f"
522 " below threshold %f after " INT64_FORMAT " values (%d rows)",
523 abbr_card, uss->input_count / 2000.0 + 0.5, uss->input_count,
524 memtupcount);
525 return true;
526 }
527
530 "network_abbrev: cardinality %f after " INT64_FORMAT
531 " values (%d rows)", abbr_card, uss->input_count, memtupcount);
532
533 return false;
534}
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
594{
602
605
606
607
608
609
610
611
612
613
614
616 {
618
620
621
622#ifndef WORDS_BIGENDIAN
624#else
626#endif
627
628
630 }
631 else
632 {
634
635
637
638
640 }
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
659
662 {
663
666 }
668 {
669
672 }
673 else
674 {
675
678 }
679
681 {
682
683
684
685
688
689
690
691
692
693
694
695
696
697
698
701
702
704
705
707
708
709
710
711
712
713
714
715
716
717
720
721
722
723
724
726 }
727 else
728 {
729
730
731
732
733
735 }
736
737 uss->input_count += 1;
738
739
740 if (uss->estimating)
741 {
743
745
747 }
748
749 return res;
750}
751
752
753
754
763
772
781
790
799
808
809
810
811
823
835
836
837
838
848
858
859
860
861
864{
867
869 {
872 }
873
875}
876
879{
882
884 {
887 }
888
890}
891
894{
897
899 {
902 }
903
905}
906
909{
912
914 {
917 }
918
920}
921
924{
927
929 {
932 }
933
935}
936
937
938
939
942{
945
947 {
948
950
952 {
954
956 ret = (Node *)
959 req->indexarg,
960 req->funcid,
961 req->opfamily);
962 }
964 {
966
968 ret = (Node *)
971 req->indexarg,
972 req->funcid,
973 req->opfamily);
974 }
975 }
976
978}
979
980
981
982
983
984
985
986
990 int indexarg,
991 Oid funcid,
992 Oid opfamily)
993{
994 switch (funcid)
995 {
997
998 if (indexarg != 0)
999 return NIL;
1001
1003
1004 if (indexarg != 0)
1005 return NIL;
1007
1009
1010 if (indexarg != 1)
1011 return NIL;
1013
1015
1016 if (indexarg != 1)
1017 return NIL;
1019
1020 default:
1021
1022
1023
1024
1025
1026
1027 return NIL;
1028 }
1029}
1030
1031
1032
1033
1034
1035static List *
1039 Oid opfamily)
1040{
1041 List *result;
1049
1050
1051
1052
1053
1054
1055
1056
1059 return NIL;
1061
1062
1063
1064
1065
1068 return NIL;
1069
1071
1077 false, false),
1080
1081
1082
1085 return NIL;
1086
1088
1094 false, false),
1096 result = lappend(result, expr);
1097
1098 return result;
1099}
1100
1101
1102
1103
1104
1107{
1109 char *ptr;
1110 char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
1111
1112
1114 tmp, sizeof(tmp)) == NULL)
1117 errmsg("could not format inet value: %m")));
1118
1119
1120 if ((ptr = strchr(tmp, '/')) != NULL)
1121 *ptr = '\0';
1122
1124}
1125
1126
1127
1128
1129
1130
1133{
1135 int len;
1136 char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
1137
1139 tmp, sizeof(tmp)) == NULL)
1142 errmsg("could not format inet value: %m")));
1143
1144
1146 {
1149 }
1150
1152}
1153
1156{
1158 char *dst;
1159 char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
1160
1163
1167 errmsg("could not format inet value: %m")));
1168
1170}
1171
1174{
1176 char *dst;
1177 char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
1178
1181
1185 errmsg("could not format cidr value: %m")));
1186
1188}
1189
1197
1200{
1202
1204 {
1207 break;
1210 break;
1211 default:
1213 break;
1214 }
1215}
1216
1219{
1222 int byte;
1223 int bits;
1225 unsigned char mask;
1226 unsigned char *a,
1227 *b;
1228
1229
1231
1236
1237 for (byte = 0; byte < maxbytes; byte++)
1238 {
1239 if (bits >= 8)
1240 {
1241 mask = 0x00;
1242 bits -= 8;
1243 }
1244 else if (bits == 0)
1245 mask = 0xff;
1246 else
1247 {
1248 mask = 0xff >> bits;
1249 bits = 0;
1250 }
1251
1252 b[byte] = a[byte] | mask;
1253 }
1254
1258
1260}
1261
1264{
1267 int byte;
1268 int bits;
1269 unsigned char mask;
1270 unsigned char *a,
1271 *b;
1272
1273
1275
1279
1280 byte = 0;
1281
1282 while (bits)
1283 {
1284 if (bits >= 8)
1285 {
1286 mask = 0xff;
1287 bits -= 8;
1288 }
1289 else
1290 {
1291 mask = 0xff << (8 - bits);
1292 bits = 0;
1293 }
1294
1295 b[byte] = a[byte] & mask;
1296 byte++;
1297 }
1298
1302
1304}
1305
1308{
1311 int byte;
1312 int bits;
1313 unsigned char mask;
1314 unsigned char *b;
1315
1316
1318
1321
1322 byte = 0;
1323
1324 while (bits)
1325 {
1326 if (bits >= 8)
1327 {
1328 mask = 0xff;
1329 bits -= 8;
1330 }
1331 else
1332 {
1333 mask = 0xff << (8 - bits);
1334 bits = 0;
1335 }
1336
1337 b[byte] = mask;
1338 byte++;
1339 }
1340
1344
1346}
1347
1350{
1353 int byte;
1354 int bits;
1356 unsigned char mask;
1357 unsigned char *b;
1358
1359
1361
1365
1367
1368 while (bits)
1369 {
1370 if (bits >= 8)
1371 {
1372 mask = 0xff;
1373 bits -= 8;
1374 }
1375 else
1376 {
1377 mask = 0xff >> (8 - bits);
1378 bits = 0;
1379 }
1380
1381 b[byte] = mask;
1382 byte--;
1383 }
1384
1388
1390}
1391
1392
1393
1394
1395
1404
1405
1406
1407
1410{
1413 int commonbits;
1414
1418 errmsg("cannot merge addresses from different families")));
1419
1422
1424}
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434double
1436{
1437 switch (typid)
1438 {
1441 {
1443 int len;
1444 double res;
1445 int i;
1446
1447
1448
1449
1451 len = 4;
1452 else
1453 len = 5;
1454
1456 for (i = 0; i < len; i++)
1457 {
1458 res *= 256;
1460 }
1461 return res;
1462 }
1464 {
1466 double res;
1467
1468 res = (mac->a << 16) | (mac->b << 8) | (mac->c);
1469 res *= 256 * 256 * 256;
1470 res += (mac->d << 16) | (mac->e << 8) | (mac->f);
1471 return res;
1472 }
1474 {
1476 double res;
1477
1478 res = (mac->a << 24) | (mac->b << 16) | (mac->c << 8) | (mac->d);
1479 res *= ((double) 256) * 256 * 256 * 256;
1480 res += (mac->e << 24) | (mac->f << 16) | (mac->g << 8) | (mac->h);
1481 return res;
1482 }
1483 }
1484
1486 return 0;
1487}
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501int
1502bitncmp(const unsigned char *l, const unsigned char *r, int n)
1503{
1504 unsigned int lb,
1506 int x,
1507 b;
1508
1509 b = n / 8;
1511 if (x || (n % 8) == 0)
1512 return x;
1513
1514 lb = l[b];
1516 for (b = n % 8; b > 0; b--)
1517 {
1519 {
1521 return 1;
1522 return -1;
1523 }
1524 lb <<= 1;
1525 rb <<= 1;
1526 }
1527 return 0;
1528}
1529
1530
1531
1532
1533
1534
1535int
1536bitncommon(const unsigned char *l, const unsigned char *r, int n)
1537{
1538 int byte,
1539 nbits;
1540
1541
1542 nbits = n % 8;
1543
1544
1545 for (byte = 0; byte < n / 8; byte++)
1546 {
1547 if (l[byte] != r[byte])
1548 {
1549
1550 nbits = 7;
1551 break;
1552 }
1553 }
1554
1555
1556 if (nbits != 0)
1557 {
1558
1559 unsigned int diff = l[byte] ^ r[byte];
1560
1561
1562 while ((diff >> (8 - nbits)) != 0)
1563 nbits--;
1564 }
1565
1566 return (8 * byte) + nbits;
1567}
1568
1569
1570
1571
1572
1573static bool
1575{
1576 int byte;
1577 int nbits;
1580 unsigned char mask;
1581
1583 {
1586 }
1587 else
1588 {
1591 }
1593
1595 return true;
1596
1597 byte = bits / 8;
1598
1599 nbits = bits % 8;
1600 mask = 0xff;
1601 if (bits != 0)
1602 mask >>= nbits;
1603
1605 {
1606 if ((a[byte] & mask) != 0)
1607 return false;
1608 mask = 0xff;
1609 byte++;
1610 }
1611
1612 return true;
1613}
1614
1615
1616
1617
1618
1619
1620
1621
1627
1628
1629
1630
1631
1632
1633
1634
1635
1643
1644
1645
1646
1647
1650{
1653 int ret;
1654
1657
1658 switch (port->raddr.addr.ss_family)
1659 {
1662 break;
1663 default:
1665 }
1666
1667 remote_host[0] = '\0';
1668
1670 remote_host, sizeof(remote_host),
1673 if (ret != 0)
1675
1677
1679}
1680
1681
1682
1683
1684
1687{
1690 int ret;
1691
1694
1695 switch (port->raddr.addr.ss_family)
1696 {
1699 break;
1700 default:
1702 }
1703
1704 remote_port[0] = '\0';
1705
1708 remote_port, sizeof(remote_port),
1710 if (ret != 0)
1712
1714}
1715
1716
1717
1718
1719
1722{
1725 int ret;
1726
1729
1730 switch (port->laddr.addr.ss_family)
1731 {
1734 break;
1735 default:
1737 }
1738
1739 local_host[0] = '\0';
1740
1742 local_host, sizeof(local_host),
1745 if (ret != 0)
1747
1749
1751}
1752
1753
1754
1755
1756
1759{
1762 int ret;
1763
1766
1767 switch (port->laddr.addr.ss_family)
1768 {
1771 break;
1772 default:
1774 }
1775
1777
1782 if (ret != 0)
1784
1786}
1787
1788
1791{
1794
1796
1797 {
1801
1802 while (--nb >= 0)
1804 }
1806
1809
1811}
1812
1813
1816{
1820
1822
1826 errmsg("cannot AND inet values of different sizes")));
1827 else
1828 {
1833
1834 while (--nb >= 0)
1836 }
1838
1841
1843}
1844
1845
1848{
1852
1854
1858 errmsg("cannot OR inet values of different sizes")));
1859 else
1860 {
1865
1866 while (--nb >= 0)
1868 }
1870
1873
1875}
1876
1877
1878static inet *
1880{
1882
1884
1885 {
1890
1891 while (--nb >= 0)
1892 {
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1908 }
1909
1910
1911
1912
1913
1914
1919 errmsg("result is out of range")));
1920 }
1921
1925
1926 return dst;
1927}
1928
1929
1938
1939
1948
1949
1952{
1956
1960 errmsg("cannot subtract inet values of different sizes")));
1961 else
1962 {
1963
1964
1965
1966
1967
1968
1970 int byte = 0;
1974
1975 while (--nb >= 0)
1976 {
1978
1981 if (byte < sizeof(int64))
1982 {
1984 }
1985 else
1986 {
1987
1988
1989
1990
1991
1992 if ((res < 0) ? (lobyte != 0xFF) : (lobyte != 0))
1995 errmsg("result is out of range")));
1996 }
1998 byte++;
1999 }
2000
2001
2002
2003
2004
2005 if (carry == 0 && byte < sizeof(int64))
2006 res |= ((uint64) (int64) -1) << (byte * 8);
2007 }
2008
2010}
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027void
2029{
2031 {
2033
2034 if (pct)
2035 *pct = '\0';
2036 }
2037}
#define IS_HIGHBIT_SET(ch)
#define Assert(condition)
int errcode(int sqlerrcode)
#define ereturn(context, dummy_value,...)
int errdetail(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
#define palloc_object(type)
#define palloc0_object(type)
#define PG_RETURN_BYTEA_P(x)
#define DirectFunctionCall2(func, arg1, arg2)
#define PG_GETARG_POINTER(n)
#define PG_RETURN_CSTRING(x)
#define PG_RETURN_INT64(x)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_CSTRING(n)
#define PG_GETARG_INT64(n)
#define PG_RETURN_TEXT_P(x)
#define PG_RETURN_INT32(x)
#define PG_GETARG_INT32(n)
#define PG_RETURN_DATUM(x)
#define PG_RETURN_POINTER(x)
#define PG_RETURN_BOOL(x)
static Datum hash_uint32(uint32 k)
static Datum hash_any_extended(const unsigned char *k, int keylen, uint64 seed)
static Datum hash_any(const unsigned char *k, int keylen)
static const FormData_pg_attribute a1
static const FormData_pg_attribute a2
void initHyperLogLog(hyperLogLogState *cState, uint8 bwidth)
double estimateHyperLogLog(hyperLogLogState *cState)
void addHyperLogLog(hyperLogLogState *cState, uint32 hash)
char * pg_inet_cidr_ntop(int af, const void *src, int bits, char *dst, size_t size)
int pg_inet_net_pton(int af, const char *src, void *dst, size_t size)
Datum int4in(PG_FUNCTION_ARGS)
int pg_getnameinfo_all(const struct sockaddr_storage *addr, int salen, char *node, int nodelen, char *service, int servicelen, int flags)
List * lappend(List *list, void *datum)
Oid get_opfamily_member_for_cmptype(Oid opfamily, Oid lefttype, Oid righttype, CompareType cmptype)
Expr * make_opclause(Oid opno, Oid opresulttype, bool opretset, Expr *leftop, Expr *rightop, Oid opcollid, Oid inputcollid)
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
char * pstrdup(const char *in)
Datum inet_server_addr(PG_FUNCTION_ARGS)
Datum hashinet(PG_FUNCTION_ARGS)
static List * match_network_subset(Node *leftop, Node *rightop, bool is_eq, Oid opfamily)
static int network_fast_cmp(Datum x, Datum y, SortSupport ssup)
Datum inet_send(PG_FUNCTION_ARGS)
static List * match_network_function(Node *leftop, Node *rightop, int indexarg, Oid funcid, Oid opfamily)
void clean_ipv6_addr(int addr_family, char *addr)
Datum cidr_out(PG_FUNCTION_ARGS)
Datum inet_client_addr(PG_FUNCTION_ARGS)
int bitncommon(const unsigned char *l, const unsigned char *r, int n)
inet * cidr_set_masklen_internal(const inet *src, int bits)
Datum network_hostmask(PG_FUNCTION_ARGS)
Datum network_scan_last(Datum in)
Datum network_overlap(PG_FUNCTION_ARGS)
static inet * network_in(char *src, bool is_cidr, Node *escontext)
Datum inet_to_cidr(PG_FUNCTION_ARGS)
Datum inet_abbrev(PG_FUNCTION_ARGS)
Datum inetand(PG_FUNCTION_ARGS)
Datum network_subset_support(PG_FUNCTION_ARGS)
Datum network_sup(PG_FUNCTION_ARGS)
Datum network_host(PG_FUNCTION_ARGS)
Datum network_supeq(PG_FUNCTION_ARGS)
Datum inetpl(PG_FUNCTION_ARGS)
Datum cidr_abbrev(PG_FUNCTION_ARGS)
Datum inet_server_port(PG_FUNCTION_ARGS)
static bool addressOK(unsigned char *a, int bits, int family)
int bitncmp(const unsigned char *l, const unsigned char *r, int n)
Datum network_netmask(PG_FUNCTION_ARGS)
Datum network_broadcast(PG_FUNCTION_ARGS)
Datum network_smaller(PG_FUNCTION_ARGS)
Datum inetor(PG_FUNCTION_ARGS)
Datum inet_set_masklen(PG_FUNCTION_ARGS)
static inet * network_recv(StringInfo buf, bool is_cidr)
Datum inet_in(PG_FUNCTION_ARGS)
Datum inetnot(PG_FUNCTION_ARGS)
Datum network_ge(PG_FUNCTION_ARGS)
#define ABBREV_BITS_INET4_SUBNET
Datum inetmi_int8(PG_FUNCTION_ARGS)
Datum inet_same_family(PG_FUNCTION_ARGS)
double convert_network_to_scalar(Datum value, Oid typid, bool *failure)
Datum hashinetextended(PG_FUNCTION_ARGS)
Datum cidr_send(PG_FUNCTION_ARGS)
Datum network_sub(PG_FUNCTION_ARGS)
Datum network_ne(PG_FUNCTION_ARGS)
#define ABBREV_BITS_INET4_NETMASK_SIZE
Datum network_le(PG_FUNCTION_ARGS)
Datum network_sortsupport(PG_FUNCTION_ARGS)
Datum cidr_recv(PG_FUNCTION_ARGS)
Datum inet_client_port(PG_FUNCTION_ARGS)
static inet * internal_inetpl(inet *ip, int64 addend)
Datum inetmi(PG_FUNCTION_ARGS)
Datum cidr_set_masklen(PG_FUNCTION_ARGS)
Datum network_family(PG_FUNCTION_ARGS)
Datum network_show(PG_FUNCTION_ARGS)
static int32 network_cmp_internal(inet *a1, inet *a2)
Datum network_lt(PG_FUNCTION_ARGS)
static bytea * network_send(inet *addr, bool is_cidr)
Datum network_eq(PG_FUNCTION_ARGS)
static char * network_out(inet *src, bool is_cidr)
Datum network_subeq(PG_FUNCTION_ARGS)
Datum network_gt(PG_FUNCTION_ARGS)
Datum inet_merge(PG_FUNCTION_ARGS)
Datum inet_recv(PG_FUNCTION_ARGS)
Datum network_cmp(PG_FUNCTION_ARGS)
Datum network_larger(PG_FUNCTION_ARGS)
Datum network_network(PG_FUNCTION_ARGS)
static Datum network_abbrev_convert(Datum original, SortSupport ssup)
static bool network_abbrev_abort(int memtupcount, SortSupport ssup)
Datum network_masklen(PG_FUNCTION_ARGS)
Datum network_scan_first(Datum in)
Datum inet_out(PG_FUNCTION_ARGS)
Datum cidr_in(PG_FUNCTION_ARGS)
static bool is_opclause(const void *clause)
static bool is_funcclause(const void *clause)
#define IsA(nodeptr, _type_)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static uint32 pg_bswap32(uint32 x)
#define DatumBigEndianToNative(x)
static int list_length(const List *l)
static char buf[DEFAULT_XLOG_SEG_SIZE]
char * pg_inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size)
static uint32 DatumGetUInt32(Datum X)
static uint64 DatumGetUInt64(Datum X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
void pq_begintypsend(StringInfo buf)
int pq_getmsgbyte(StringInfo msg)
bytea * pq_endtypsend(StringInfo buf)
static void pq_sendbyte(StringInfo buf, uint8 byt)
struct SortSupportData * SortSupport
struct StringInfoData * StringInfo
int(* comparator)(Datum x, Datum y, SortSupport ssup)
Datum(* abbrev_converter)(Datum original, SortSupport ssup)
int(* abbrev_full_comparator)(Datum x, Datum y, SortSupport ssup)
bool(* abbrev_abort)(int memtupcount, SortSupport ssup)
hyperLogLogState abbr_card
int ssup_datum_unsigned_cmp(Datum x, Datum y, SortSupport ssup)
#define PG_RETURN_INET_P(x)
static macaddr8 * DatumGetMacaddr8P(Datum X)
static inet * DatumGetInetPP(Datum X)
#define SET_INET_VARSIZE(dst)
#define PG_GETARG_INET_PP(n)
#define ip_family(inetptr)
static macaddr * DatumGetMacaddrP(Datum X)
#define ip_addrsize(inetptr)
#define ip_maxbits(inetptr)
static Size VARSIZE_ANY(const void *PTR)
static char * VARDATA_ANY(const void *PTR)
text * cstring_to_text(const char *s)