Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8849655

Browse files
committed
I agree. I think, though, that the best argument presented in the
debate was from Paul Vixie, who wanted INET to be the name coveringboth IPV4 and IPV6. The following kit makes the needed changes:Tom Ivar Helbekkmo
1 parentac5a8b9 commit8849655

File tree

11 files changed

+90
-89
lines changed

11 files changed

+90
-89
lines changed

‎doc/README.ipaddrrenamed to‎doc/README.inet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PostgreSQL type extensions for IP and MAC addresses.
22
---------------------------------------------------
33

4-
$Id: README.ipaddr,v 1.1 1998/10/03 05:40:41 momjian Exp $
4+
$Id: README.inet,v 1.1 1998/10/08 00:19:32 momjian Exp $
55

66
I needed to record IP and MAC level ethernet addresses in a data
77
base, and I really didn't want to store them as plain strings, with

‎src/backend/utils/adt/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for utils/adt
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.18 1998/10/03 05:40:47 momjian Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.19 1998/10/08 00:19:33 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -24,7 +24,7 @@ OBJS = acl.o arrayfuncs.o arrayutils.o bool.o cash.o char.o chunk.o \
2424
oid.o oracle_compat.o\
2525
regexp.o regproc.o ruleutils.o selfuncs.o sets.o\
2626
tid.o timestamp.o varchar.o varlena.o version.o\
27-
ip.o mac.o inet_net_ntop.o inet_net_pton.o
27+
inet.o mac.o inet_net_ntop.o inet_net_pton.o
2828

2929
all: SUBSYS.o
3030

‎src/backend/utils/adt/ip.crenamed to‎src/backend/utils/adt/inet.c

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
*PostgreSQL type definitions forIP addresses. This
2+
*PostgreSQL type definitions forthe INET type. This
33
*is for IP V4 CIDR notation, but prepared for V6: just
44
*add the necessary bits where the comments indicate.
55
*
6-
*$Id:ip.c,v 1.4 1998/10/04 16:24:30 momjian Exp $
6+
*$Id:inet.c,v 1.1 1998/10/08 00:19:35 momjian Exp $
77
*/
88

99
#include<sys/types.h>
@@ -19,38 +19,40 @@
1919
#include<postgres.h>
2020
#include<utils/palloc.h>
2121
#include<utils/builtins.h>
22-
#include<utils/mac.h>
22+
#include<utils/network.h>
23+
24+
staticintv4bitncmp(unsignedinta1,unsignedinta2,intbits);
2325

2426
/*
2527
*Access macros.Add IPV6 support.
2628
*/
2729

28-
#defineip_addrsize(ipaddrptr) \
29-
(((ipaddr_struct *)VARDATA(ipaddrptr))->family == AF_INET ? 4 : -1)
30+
#defineip_addrsize(inetptr) \
31+
(((inet_struct *)VARDATA(inetptr))->family == AF_INET ? 4 : -1)
3032

31-
#defineip_family(ipaddrptr) \
32-
(((ipaddr_struct *)VARDATA(ipaddrptr))->family)
33+
#defineip_family(inetptr) \
34+
(((inet_struct *)VARDATA(inetptr))->family)
3335

34-
#defineip_bits(ipaddrptr) \
35-
(((ipaddr_struct *)VARDATA(ipaddrptr))->bits)
36+
#defineip_bits(inetptr) \
37+
(((inet_struct *)VARDATA(inetptr))->bits)
3638

37-
#defineip_v4addr(ipaddrptr) \
38-
(((ipaddr_struct *)VARDATA(ipaddrptr))->addr.ipv4_addr)
39+
#defineip_v4addr(inetptr) \
40+
(((inet_struct *)VARDATA(inetptr))->addr.ipv4_addr)
3941

4042
/*
4143
*IP address reader.
4244
*/
4345

