1998-10-03 07:41:01 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
2000-07-06 07:48:31 +02:00
|
|
|
* inet.h
|
|
|
|
* Declarations for operations on INET datatypes.
|
1998-10-03 07:41:01 +02:00
|
|
|
*
|
|
|
|
*
|
2002-06-20 22:29:54 +02:00
|
|
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1998-10-03 07:41:01 +02:00
|
|
|
*
|
2003-06-25 00:21:24 +02:00
|
|
|
* $Id: inet.h,v 1.14 2003/06/24 22:21:23 momjian Exp $
|
1998-10-03 07:41:01 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2000-08-04 01:07:51 +02:00
|
|
|
#ifndef INET_H
|
|
|
|
#define INET_H
|
1998-10-03 07:41:01 +02:00
|
|
|
|
|
|
|
/*
|
2000-08-04 01:07:51 +02:00
|
|
|
* This is the internal storage format for IP addresses
|
|
|
|
* (both INET and CIDR datatypes):
|
1998-10-03 07:41:01 +02:00
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned char family;
|
|
|
|
unsigned char bits;
|
1998-10-21 18:06:50 +02:00
|
|
|
unsigned char type;
|
2003-06-25 00:21:24 +02:00
|
|
|
unsigned char ip_addr[16]; /* 128 bits of address */
|
1999-05-26 00:43:53 +02:00
|
|
|
} inet_struct;
|
1998-10-03 07:41:01 +02:00
|
|
|
|
2003-06-25 00:21:24 +02:00
|
|
|
/*
|
|
|
|
* Referencing all of the non-AF_INET types to AF_INET lets us work on
|
|
|
|
* machines which may not have the appropriate address family (like
|
|
|
|
* inet6 addresses when AF_INET6 isn't present) but doesn't cause a
|
|
|
|
* dump/reload requirement. Existing databases used AF_INET for the family
|
|
|
|
* type on disk.
|
|
|
|
*/
|
|
|
|
#define PGSQL_AF_INET (AF_INET + 0)
|
|
|
|
#define PGSQL_AF_INET6 (AF_INET + 1)
|
|
|
|
|
2000-08-04 01:07:51 +02:00
|
|
|
/*
|
|
|
|
* Both INET and CIDR addresses are represented within Postgres as varlena
|
|
|
|
* objects, ie, there is a varlena header (basically a length word) in front
|
|
|
|
* of the struct type depicted above.
|
|
|
|
*
|
|
|
|
* Although these types are variable-length, the maximum length
|
|
|
|
* is pretty short, so we make no provision for TOASTing them.
|
|
|
|
*/
|
1998-10-08 02:19:47 +02:00
|
|
|
typedef struct varlena inet;
|
1998-10-03 07:41:01 +02:00
|
|
|
|
2000-08-04 01:07:51 +02:00
|
|
|
|
1998-10-03 07:41:01 +02:00
|
|
|
/*
|
|
|
|
* This is the internal storage format for MAC addresses:
|
|
|
|
*/
|
|
|
|
typedef struct macaddr
|
|
|
|
{
|
|
|
|
unsigned char a;
|
|
|
|
unsigned char b;
|
|
|
|
unsigned char c;
|
|
|
|
unsigned char d;
|
|
|
|
unsigned char e;
|
|
|
|
unsigned char f;
|
1999-05-25 18:15:34 +02:00
|
|
|
} macaddr;
|
1998-10-03 07:41:01 +02:00
|
|
|
|
2000-08-04 01:07:51 +02:00
|
|
|
/*
|
|
|
|
* fmgr interface macros
|
|
|
|
*/
|
2001-03-22 05:01:46 +01:00
|
|
|
#define DatumGetInetP(X) ((inet *) DatumGetPointer(X))
|
|
|
|
#define InetPGetDatum(X) PointerGetDatum(X)
|
2000-08-04 01:07:51 +02:00
|
|
|
#define PG_GETARG_INET_P(n) DatumGetInetP(PG_GETARG_DATUM(n))
|
|
|
|
#define PG_RETURN_INET_P(x) return InetPGetDatum(x)
|
|
|
|
/* macaddr is a fixed-length pass-by-reference datatype */
|
|
|
|
#define DatumGetMacaddrP(X) ((macaddr *) DatumGetPointer(X))
|
|
|
|
#define MacaddrPGetDatum(X) PointerGetDatum(X)
|
|
|
|
#define PG_GETARG_MACADDR_P(n) DatumGetMacaddrP(PG_GETARG_DATUM(n))
|
|
|
|
#define PG_RETURN_MACADDR_P(x) return MacaddrPGetDatum(x)
|
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* INET_H */
|