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

44typedef struct

45{

47 bool estimating;

48

51

57 Node *rightop,

58 int indexarg,

59 Oid funcid,

60 Oid opfamily);

62 Node *rightop,

63 bool is_eq,

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

86 if (strchr(src, ':') != NULL)

88 else

90

93 if ((bits < 0) || (bits > ip_maxbits(dst)))

95 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),

96

97 errmsg("invalid input syntax for type %s: \"%s\"",

98 is_cidr ? "cidr" : "inet", src)));

99

100

101

102

103 if (is_cidr)

104 {

107 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),

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

120{

122

124}

125

128{

130

132}

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));

147 if (dst == NULL)

149 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),

150 errmsg("could not format inet value: %m")));

151

152

153 if (is_cidr && strchr(tmp, '/') == NULL)

154 {

155 len = strlen(tmp);

157 }

158

160}

161

164{

166

168}

169

172{

174

176}

177

178

179

180

181

182

183

184

185

186

187

188

191{

193 char *addrptr;

194 int bits;

195 int nb,

196 i;

197

198

200

205 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),

206

207 errmsg("invalid address family in external \"%s\" value",

208 is_cidr ? "cidr" : "inet")));

210 if (bits < 0 || bits > ip_maxbits(addr))

212 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),

213

214 errmsg("invalid bits in external \"%s\" value",

215 is_cidr ? "cidr" : "inet")));

221 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),

222

223 errmsg("invalid length in external \"%s\" value",

224 is_cidr ? "cidr" : "inet")));

225

226 addrptr = (char *) ip_addr(addr);

227 for (i = 0; i < nb; i++)

229

230

231

232

233 if (is_cidr)

234 {

237 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),

238 errmsg("invalid external \"cidr\" value"),

239 errdetail("Value has bits set to right of mask.")));

240 }

241

243

244 return addr;

245}

246

249{

251

253}

254

257{

259

261}

262

263

264

265

266

269{

271 char *addrptr;

272 int nb,

273 i;

274

281 addrptr = (char *) ip_addr(addr);

282 for (i = 0; i < nb; i++)

285}

286

289{

291

293}

294

297{

299

301}

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)))

331 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

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)))

354 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

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

422{

425

427}

428

429

430

431

434{

436

439

441 {

444

446

451

453

458

460 }

461

463}

464

465

466

467

468static int

470{

473

475}

476

477

478

479

480

481

482

483static bool

485{

487 double abbr_card;

488

489 if (memtupcount < 10000 || uss->input_count < 10000 || !uss->estimating)

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);

508 return false;

509 }

510

511

512

513

514

515

516

517 if (abbr_card < uss->input_count / 2000.0 + 0.5)

518 {

521 "network_abbrev: aborting abbreviation at cardinality %f"

522 " below threshold %f after " INT64_FORMAT " values (%d rows)",

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{

598 ipaddr_datum,

599 subnet_bitmask,

600 network;

601 int subnet_size;

602

605

606

607

608

609

610

611

612

613

614

616 {

617 uint32 ipaddr_datum32;

618

619 memcpy(&ipaddr_datum32, ip_addr(authoritative), sizeof(uint32));

620

621

622#ifndef WORDS_BIGENDIAN

623 ipaddr_datum = pg_bswap32(ipaddr_datum32);

624#else

625 ipaddr_datum = ipaddr_datum32;

626#endif

627

628

630 }

631 else

632 {

633 memcpy(&ipaddr_datum, ip_addr(authoritative), sizeof(Datum));

634

635

637

638

640 }

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657 subnet_size = ip_maxbits(authoritative) - ip_bits(authoritative);

658 Assert(subnet_size >= 0);

659

661 if (ip_bits(authoritative) == 0)

662 {

663

664 subnet_bitmask = ((Datum) 0) - 1;

665 network = 0;

666 }

668 {

669

670 subnet_bitmask = (((Datum) 1) << subnet_size) - 1;

671 network = ipaddr_datum & ~subnet_bitmask;

672 }

673 else

674 {

675

676 subnet_bitmask = 0;

677 network = ipaddr_datum;

678 }

679

681 {

682

683

684

685

688

689

690

691

692

693

694

695

696

697

698

701

702

704

705

706 subnet = ipaddr_datum & subnet_bitmask;

707

708

709

710

711

712

713

714

715

716

717

720

721

722

723

724

725 res |= network | netmask_size | subnet;

726 }

727 else

728 {

729

730

731

732

733

734 res |= network >> 1;

735 }

736

738

739

741 {

743

745

747 }

748

749 return res;

750}

751

752

753

754

757{

760

762}

763

766{

769

771}

772

775{

778

780}

781

784{

787

789}

790

793{

796

798}

799

802{

805

807}

808

809

810

811

814{

817

820 else

822}

823

826{

829

832 else

834}

835

836

837

838

841{

844

845

847}

848

851{

854

857}

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{

944 Node *ret = NULL;

945

947 {

948

950

952 {

954

956 ret = (Node *)

962 }

964 {

966

968 ret = (Node *)

974 }

975 }

976

978}

979

980

981

982

983

984

985

986

989 Node *rightop,

990 int indexarg,

991 Oid funcid,

992 Oid opfamily)

