Eneboo - Documentación para desarrolladores
src/libpq/include/utils/inet.h
Ir a la documentación de este archivo.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * inet.h
00004  *        Declarations for operations on INET datatypes.
00005  *
00006  *
00007  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
00008  * Portions Copyright (c) 1994, Regents of the University of California
00009  *
00010  * $PostgreSQL: pgsql/src/include/utils/inet.h,v 1.20 2004/12/31 22:03:46 pgsql Exp $
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 #ifndef INET_H
00015 #define INET_H
00016 
00017 /*
00018  *      This is the internal storage format for IP addresses
00019  *      (both INET and CIDR datatypes):
00020  */
00021 typedef struct
00022 {
00023         unsigned char family;           /* PGSQL_AF_INET or PGSQL_AF_INET6 */
00024         unsigned char bits;                     /* number of bits in netmask */
00025         unsigned char type;                     /* 0 = inet, 1 = cidr */
00026         unsigned char ipaddr[16];       /* up to 128 bits of address */
00027 } inet_struct;
00028 
00029 /*
00030  * Referencing all of the non-AF_INET types to AF_INET lets us work on
00031  * machines which may not have the appropriate address family (like
00032  * inet6 addresses when AF_INET6 isn't present) but doesn't cause a
00033  * dump/reload requirement.  Existing databases used AF_INET for the family
00034  * type on disk.
00035  */
00036 #define PGSQL_AF_INET   (AF_INET + 0)
00037 #define PGSQL_AF_INET6  (AF_INET + 1)
00038 
00039 /*
00040  * Both INET and CIDR addresses are represented within Postgres as varlena
00041  * objects, ie, there is a varlena header (basically a length word) in front
00042  * of the struct type depicted above.
00043  *
00044  * Although these types are variable-length, the maximum length
00045  * is pretty short, so we make no provision for TOASTing them.
00046  */
00047 typedef struct varlena inet;
00048 
00049 
00050 /*
00051  *      This is the internal storage format for MAC addresses:
00052  */
00053 typedef struct macaddr
00054 {
00055         unsigned char a;
00056         unsigned char b;
00057         unsigned char c;
00058         unsigned char d;
00059         unsigned char e;
00060         unsigned char f;
00061 } macaddr;
00062 
00063 /*
00064  * fmgr interface macros
00065  */
00066 #define DatumGetInetP(X)        ((inet *) DatumGetPointer(X))
00067 #define InetPGetDatum(X)        PointerGetDatum(X)
00068 #define PG_GETARG_INET_P(n) DatumGetInetP(PG_GETARG_DATUM(n))
00069 #define PG_RETURN_INET_P(x) return InetPGetDatum(x)
00070 /* macaddr is a fixed-length pass-by-reference datatype */
00071 #define DatumGetMacaddrP(X)    ((macaddr *) DatumGetPointer(X))
00072 #define MacaddrPGetDatum(X)    PointerGetDatum(X)
00073 #define PG_GETARG_MACADDR_P(n) DatumGetMacaddrP(PG_GETARG_DATUM(n))
00074 #define PG_RETURN_MACADDR_P(x) return MacaddrPGetDatum(x)
00075 
00076 #endif   /* INET_H */
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'