44-
ipaddr*
45-
ipaddr_in(char*src)
46+
inet*
47+
inet_in(char*src)
4648
{
4749
intbits;
48-
ipaddr*dst;
50+
inet*dst;
4951

50-
dst=palloc(VARHDRSZ+sizeof(ipaddr_struct));
52+
dst=palloc(VARHDRSZ+sizeof(inet_struct));
5153
if (dst==NULL)
5254
{
53-
elog(ERROR,"unable to allocate memory inipaddr_in()");
55+
elog(ERROR,"unable to allocate memory ininet_in()");
5456
return (NULL);
5557
}
5658
/* First, try for an IP V4 address: */
@@ -75,7 +77,7 @@ ipaddr_in(char *src)
7577
*/
7678

7779
char*
78-
ipaddr_out(ipaddr*src)
80+
inet_out(inet*src)
7981
{
8082
char*dst,
8183
tmp[sizeof("255.255.255.255/32")];
@@ -99,7 +101,7 @@ ipaddr_out(ipaddr *src)
99101
dst=palloc(strlen(tmp)+1);
100102
if (dst==NULL)
101103
{
102-
elog(ERROR,"unable to allocate memory inipaddr_out()");
104+
elog(ERROR,"unable to allocate memory ininet_out()");
103105
return (NULL);
104106
}
105107
strcpy(dst,tmp);
@@ -111,7 +113,7 @@ ipaddr_out(ipaddr *src)
111113
*/
112114

113115
bool
114-
ipaddr_lt(ipaddr*a1,ipaddr*a2)
116+
inet_lt(inet*a1,inet*a2)
115117
{
116118
if ((ip_family(a1)==AF_INET)&& (ip_family(a2)==AF_INET))
117119
{
@@ -129,13 +131,13 @@ ipaddr_lt(ipaddr *a1, ipaddr *a2)
129131
}
130132

131133
bool
132-
ipaddr_le(ipaddr*a1,ipaddr*a2)
134+
inet_le(inet*a1,inet*a2)
133135
{
134-
return (ipaddr_lt(a1,a2)||ipaddr_eq(a1,a2));
136+
return (inet_lt(a1,a2)||inet_eq(a1,a2));
135137
}
136138

137139
bool
138-
ipaddr_eq(ipaddr*a1,ipaddr*a2)
140+
inet_eq(inet*a1,inet*a2)
139141
{
140142
if ((ip_family(a1)==AF_INET)&& (ip_family(a2)==AF_INET))
141143
{
@@ -152,13 +154,13 @@ ipaddr_eq(ipaddr *a1, ipaddr *a2)
152154
}
153155

154156
bool
155-
ipaddr_ge(ipaddr*a1,ipaddr*a2)
157+
inet_ge(inet*a1,inet*a2)
156158
{
157-
return (ipaddr_gt(a1,a2)||ipaddr_eq(a1,a2));
159+
return (inet_gt(a1,a2)||inet_eq(a1,a2));
158160
}
159161

160162
bool
161-
ipaddr_gt(ipaddr*a1,ipaddr*a2)
163+
inet_gt(inet*a1,inet*a2)
162164
{
163165
if ((ip_family(a1)==AF_INET)&& (ip_family(a2)==AF_INET))
164166
{
@@ -176,13 +178,13 @@ ipaddr_gt(ipaddr *a1, ipaddr *a2)
176178
}
177179

178180
bool
179-
ipaddr_ne(ipaddr*a1,ipaddr*a2)
181+
inet_ne(inet*a1,inet*a2)
180182
{
181-
return (!ipaddr_eq(a1,a2));
183+
return (!inet_eq(a1,a2));
182184
}
183185

184186
bool
185-
ipaddr_sub(ipaddr*a1,ipaddr*a2)
187+
inet_sub(inet*a1,inet*a2)
186188
{
187189
if ((ip_family(a1)==AF_INET)&& (ip_family(a2)==AF_INET))
188190
{
@@ -199,7 +201,7 @@ ipaddr_sub(ipaddr *a1, ipaddr *a2)
199201
}
200202

201203
bool
202-
ipaddr_subeq(ipaddr*a1,ipaddr*a2)
204+
inet_subeq(inet*a1,inet*a2)
203205
{
204206
if ((ip_family(a1)==AF_INET)&& (ip_family(a2)==AF_INET))
205207
{
@@ -216,7 +218,7 @@ ipaddr_subeq(ipaddr *a1, ipaddr *a2)
216218
}
217219

218220
bool
219-
ipaddr_sup(ipaddr*a1,ipaddr*a2)
221+
inet_sup(inet*a1,inet*a2)
220222
{
221223
if ((ip_family(a1)==AF_INET)&& (ip_family(a2)==AF_INET))
222224
{
@@ -233,7 +235,7 @@ ipaddr_sup(ipaddr *a1, ipaddr *a2)
233235
}
234236

235237
bool
236-
ipaddr_supeq(ipaddr*a1,ipaddr*a2)
238+
inet_supeq(inet*a1,inet*a2)
237239
{
238240
if ((ip_family(a1)==AF_INET)&& (ip_family(a2)==AF_INET))
239241
{
@@ -254,7 +256,7 @@ ipaddr_supeq(ipaddr *a1, ipaddr *a2)
254256
*/
255257

256258
int4
257-
ipaddr_cmp(ipaddr*a1,ipaddr*a2)
259+
inet_cmp(inet*a1,inet*a2)
258260
{
259261
if (ntohl(ip_v4addr(a1))<ntohl(ip_v4addr(a2)))
260262
return (-1);
@@ -267,7 +269,7 @@ ipaddr_cmp(ipaddr *a1, ipaddr *a2)
267269
*Bitwise comparison for V4 addresses. Add V6 implementation!
268270
*/
269271

270-
int
272+
staticint
271273
v4bitncmp(unsignedinta1,unsignedinta2,intbits)
272274
{
273275
unsigned longmask=0;

‎src/backend/utils/adt/mac.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
*PostgreSQL type definitions for MAC addresses.
33
*
4-
*$Id: mac.c,v 1.3 1998/10/04 16:24:32 momjian Exp $
4+
*$Id: mac.c,v 1.4 1998/10/08 00:19:36 momjian Exp $
55
*/
66

77
#include<stdio.h>
@@ -10,7 +10,7 @@
1010
#include<postgres.h>
1111
#include<utils/palloc.h>
1212
#include<utils/builtins.h>
13-
#include<utils/mac.h>
13+
#include<utils/network.h>
1414

1515
manufacturermanufacturers[]= {
1616
{0x00,0x00,0x0C,"Cisco"},

‎src/include/catalog/pg_opclass.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_opclass.h,v 1.12 1998/10/03 05:40:54 momjian Exp $
10+
* $Id: pg_opclass.h,v 1.13 1998/10/08 00:19:38 momjian Exp $
1111
*
1212
* NOTES
1313
* the genbki.sh script reads this file and generates .bki
@@ -109,7 +109,7 @@ DATA(insert OID = 1313 (timespan_ops 1186 ));
109109
DESCR("");
110110
DATA(insertOID=810 (macaddr_ops829 ));
111111
DESCR("");
112-
DATA(insertOID=935 (ipaddr_ops869 ));
112+
DATA(insertOID=935 (inet_ops869 ));
113113
DESCR("");
114114

115115
#endif/* PG_OPCLASS_H */

‎src/include/catalog/pg_operator.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_operator.h,v 1.39 1998/10/03 05:40:55 momjian Exp $
10+
* $Id: pg_operator.h,v 1.40 1998/10/08 00:19:39 momjian Exp $
1111
*
1212
* NOTES
1313
* the genbki.sh script reads this file and generates .bki
@@ -644,16 +644,16 @@ DATA(insert OID = 1224 ( ">" PGUID 0 b t f 829 829 16 1222 1223 0 0 macaddr
644644
DATA(insertOID=1225 (">="PGUID0btf829829161223122200macaddr_geintltselintltjoinsel ));
645645

646646
/* IP type */
647-
DATA(insertOID=1201 ("="PGUID0btt869869161201120200ipaddr_eqeqseleqjoinsel ));
648-
DATA(insertOID=1202 ("<>"PGUID0btf869869161202120100ipaddr_neneqselneqjoinsel ));
649-
DATA(insertOID=1203 ("<"PGUID0btf869869161205120600ipaddr_ltintltselintltjoinsel ));
650-
DATA(insertOID=1204 ("<="PGUID0btf869869161206120500ipaddr_leintltselintltjoinsel ));
651-
DATA(insertOID=1205 (">"PGUID0btf869869161203120400ipaddr_gtintltselintltjoinsel ));
652-
DATA(insertOID=1206 (">="PGUID0btf869869161204120300ipaddr_geintltselintltjoinsel ));
653-
DATA(insertOID=931 ("<<"PGUID0btf8698691693393400ipaddr_subintltselintltjoinsel ));
654-
DATA(insertOID=932 ("<<="PGUID0btf8698691693493300ipaddr_subeqintltselintltjoinsel ));
655-
DATA(insertOID=933 (">>"PGUID0btf8698691693193200ipaddr_supintltselintltjoinsel ));
656-
DATA(insertOID=934 (">>="PGUID0btf8698691693293100ipaddr_supeqintltselintltjoinsel ));
647+
DATA(insertOID=1201 ("="PGUID0btt869869161201120200inet_eqeqseleqjoinsel ));
648+
DATA(insertOID=1202 ("<>"PGUID0btf869869161202120100inet_neneqselneqjoinsel ));
649+
DATA(insertOID=1203 ("<"PGUID0btf869869161205120600inet_ltintltselintltjoinsel ));
650+
DATA(insertOID=1204 ("<="PGUID0btf869869161206120500inet_leintltselintltjoinsel ));
651+
DATA(insertOID=1205 (">"PGUID0btf869869161203120400inet_gtintltselintltjoinsel ));
652+
DATA(insertOID=1206 (">="PGUID0btf869869161204120300inet_geintltselintltjoinsel ));
653+
DATA(insertOID=931 ("<<"PGUID0btf8698691693393400inet_subintltselintltjoinsel ));
654+
DATA(insertOID=932 ("<<="PGUID0btf8698691693493300inet_subeqintltselintltjoinsel ));
655+
DATA(insertOID=933 (">>"PGUID0btf8698691693193200inet_supintltselintltjoinsel ));
656+
DATA(insertOID=934 (">>="PGUID0btf8698691693293100inet_supeqintltselintltjoinsel ));
657657

658658

659659
/*

‎src/include/catalog/pg_proc.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pg_proc.h,v 1.71 1998/10/03 05:40:56 momjian Exp $
9+
* $Id: pg_proc.h,v 1.72 1998/10/08 00:19:40 momjian Exp $
1010
*
1111
* NOTES
1212
* The script catalog/genbki.sh reads this file and generates .bki
@@ -2069,32 +2069,32 @@ DATA(insert OID = 837 ( macaddr_manuf PGUID 11 f t f 1 f 25 "829" 100 0 0 10
20692069
DESCR("MAC manufacturer");
20702070

20712071
/* for ip type support */
2072-
DATA(insertOID=910 (ipaddr_inPGUID11ftf1f869"0"10000100foobar ));
2072+
DATA(insertOID=910 (inet_inPGUID11ftf1f869"0"10000100foobar ));
20732073
DESCR("(internal)");
2074-
DATA(insertOID=911 (ipaddr_outPGUID11ftf1f23"0"10000100foobar ));
2074+
DATA(insertOID=911 (inet_outPGUID11ftf1f23"0"10000100foobar ));
20752075
DESCR("(internal)");
20762076

2077-
DATA(insertOID=920 (ipaddr_eqPGUID11ftf2f16"869 869"10000100foobar ));
2077+
DATA(insertOID=920 (inet_eqPGUID11ftf2f16"869 869"10000100foobar ));
20782078
DESCR("equal");
2079-
DATA(insertOID=921 (ipaddr_ltPGUID11ftf2f16"869 869"10000100foobar ));
2079+
DATA(insertOID=921 (inet_ltPGUID11ftf2f16"869 869"10000100foobar ));
20802080
DESCR("less-than");
2081-
DATA(insertOID=922 (ipaddr_lePGUID11ftf2f16"869 869"10000100foobar ));
2081+
DATA(insertOID=922 (inet_lePGUID11ftf2f16"869 869"10000100foobar ));
20822082
DESCR("less-than-or-equal");
2083-
DATA(insertOID=923 (ipaddr_gtPGUID11ftf2f16"869 869"10000100foobar ));
2083+
DATA(insertOID=923 (inet_gtPGUID11ftf2f16"869 869"10000100foobar ));
20842084
DESCR("greater-than");
2085-
DATA(insertOID=924 (ipaddr_gePGUID11ftf2f16"869 869"10000100foobar ));
2085+
DATA(insertOID=924 (inet_gePGUID11ftf2f16"869 869"10000100foobar ));
20862086
DESCR("greater-than-or-equal");
2087-
DATA(insertOID=925 (ipaddr_nePGUID11ftf2f16"869 869"10000100foobar ));
2087+
DATA(insertOID=925 (inet_nePGUID11ftf2f16"869 869"10000100foobar ));
20882088
DESCR("not equal");
2089-
DATA(insertOID=926 (ipaddr_cmpPGUID11ftf2f23"869 869"10000100foobar ));
2089+
DATA(insertOID=926 (inet_cmpPGUID11ftf2f23"869 869"10000100foobar ));
20902090
DESCR("less-equal-greater");
2091-
DATA(insertOID=927 (ipaddr_subPGUID11ftf2f16"869 869"10000100foobar ));
2091+
DATA(insertOID=927 (inet_subPGUID11ftf2f16"869 869"10000100foobar ));
20922092
DESCR("is-subnet");
2093-
DATA(insertOID=928 (ipaddr_subeqPGUID11ftf2f16"869 869"10000100foobar ));
2093+
DATA(insertOID=928 (inet_subeqPGUID11ftf2f16"869 869"10000100foobar ));
20942094
DESCR("is-subnet-or-equal");
2095-
DATA(insertOID=929 (ipaddr_supPGUID11ftf2f16"869 869"10000100foobar ));
2095+
DATA(insertOID=929 (inet_supPGUID11ftf2f16"869 869"10000100foobar ));
20962096
DESCR("is-supernet");
2097-
DATA(insertOID=930 (ipaddr_supeqPGUID11ftf2f16"869 869"10000100foobar ));
2097+
DATA(insertOID=930 (inet_supeqPGUID11ftf2f16"869 869"10000100foobar ));
20982098
DESCR("is-supernet-or-equal");
20992099

21002100

‎src/include/catalog/pg_type.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_type.h,v 1.48 1998/10/03 05:40:58 momjian Exp $
10+
* $Id: pg_type.h,v 1.49 1998/10/08 00:19:42 momjian Exp $
1111
*
1212
* NOTES
1313
* the genbki.sh script reads this file and generates .bki
@@ -300,7 +300,7 @@ DATA(insert OID = 791 ( _money PGUID -1 -1 f b t \054 0 790 array_in array
300300
/* OIDS 800 - 899 */
301301
DATA(insertOID=829 (macaddrPGUID6-1fbt \05400macaddr_inmacaddr_outmacaddr_inmacaddr_outi_null_ ));
302302
DESCR("MAC address");
303-
DATA(insertOID=869 (ipaddrPGUID-1-1fbt \05400ipaddr_inipaddr_outipaddr_inipaddr_outi_null_ ));
303+
DATA(insertOID=869 (inetPGUID-1-1fbt \05400inet_ininet_outinet_ininet_outi_null_ ));
304304
DESCR("IP address");
305305

306306
/* OIDS 900 - 999 */
@@ -339,7 +339,7 @@ DATA(insert OID = 1033 ( aclitem PGUID 8 -1 f b t \054 0 0 aclitemin aclitem
339339
DESCR("access control list");
340340
DATA(insertOID=1034 (_aclitemPGUID-1-1fbt \05401033array_inarray_outarray_inarray_outi_null_ ));
341341
DATA(insertOID=1040 (_macaddrPGUID-1-1fbt \0540829array_inarray_outarray_inarray_outi_null_ ));
342-
DATA(insertOID=1041 (_ipaddrPGUID-1-1fbt \0540869array_inarray_outarray_inarray_outi_null_ ));
342+
DATA(insertOID=1041 (_inetPGUID-1-1fbt \0540869array_inarray_outarray_inarray_outi_null_ ));
343343
DATA(insertOID=1042 (bpcharPGUID-1-1fbt \054018bpcharinbpcharoutbpcharinbpcharouti_null_ ));
344344
DESCR("blank-padded characters, length specifed when created");
345345
#defineBPCHAROID1042

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp