Update FSM on WAL replay. This is a bit limited; the FSM is only updated
[PostgreSQL.git] / src / include / utils / inet.h
blob4134bcf6f3c98c4ee32ba07cc212f9ba71267086
1 /*-------------------------------------------------------------------------
3 * inet.h
4 * Declarations for operations on INET datatypes.
7 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $PostgreSQL$
12 *-------------------------------------------------------------------------
14 #ifndef INET_H
15 #define INET_H
17 #include "fmgr.h"
20 * This is the internal storage format for IP addresses
21 * (both INET and CIDR datatypes):
23 typedef struct
25 unsigned char family; /* PGSQL_AF_INET or PGSQL_AF_INET6 */
26 unsigned char bits; /* number of bits in netmask */
27 unsigned char ipaddr[16]; /* up to 128 bits of address */
28 } inet_struct;
31 * Referencing all of the non-AF_INET types to AF_INET lets us work on
32 * machines which may not have the appropriate address family (like
33 * inet6 addresses when AF_INET6 isn't present) but doesn't cause a
34 * dump/reload requirement. Existing databases used AF_INET for the family
35 * type on disk.
37 #define PGSQL_AF_INET (AF_INET + 0)
38 #define PGSQL_AF_INET6 (AF_INET + 1)
41 * Both INET and CIDR addresses are represented within Postgres as varlena
42 * objects, ie, there is a varlena header in front of the struct type
43 * depicted above. This struct depicts what we actually have in memory
44 * in "uncompressed" cases. Note that since the maximum data size is only
45 * 18 bytes, INET/CIDR will invariably be stored into tuples using the
46 * 1-byte-header varlena format. However, we have to be prepared to cope
47 * with the 4-byte-header format too, because various code may helpfully
48 * try to "decompress" 1-byte-header datums.
50 typedef struct
52 char vl_len_[4]; /* Do not touch this field directly! */
53 inet_struct inet_data;
54 } inet;
58 * This is the internal storage format for MAC addresses:
60 typedef struct macaddr
62 unsigned char a;
63 unsigned char b;
64 unsigned char c;
65 unsigned char d;
66 unsigned char e;
67 unsigned char f;
68 } macaddr;
71 * fmgr interface macros
73 #define DatumGetInetP(X) ((inet *) PG_DETOAST_DATUM_PACKED(X))
74 #define InetPGetDatum(X) PointerGetDatum(X)
75 #define PG_GETARG_INET_P(n) DatumGetInetP(PG_GETARG_DATUM(n))
76 #define PG_RETURN_INET_P(x) return InetPGetDatum(x)
77 /* macaddr is a fixed-length pass-by-reference datatype */
78 #define DatumGetMacaddrP(X) ((macaddr *) DatumGetPointer(X))
79 #define MacaddrPGetDatum(X) PointerGetDatum(X)
80 #define PG_GETARG_MACADDR_P(n) DatumGetMacaddrP(PG_GETARG_DATUM(n))
81 #define PG_RETURN_MACADDR_P(x) return MacaddrPGetDatum(x)
83 #endif /* INET_H */