993{

994 switch (funcid)

995 {

996 case F_NETWORK_SUB:

997

998 if (indexarg != 0)

999 return NIL;

1001

1002 case F_NETWORK_SUBEQ:

1003

1004 if (indexarg != 0)

1005 return NIL;

1007

1008 case F_NETWORK_SUP:

1009

1010 if (indexarg != 1)

1011 return NIL;

1013

1014 case F_NETWORK_SUPEQ:

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 *

1037 Node *rightop,

1038 bool is_eq,

1039 Oid opfamily)

1040{

1041 List *result;

1042 Datum rightopval;

1043 Oid datatype = INETOID;

1044 Oid opr1oid;

1045 Oid opr2oid;

1046 Datum opr1right;

1047 Datum opr2right;

1049

1050

1051

1052

1053

1054

1055

1056

1058 ((Const *) rightop)->constisnull)

1059 return NIL;

1060 rightopval = ((Const *) rightop)->constvalue;

1061

1062

1063

1064

1065

1068 return NIL;

1069

1071

1073 (Expr *) leftop,

1076 -1, opr1right,

1077 false, false),

1080

1081

1082

1085 return NIL;

1086

1088

1090 (Expr *) leftop,

1093 -1, opr2right,

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)

1116 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),

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)

1141 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),

1142 errmsg("could not format inet value: %m")));

1143

1144

1145 if (strchr(tmp, '/') == NULL)

1146 {

1147 len = strlen(tmp);

1149 }

1150

1152}

1153

1156{

1158 char *dst;

1159 char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];

1160

1162 ip_bits(ip), tmp, sizeof(tmp));

1163

1164 if (dst == NULL)

1166 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),

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

1180 ip_bits(ip), tmp, sizeof(tmp));

1181

1182 if (dst == NULL)

1184 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),

1185 errmsg("could not format cidr value: %m")));

1186

1188}

1189

1192{

1194

1196}

1197

1200{

1202

1204 {

1207 break;

1210 break;

1211 default:

1213 break;

1214 }

1215}

1216

1219{

1222 int byte;

1223 int bits;

1224 int maxbytes;

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;

1355 int maxbytes;

1356 unsigned char mask;

1357 unsigned char *b;

1358

1359

1361

1365

1366 byte = maxbytes - 1;

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

1398{

1401

1403}

1404

1405

1406

1407

1410{

1413 int commonbits;

1414

1417 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

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 {

1439 case INETOID:

1440 case CIDROID:

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 }

1463 case MACADDROID:

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 }

1473 case MACADDR8OID:

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

1485 *failure = true;

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,

1505 rb;

1506 int x,

1507 b;

1508

1509 b = n / 8;

1510 x = memcmp(l, r, b);

1511 if (x || (n % 8) == 0)

1512 return x;

1513

1514 lb = l[b];

1515 rb = r[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;

1578 int maxbits;

1579 int maxbytes;

1580 unsigned char mask;

1581

1583 {

1584 maxbits = 32;

1585 maxbytes = 4;

1586 }

1587 else

1588 {

1589 maxbits = 128;

1590 maxbytes = 16;

1591 }

1592 Assert(bits <= maxbits);

1593

1594 if (bits == maxbits)

1595 return true;

1596

1597 byte = bits / 8;

1598

1599 nbits = bits % 8;

1600 mask = 0xff;

1601 if (bits != 0)

1602 mask >>= nbits;

1603

1604 while (byte < maxbytes)

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

1624{

1626}

1627

1628

1629

1630

1631

1632

1633

1634

1635

1638{

1642}

1643

1644

1645

1646

1647

1650{

1652 char remote_host[NI_MAXHOST];

1653 int ret;

1654

1655 if (port == NULL)

1657

1658 switch (port->raddr.addr.ss_family)

1659 {

1660 case AF_INET:

1661 case AF_INET6:

1662 break;

1663 default:

1665 }

1666

1667 remote_host[0] = '\0';

1668

1670 remote_host, sizeof(remote_host),

1671 NULL, 0,

1672 NI_NUMERICHOST | NI_NUMERICSERV);

1673 if (ret != 0)

1675

1677

1679}

1680

1681

1682

1683

1684

1687{

1689 char remote_port[NI_MAXSERV];

1690 int ret;

1691

1692 if (port == NULL)

1694

1695 switch (port->raddr.addr.ss_family)

1696 {

1697 case AF_INET:

1698 case AF_INET6:

1699 break;

1700 default:

1702 }

1703

1704 remote_port[0] = '\0';

1705

1707 NULL, 0,

1708 remote_port, sizeof(remote_port),

1709 NI_NUMERICHOST | NI_NUMERICSERV);

1710 if (ret != 0)

1712

1714}

