Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
5dfcbdde
Commit
5dfcbdde
authored
Nov 25, 2000
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some portability bugs I'd introduced into inet/cidr code ---
shifting by the word width is not defined by ANSI C...
parent
bbea3643
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
6 deletions
+36
-6
src/backend/utils/adt/network.c
src/backend/utils/adt/network.c
+36
-6
No files found.
src/backend/utils/adt/network.c
View file @
5dfcbdde
...
...
@@ -3,7 +3,7 @@
* is for IP V4 CIDR notation, but prepared for V6: just
* add the necessary bits where the comments indicate.
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.2
6 2000/11/10 20:13:25
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.2
7 2000/11/25 21:30:54
tgl Exp $
*
* Jon Postel RIP 16 Oct 1998
*/
...
...
@@ -418,7 +418,13 @@ network_broadcast(PG_FUNCTION_ARGS)
/* It's an IP V4 address: */
unsigned
long
mask
=
0xffffffff
;
mask
>>=
ip_bits
(
ip
);
/* Shifting by 32 or more bits does not yield portable results,
* so don't try it.
*/
if
(
ip_bits
(
ip
)
<
32
)
mask
>>=
ip_bits
(
ip
);
else
mask
=
0
;
ip_v4addr
(
dst
)
=
htonl
(
ntohl
(
ip_v4addr
(
ip
))
|
mask
);
}
...
...
@@ -451,7 +457,13 @@ network_network(PG_FUNCTION_ARGS)
/* It's an IP V4 address: */
unsigned
long
mask
=
0xffffffff
;
mask
<<=
(
32
-
ip_bits
(
ip
));
/* Shifting by 32 or more bits does not yield portable results,
* so don't try it.
*/
if
(
ip_bits
(
ip
)
>
0
)
mask
<<=
(
32
-
ip_bits
(
ip
));
else
mask
=
0
;
ip_v4addr
(
dst
)
=
htonl
(
ntohl
(
ip_v4addr
(
ip
))
&
mask
);
}
...
...
@@ -484,7 +496,13 @@ network_netmask(PG_FUNCTION_ARGS)
/* It's an IP V4 address: */
unsigned
long
mask
=
0xffffffff
;
mask
<<=
(
32
-
ip_bits
(
ip
));
/* Shifting by 32 or more bits does not yield portable results,
* so don't try it.
*/
if
(
ip_bits
(
ip
)
>
0
)
mask
<<=
(
32
-
ip_bits
(
ip
));
else
mask
=
0
;
ip_v4addr
(
dst
)
=
htonl
(
mask
);
...
...
@@ -512,7 +530,13 @@ v4bitncmp(unsigned long a1, unsigned long a2, int bits)
{
unsigned
long
mask
;
mask
=
(
0xFFFFFFFFL
<<
(
32
-
bits
))
&
0xFFFFFFFFL
;
/* Shifting by 32 or more bits does not yield portable results,
* so don't try it.
*/
if
(
bits
>
0
)
mask
=
(
0xFFFFFFFFL
<<
(
32
-
bits
))
&
0xFFFFFFFFL
;
else
mask
=
0
;
a1
=
ntohl
(
a1
);
a2
=
ntohl
(
a2
);
if
((
a1
&
mask
)
<
(
a2
&
mask
))
...
...
@@ -530,7 +554,13 @@ v4addressOK(unsigned long a1, int bits)
{
unsigned
long
mask
;
mask
=
(
0xFFFFFFFFL
<<
(
32
-
bits
))
&
0xFFFFFFFFL
;
/* Shifting by 32 or more bits does not yield portable results,
* so don't try it.
*/
if
(
bits
>
0
)
mask
=
(
0xFFFFFFFFL
<<
(
32
-
bits
))
&
0xFFFFFFFFL
;
else
mask
=
0
;
a1
=
ntohl
(
a1
);
if
((
a1
&
mask
)
==
a1
)
return
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment