Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
net-tools
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
net-tools
Commits
c9014df8
Commit
c9014df8
authored
Mar 02, 1999
by
Phil Blundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Take the netmask into account when printing routes (previously it
was hardwired as 255.255.255.0!) Not very pretty I admit.
parent
86229c58
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
14 deletions
+40
-14
lib/inet.c
lib/inet.c
+20
-4
lib/inet_gr.c
lib/inet_gr.c
+20
-10
No files found.
lib/inet.c
View file @
c9014df8
...
...
@@ -3,7 +3,7 @@
* support functions for the net-tools.
* (NET-3 base distribution).
*
* Version: $Id: inet.c,v 1.
8 1999/01/05 20:53:33
philip Exp $
* Version: $Id: inet.c,v 1.
9 1999/03/02 21:09:14
philip Exp $
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* Copyright 1993 MicroWalt Corporation
...
...
@@ -16,6 +16,7 @@
*960219 {1.25} Bernd Eckenfels : extern int h_errno
*960329 {1.26} Bernd Eckenfels : resolve 255.255.255.255
*980101 {1.27} Bernd Eckenfels : resolve raw sockets in /etc/protocols
*990302 {1.28} Phil Blundell : add netmask to INET_rresolve
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
...
...
@@ -104,7 +105,8 @@ static int INET_resolve(char *name, struct sockaddr_in *sin)
}
static
int
INET_rresolve
(
char
*
name
,
struct
sockaddr_in
*
sin
,
int
numeric
)
static
int
INET_rresolve
(
char
*
name
,
struct
sockaddr_in
*
sin
,
int
numeric
,
unsigned
int
netmask
)
{
struct
hostent
*
ent
;
struct
netent
*
np
;
...
...
@@ -148,7 +150,7 @@ static int INET_rresolve(char *name, struct sockaddr_in *sin, int numeric)
host_ad
=
ntohl
(
ad
);
np
=
NULL
;
ent
=
NULL
;
if
((
host_ad
&
0xFF
)
!=
0
)
{
if
((
ad
&
(
~
netmask
)
)
!=
0
)
{
ent
=
gethostbyaddr
((
char
*
)
&
ad
,
4
,
AF_INET
);
if
(
ent
!=
NULL
)
strcpy
(
name
,
ent
->
h_name
);
...
...
@@ -192,7 +194,21 @@ static char *INET_sprint(struct sockaddr *sap, int numeric)
if
(
sap
->
sa_family
==
0xFFFF
||
sap
->
sa_family
==
0
)
return
safe_strncpy
(
buff
,
_
(
"[NONE SET]"
),
sizeof
(
buff
));
if
(
INET_rresolve
(
buff
,
(
struct
sockaddr_in
*
)
sap
,
numeric
)
!=
0
)
if
(
INET_rresolve
(
buff
,
(
struct
sockaddr_in
*
)
sap
,
numeric
,
0xffffff00
)
!=
0
)
return
(
NULL
);
return
(
buff
);
}
char
*
INET_sprintmask
(
struct
sockaddr
*
sap
,
int
numeric
,
unsigned
int
netmask
)
{
static
char
buff
[
128
];
if
(
sap
->
sa_family
==
0xFFFF
||
sap
->
sa_family
==
0
)
return
safe_strncpy
(
buff
,
_
(
"[NONE SET]"
),
sizeof
(
buff
));
if
(
INET_rresolve
(
buff
,
(
struct
sockaddr_in
*
)
sap
,
numeric
,
netmask
)
!=
0
)
return
(
NULL
);
return
(
buff
);
}
...
...
lib/inet_gr.c
View file @
c9014df8
/*
$Id: inet_gr.c,v 1.1
0 1999/01/05 20:53:43
philip Exp $
$Id: inet_gr.c,v 1.1
1 1999/03/02 21:09:15
philip Exp $
Modifications:
1998-07-01 - Arnaldo Carvalho de Melo - GNU gettext instead of catgets
...
...
@@ -31,13 +31,14 @@
#include "proc.h"
extern
struct
aftype
inet_aftype
;
extern
char
*
INET_sprintmask
(
struct
sockaddr
*
sap
,
int
numeric
,
unsigned
int
netmask
);
int
rprint_fib
(
int
ext
,
int
numeric
)
{
char
buff
[
1024
],
iface
[
16
],
flags
[
64
];
char
gate_addr
[
128
],
net_addr
[
128
];
char
mask_addr
[
128
];
struct
sockaddr
snet
;
int
num
,
iflags
,
metric
,
refcnt
,
use
,
mss
,
window
,
irtt
;
FILE
*
fp
=
fopen
(
_PATH_PROCNET_ROUTE
,
"r"
);
char
*
fmt
;
...
...
@@ -83,6 +84,9 @@ int rprint_fib(int ext, int numeric)
return
1
;
while
(
fgets
(
buff
,
1023
,
fp
))
{
struct
sockaddr
snet_target
,
snet_gateway
,
snet_mask
;
struct
sockaddr_in
*
sin_netmask
;
num
=
sscanf
(
buff
,
fmt
,
iface
,
net_addr
,
gate_addr
,
&
iflags
,
&
refcnt
,
&
use
,
&
metric
,
mask_addr
,
...
...
@@ -91,18 +95,24 @@ int rprint_fib(int ext, int numeric)
continue
;
/* Fetch and resolve the target address. */
(
void
)
inet_aftype
.
input
(
1
,
net_addr
,
&
snet
);
strcpy
(
net_addr
,
inet_aftype
.
sprint
(
&
snet
,
(
numeric
|
0x8000
)));
net_addr
[
15
]
=
'\0'
;
(
void
)
inet_aftype
.
input
(
1
,
net_addr
,
&
snet_target
);
/* Fetch and resolve the gateway address. */
(
void
)
inet_aftype
.
input
(
1
,
gate_addr
,
&
snet
);
strcpy
(
gate_addr
,
inet_aftype
.
sprint
(
&
snet
,
numeric
));
gate_addr
[
15
]
=
'\0'
;
(
void
)
inet_aftype
.
input
(
1
,
gate_addr
,
&
snet_gateway
);
/* Fetch and resolve the genmask. */
(
void
)
inet_aftype
.
input
(
1
,
mask_addr
,
&
snet
);
strcpy
(
mask_addr
,
inet_aftype
.
sprint
(
&
snet
,
1
));
(
void
)
inet_aftype
.
input
(
1
,
mask_addr
,
&
snet_mask
);
sin_netmask
=
(
struct
sockaddr_in
*
)
&
snet_mask
;
strcpy
(
net_addr
,
INET_sprintmask
(
&
snet_target
,
(
numeric
|
0x8000
),
sin_netmask
->
sin_addr
.
s_addr
));
net_addr
[
15
]
=
'\0'
;
strcpy
(
gate_addr
,
inet_aftype
.
sprint
(
&
snet_gateway
,
numeric
));
gate_addr
[
15
]
=
'\0'
;
strcpy
(
mask_addr
,
inet_aftype
.
sprint
(
&
snet_mask
,
1
));
mask_addr
[
15
]
=
'\0'
;
/* Decode the flags. */
...
...
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