1715

1716

1717

1718

1719

1722{

1724 char local_host[NI_MAXHOST];

1725 int ret;

1726

1727 if (port == NULL)

1729

1730 switch (port->laddr.addr.ss_family)

1731 {

1732 case AF_INET:

1733 case AF_INET6:

1734 break;

1735 default:

1737 }

1738

1739 local_host[0] = '\0';

1740

1742 local_host, sizeof(local_host),

1743 NULL, 0,

1744 NI_NUMERICHOST | NI_NUMERICSERV);

1745 if (ret != 0)

1747

1749

1751}

1752

1753

1754

1755

1756

1759{

1761 char local_port[NI_MAXSERV];

1762 int ret;

1763

1764 if (port == NULL)

1766

1767 switch (port->laddr.addr.ss_family)

1768 {

1769 case AF_INET:

1770 case AF_INET6:

1771 break;

1772 default:

1774 }

1775

1776 local_port[0] = '\0';

1777

1779 NULL, 0,

1780 local_port, sizeof(local_port),

1781 NI_NUMERICHOST | NI_NUMERICSERV);

1782 if (ret != 0)

1784

1786}

1787

1788

1791{

1794

1796

1797 {

1799 unsigned char *pip = ip_addr(ip);

1800 unsigned char *pdst = ip_addr(dst);

1801

1802 while (--nb >= 0)

1803 pdst[nb] = ~pip[nb];

1804 }

1806

1809

1811}

1812

1813

1816{

1820

1822

1825 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

1826 errmsg("cannot AND inet values of different sizes")));

1827 else

1828 {

1830 unsigned char *pip = ip_addr(ip);

1831 unsigned char *pip2 = ip_addr(ip2);

1832 unsigned char *pdst = ip_addr(dst);

1833

1834 while (--nb >= 0)

1835 pdst[nb] = pip[nb] & pip2[nb];

1836 }

1838

1841

1843}

1844

1845

1848{

1852

1854

1857 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

1858 errmsg("cannot OR inet values of different sizes")));

1859 else

1860 {

1862 unsigned char *pip = ip_addr(ip);

1863 unsigned char *pip2 = ip_addr(ip2);

1864 unsigned char *pdst = ip_addr(dst);

1865

1866 while (--nb >= 0)

1867 pdst[nb] = pip[nb] | pip2[nb];

1868 }

1870

1873

1875}

1876

1877

1878static inet *

1880{

1882

1884

1885 {

1887 unsigned char *pip = ip_addr(ip);

1888 unsigned char *pdst = ip_addr(dst);

1889 int carry = 0;

1890

1891 while (--nb >= 0)

1892 {

1893 carry = pip[nb] + (int) (addend & 0xFF) + carry;

1894 pdst[nb] = (unsigned char) (carry & 0xFF);

1895 carry >>= 8;

1896

1897

1898

1899

1900

1901

1902

1903

1904

1905

1906 addend &= ~((int64) 0xFF);

1907 addend /= 0x100;

1908 }

1909

1910

1911

1912

1913

1914

1915 if (!((addend == 0 && carry == 0) ||

1916 (addend == -1 && carry == 1)))

1918 (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),

1919 errmsg("result is out of range")));

1920 }

1921

1925

1926 return dst;

1927}

1928

1929

1932{

1935

1937}

1938

1939

1942{

1945

1947}

1948

1949

1952{

1956

1959 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

1960 errmsg("cannot subtract inet values of different sizes")));

1961 else

1962 {

1963

1964

1965

1966

1967

1968

1970 int byte = 0;

1971 unsigned char *pip = ip_addr(ip);

1972 unsigned char *pip2 = ip_addr(ip2);

1973 int carry = 1;

1974

1975 while (--nb >= 0)

1976 {

1977 int lobyte;

1978

1979 carry = pip[nb] + (~pip2[nb] & 0xFF) + carry;

1980 lobyte = carry & 0xFF;

1981 if (byte < sizeof(int64))

1982 {

1983 res |= ((int64) lobyte) << (byte * 8);

1984 }

1985 else

1986 {

1987

1988

1989

1990

1991

1992 if ((res < 0) ? (lobyte != 0xFF) : (lobyte != 0))

1994 (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),

1995 errmsg("result is out of range")));

1996 }

1997 carry >>= 8;

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{

2030 if (addr_family == AF_INET6)

2031 {

2032 char *pct = strchr(addr, '%');

2033

2034 if (pct)

2035 *pct = '\0';

2036 }

2037}

#define IS_HIGHBIT_SET(ch)

int errdetail(const char *fmt,...)

int errcode(int sqlerrcode)

int errmsg(const char *fmt,...)

#define ereturn(context, dummy_value,...)

#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)

Assert(PointerIsAligned(start, uint64))

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)