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
d1381f90
Commit
d1381f90
authored
May 12, 2013
by
Mike Frysinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trim trailing whitespace
Signed-off-by:
Mike Frysinger
<
vapier@gentoo.org
>
parent
35eaa82d
Changes
49
Hide whitespace changes
Inline
Side-by-side
Showing
49 changed files
with
451 additions
and
451 deletions
+451
-451
INSTALLING
INSTALLING
+1
-1
Makefile
Makefile
+5
-5
README
README
+1
-1
RPM/net-tools.spec
RPM/net-tools.spec
+2
-2
TODO
TODO
+1
-1
arp.c
arp.c
+4
-4
config.in
config.in
+1
-1
hostname.c
hostname.c
+2
-2
ifconfig.c
ifconfig.c
+43
-43
include/interface.h
include/interface.h
+2
-2
ipmaddr.c
ipmaddr.c
+1
-1
iptunnel.c
iptunnel.c
+7
-7
lib/af.c
lib/af.c
+1
-1
lib/ash.c
lib/ash.c
+1
-1
lib/ddp_gr.c
lib/ddp_gr.c
+2
-2
lib/econet.c
lib/econet.c
+1
-1
lib/eui64.c
lib/eui64.c
+4
-4
lib/getargs.c
lib/getargs.c
+1
-1
lib/hdlclapb.c
lib/hdlclapb.c
+2
-2
lib/hw.c
lib/hw.c
+3
-3
lib/inet.c
lib/inet.c
+11
-11
lib/inet6.c
lib/inet6.c
+13
-13
lib/inet6_gr.c
lib/inet6_gr.c
+2
-2
lib/inet_gr.c
lib/inet_gr.c
+8
-8
lib/interface.c
lib/interface.c
+52
-52
lib/ipx.c
lib/ipx.c
+1
-1
lib/ipx_gr.c
lib/ipx_gr.c
+1
-1
lib/irda.c
lib/irda.c
+12
-12
lib/net-features.h
lib/net-features.h
+1
-1
lib/net-support.h
lib/net-support.h
+1
-1
lib/netrom.c
lib/netrom.c
+1
-1
lib/netrom_gr.c
lib/netrom_gr.c
+1
-1
lib/nstrcmp.c
lib/nstrcmp.c
+18
-18
lib/pathnames.h
lib/pathnames.h
+2
-2
lib/ppp.c
lib/ppp.c
+1
-1
lib/proc.c
lib/proc.c
+5
-5
lib/proc.h
lib/proc.h
+1
-1
lib/tr.c
lib/tr.c
+3
-3
lib/util.c
lib/util.c
+4
-4
lib/util.h
lib/util.h
+1
-1
lib/x25.c
lib/x25.c
+1
-1
lib/x25_sr.c
lib/x25_sr.c
+4
-4
mii-tool.c
mii-tool.c
+3
-3
nameif.c
nameif.c
+133
-133
netstat.c
netstat.c
+39
-39
plipconfig.c
plipconfig.c
+1
-1
route.c
route.c
+2
-2
slattach.c
slattach.c
+10
-10
statistics.c
statistics.c
+34
-34
No files found.
INSTALLING
View file @
d1381f90
...
...
@@ -27,7 +27,7 @@ of the other options should work as well.
COMPILE
-------
-------
To compile simply use "make".
There should be no warnings or errors.
...
...
Makefile
View file @
d1381f90
...
...
@@ -18,12 +18,12 @@
# Alan Cox <A.Cox@swansea.ac.uk>
# Copyright 1993-1994 Swansea University Computer Society
#
# Be careful!
# Be careful!
# This Makefile doesn't describe complete dependencies for all include files.
# If you change include files you might need to do make clean.
# If you change include files you might need to do make clean.
#
# set the base of the Installation
# set the base of the Installation
# BASEDIR = /mnt
BASEDIR
?=
$(DESTDIR)
...
...
@@ -129,7 +129,7 @@ distcheck: dist
rm
-rf
net-tools-
$(RELEASE)
@
printf
"
\n
The tarball is ready to go:
\n
%s
\n
"
"
`
du
-b
net-tools-
$(RELEASE)
.tar.xz
`
"
config.h
:
config.in Makefile
config.h
:
config.in Makefile
@
echo
"Configuring the Linux net-tools (NET-3 Base Utilities)..."
;
echo
@
if
[
config.status
-nt
config.in
]
;
\
then
./configure.sh config.status
;
\
...
...
@@ -157,7 +157,7 @@ subdirs: libdir
ifconfig
:
$(NET_LIB) ifconfig.o
$(CC)
$(CFLAGS)
$(LDFLAGS)
-o
$@
ifconfig.o
$(NLIB)
$(RESLIB)
nameif
:
$(NET_LIB) nameif.o
$(CC)
$(CFLAGS)
$(LDFLAGS)
-o
$@
nameif.o
$(NLIB)
$(RESLIB)
...
...
README
View file @
d1381f90
...
...
@@ -17,7 +17,7 @@ Please include the output of "program --version" when reporting bugs.
Contents:
README This file.
README.ipv6 Notes for people hacking IPv6.
...
...
RPM/net-tools.spec
View file @
d1381f90
...
...
@@ -34,7 +34,7 @@ make BASEDIR=$RPM_BUILD_ROOT install
strip arp ifconfig rarp route slattach plipconfig ipmaddr iptunnel
cd ../bin
strip hostname netstat
)
)
%clean
rm -rf $RPM_BUILD_ROOT
...
...
@@ -92,7 +92,7 @@ rm -rf $RPM_BUILD_ROOT
* Fri Feb 27 1998 Jason Spangler <jasons@usemail.com>
- changed to net-tools 1.432
- removed old glibc 2.1 patch
* Wed Oct 22 1997 Erik Troan <ewt@redhat.com>
- added extra patches for glibc 2.1
...
...
TODO
View file @
d1381f90
...
...
@@ -23,7 +23,7 @@ TODO for net-tools
[ ] supply some informations about new features to HOWTOs
[ ] Config file only works with bash not ash.
[ ] Token ring is almost totally untested.
[ ] additional tools for IPX, AX.25 etc be bundled [ipxripd004, ipx_* tools
[ ] additional tools for IPX, AX.25 etc be bundled [ipxripd004, ipx_* tools
from caldera, axattach] into existing bins
[ ] "SIOCAX25OPTRT" [Joerg (DL1BKE)]. 1.3.75
[ ] dummy NOARP?! (2. default route for preveting hostunreachables on linedrop)
...
...
arp.c
View file @
d1381f90
...
...
@@ -20,14 +20,14 @@
* Andrew Tridgell : proxy arp netmasks
* Bernd Eckenfels : -n option
* Bernd Eckenfels : Use only /proc for display
* {1.60} Bernd Eckenfels : new arpcode (-i) for 1.3.42 but works
* {1.60} Bernd Eckenfels : new arpcode (-i) for 1.3.42 but works
* with 1.2.x, too
* {1.61} Bernd Eckenfels : more verbose messages
* {1.62} Bernd Eckenfels : check -t for hw adresses and try to
* explain EINVAL (jeff)
*970125 {1.63} Bernd Eckenfels : -a print hardwarename instead of tiltle
*970201 {1.64} Bernd Eckenfels : net-features.h support
*970203 {1.65} Bernd Eckenfels : "#define" in "#if",
*970203 {1.65} Bernd Eckenfels : "#define" in "#if",
* -H|-A additional to -t|-p
*970214 {1.66} Bernd Eckenfels : Fix optarg required for -H and -A
*970412 {1.67} Bernd Eckenfels : device=""; is default
...
...
@@ -35,7 +35,7 @@
*970517 {1.69} Bernd Eckenfels : usage() fixed
*970622 {1.70} Bernd Eckenfels : arp -d priv
*970106 {1.80} Bernd Eckenfels : new syntax without -D and with "dev <If>",
* ATF_MAGIC, ATF_DONTPUB support.
* ATF_MAGIC, ATF_DONTPUB support.
* Typo fix (Debian Bug#5728 Giuliano Procida)
*970803 {1.81} Bernd Eckenfels : removed junk comment line 1
*970925 {1.82} Bernd Eckenfels : include fix for libc6
...
...
@@ -628,7 +628,7 @@ static void usage(void)
fprintf
(
stderr
,
_
(
" arp [-vnD] [<HW>] [-i <if>] -f [<filename>] <-Add entry from file
\n
"
));
fprintf
(
stderr
,
_
(
" arp [-v] [<HW>] [-i <if>] -s <host> <hwaddr> [temp] <-Add entry
\n
"
));
fprintf
(
stderr
,
_
(
" arp [-v] [<HW>] [-i <if>] -Ds <host> <if> [netmask <nm>] pub <-''-
\n\n
"
));
fprintf
(
stderr
,
_
(
" -a display (all) hosts in alternative (BSD) style
\n
"
));
fprintf
(
stderr
,
_
(
" -e display (all) hosts in default (Linux) style
\n
"
));
fprintf
(
stderr
,
_
(
" -s, --set set a new ARP entry
\n
"
));
...
...
config.in
View file @
d1381f90
...
...
@@ -46,7 +46,7 @@ bool 'Does your system support GNU gettext?' I18N n
*
*
* Protocol Families.
*
*
bool 'UNIX protocol family' HAVE_AFUNIX y
bool 'INET (TCP/IP) protocol family' HAVE_AFINET y
bool 'INET6 (IPv6) protocol family' HAVE_AFINET6 y
...
...
hostname.c
View file @
d1381f90
...
...
@@ -6,7 +6,7 @@
* Usage: hostname [-d|-f|-s|-a|-i|-y|-n]
* hostname [-h|-V]
* hostname {name|-F file}
* dnsdmoainname
* dnsdmoainname
* nisdomainname {name|-F file}
*
* Version: hostname 1.101 (2003-10-11)
...
...
@@ -16,7 +16,7 @@
* Changes:
* {1.90} Peter Tobias : Added -a and -i options.
* {1.91} Bernd Eckenfels : -v,-V rewritten, long_opts (major rewrite), usage.
*19960120 {1.95} Bernd Eckenfels : -y/nisdomainname - support for get/setdomainname added
*19960120 {1.95} Bernd Eckenfels : -y/nisdomainname - support for get/setdomainname added
*19960218 {1.96} Bernd Eckenfels : netinet/in.h added
*19980629 {1.97} Arnaldo Carvalho de Melo : gettext instead of catgets for i18n
*20000213 {1.99} Arnaldo Carvalho de Melo : fixed some i18n strings
...
...
ifconfig.c
View file @
d1381f90
...
...
@@ -19,8 +19,8 @@
*
* {1.34} - 19980630 - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* - gettext instead of catgets for i18n
* 10/1998 - Andi Kleen. Use interface list primitives.
* 20001008 - Bernd Eckenfels, Patch from RH for setting mtu
* 10/1998 - Andi Kleen. Use interface list primitives.
* 20001008 - Bernd Eckenfels, Patch from RH for setting mtu
* (default AF was wrong)
* 20010404 - Arnaldo Carvalho de Melo, use setlocale
*/
...
...
@@ -93,7 +93,7 @@ int opt_v = 0; /* debugging output flag */
int
addr_family
=
0
;
/* currently selected AF */
/* for ipv4 add/del modes */
static
int
get_nmbc_parent
(
char
*
parent
,
unsigned
long
*
nm
,
static
int
get_nmbc_parent
(
char
*
parent
,
unsigned
long
*
nm
,
unsigned
long
*
bc
);
static
int
set_ifstate
(
char
*
parent
,
unsigned
long
ip
,
unsigned
long
nm
,
unsigned
long
bc
,
...
...
@@ -115,11 +115,11 @@ static int if_print(char *ifname)
if
(
!
ife
)
{
return
-
1
;
}
res
=
do_if_fetch
(
ife
);
if
(
res
>=
0
)
res
=
do_if_fetch
(
ife
);
if
(
res
>=
0
)
ife_print
(
ife
);
}
return
res
;
return
res
;
}
/* Set a certain interface flag. */
...
...
@@ -129,7 +129,7 @@ static int set_flag(char *ifname, short flag)
safe_strncpy
(
ifr
.
ifr_name
,
ifname
,
IFNAMSIZ
);
if
(
ioctl
(
skfd
,
SIOCGIFFLAGS
,
&
ifr
)
<
0
)
{
fprintf
(
stderr
,
_
(
"%s: ERROR while getting interface flags: %s
\n
"
),
fprintf
(
stderr
,
_
(
"%s: ERROR while getting interface flags: %s
\n
"
),
ifname
,
strerror
(
errno
));
return
(
-
1
);
}
...
...
@@ -161,7 +161,7 @@ static int clr_flag(char *ifname, short flag)
safe_strncpy
(
ifr
.
ifr_name
,
ifname
,
IFNAMSIZ
);
if
(
ioctl
(
fd
,
SIOCGIFFLAGS
,
&
ifr
)
<
0
)
{
fprintf
(
stderr
,
_
(
"%s: ERROR while getting interface flags: %s
\n
"
),
fprintf
(
stderr
,
_
(
"%s: ERROR while getting interface flags: %s
\n
"
),
ifname
,
strerror
(
errno
));
return
-
1
;
}
...
...
@@ -193,7 +193,7 @@ static int test_flag(char *ifname, short flags)
safe_strncpy
(
ifr
.
ifr_name
,
ifname
,
IFNAMSIZ
);
if
(
ioctl
(
fd
,
SIOCGIFFLAGS
,
&
ifr
)
<
0
)
{
fprintf
(
stderr
,
_
(
"%s: ERROR while testing interface flags: %s
\n
"
),
fprintf
(
stderr
,
_
(
"%s: ERROR while testing interface flags: %s
\n
"
),
ifname
,
strerror
(
errno
));
return
-
1
;
}
...
...
@@ -277,7 +277,7 @@ int main(int argc, char **argv)
#endif
#if I18N
setlocale
(
LC_ALL
,
""
);
setlocale
(
LC_ALL
,
""
);
bindtextdomain
(
"net-tools"
,
"/usr/share/locale"
);
textdomain
(
"net-tools"
);
#endif
...
...
@@ -294,7 +294,7 @@ int main(int argc, char **argv)
else
if
(
!
strcmp
(
*
argv
,
"-v"
))
opt_v
=
1
;
else
if
(
!
strcmp
(
*
argv
,
"-V"
)
||
!
strcmp
(
*
argv
,
"-version"
)
||
!
strcmp
(
*
argv
,
"--version"
))
version
();
...
...
@@ -304,7 +304,7 @@ int main(int argc, char **argv)
usage
();
else
{
fprintf
(
stderr
,
_
(
"ifconfig: option `%s' not recognised.
\n
"
),
fprintf
(
stderr
,
_
(
"ifconfig: option `%s' not recognised.
\n
"
),
argv
[
0
]);
fprintf
(
stderr
,
_
(
"ifconfig: `--help' gives usage information.
\n
"
));
exit
(
1
);
...
...
@@ -338,9 +338,9 @@ int main(int argc, char **argv)
/* The next argument is either an address family name, or an option. */
if
((
ap
=
get_aftype
(
*
spp
))
!=
NULL
)
spp
++
;
/* it was a AF name */
else
else
ap
=
get_aftype
(
DFLT_AF
);
if
(
ap
)
{
addr_family
=
ap
->
af
;
skfd
=
ap
->
fd
;
...
...
@@ -385,7 +385,7 @@ int main(int argc, char **argv)
goterr
=
1
;
}
else
{
if
(
ioctl
(
skfd
,
SIOCGIFMAP
,
&
ifr
)
<
0
)
{
perror
(
"port: SIOCGIFMAP"
);
perror
(
"port: SIOCGIFMAP"
);
goterr
=
1
;
continue
;
}
...
...
@@ -600,8 +600,8 @@ int main(int argc, char **argv)
if
(
*++
spp
==
NULL
)
usage
();
if
(
ioctl
(
skfd
,
SIOCGIFMAP
,
&
ifr
)
<
0
)
{
fprintf
(
stderr
,
"mem_start: SIOCGIFMAP: %s
\n
"
,
strerror
(
errno
));
spp
++
;
fprintf
(
stderr
,
"mem_start: SIOCGIFMAP: %s
\n
"
,
strerror
(
errno
));
spp
++
;
goterr
=
1
;
continue
;
}
...
...
@@ -617,8 +617,8 @@ int main(int argc, char **argv)
if
(
*++
spp
==
NULL
)
usage
();
if
(
ioctl
(
skfd
,
SIOCGIFMAP
,
&
ifr
)
<
0
)
{
fprintf
(
stderr
,
"io_addr: SIOCGIFMAP: %s
\n
"
,
strerror
(
errno
));
spp
++
;
fprintf
(
stderr
,
"io_addr: SIOCGIFMAP: %s
\n
"
,
strerror
(
errno
));
spp
++
;
goterr
=
1
;
continue
;
}
...
...
@@ -634,9 +634,9 @@ int main(int argc, char **argv)
if
(
*++
spp
==
NULL
)
usage
();
if
(
ioctl
(
skfd
,
SIOCGIFMAP
,
&
ifr
)
<
0
)
{
fprintf
(
stderr
,
"irq: SIOCGIFMAP: %s
\n
"
,
strerror
(
errno
));
fprintf
(
stderr
,
"irq: SIOCGIFMAP: %s
\n
"
,
strerror
(
errno
));
goterr
=
1
;
spp
++
;
spp
++
;
continue
;
}
ifr
.
ifr_map
.
irq
=
atoi
(
*
spp
);
...
...
@@ -730,7 +730,7 @@ int main(int argc, char **argv)
prefix_len
=
128
;
}
safe_strncpy
(
host
,
*
spp
,
(
sizeof
host
));
if
(
inet6_aftype
.
input
(
1
,
host
,
if
(
inet6_aftype
.
input
(
1
,
host
,
(
struct
sockaddr
*
)
&
sa6
)
<
0
)
{
if
(
inet6_aftype
.
herror
)
inet6_aftype
.
herror
(
host
);
...
...
@@ -745,7 +745,7 @@ int main(int argc, char **argv)
fd
=
get_socket_for_af
(
AF_INET6
);
if
(
fd
<
0
)
{
fprintf
(
stderr
,
fprintf
(
stderr
,
_
(
"No support for INET6 on this system.
\n
"
));
goterr
=
1
;
spp
++
;
...
...
@@ -779,7 +779,7 @@ int main(int argc, char **argv)
}
fd
=
get_socket_for_af
(
AF_INET
);
if
(
fd
<
0
)
{
fprintf
(
stderr
,
fprintf
(
stderr
,
_
(
"No support for INET on this system.
\n
"
));
goterr
=
1
;
spp
++
;
...
...
@@ -787,7 +787,7 @@ int main(int argc, char **argv)
}
memcpy
(
&
ip
,
&
sin
.
sin_addr
.
s_addr
,
sizeof
(
unsigned
long
));
if
(
get_nmbc_parent
(
ifr
.
ifr_name
,
&
nm
,
&
bc
)
<
0
)
{
fprintf
(
stderr
,
_
(
"Interface %s not initialized
\n
"
),
ifr
.
ifr_name
);
...
...
@@ -796,7 +796,7 @@ int main(int argc, char **argv)
continue
;
}
set_ifstate
(
ifr
.
ifr_name
,
ip
,
nm
,
bc
,
1
);
}
spp
++
;
continue
;
...
...
@@ -823,7 +823,7 @@ int main(int argc, char **argv)
prefix_len
=
128
;
}
safe_strncpy
(
host
,
*
spp
,
(
sizeof
host
));
if
(
inet6_aftype
.
input
(
1
,
host
,
if
(
inet6_aftype
.
input
(
1
,
host
,
(
struct
sockaddr
*
)
&
sa6
)
<
0
)
{
inet6_aftype
.
herror
(
host
);
goterr
=
1
;
...
...
@@ -832,10 +832,10 @@ int main(int argc, char **argv)
}
memcpy
((
char
*
)
&
ifr6
.
ifr6_addr
,
(
char
*
)
&
sa6
.
sin6_addr
,
sizeof
(
struct
in6_addr
));
fd
=
get_socket_for_af
(
AF_INET6
);
if
(
fd
<
0
)
{
fprintf
(
stderr
,
fprintf
(
stderr
,
_
(
"No support for INET6 on this system.
\n
"
));
goterr
=
1
;
spp
++
;
...
...
@@ -878,11 +878,11 @@ int main(int argc, char **argv)
spp
++
;
continue
;
}
/* Clear "ip" in case sizeof(unsigned long) > sizeof(sin.sin_addr.s_addr) */
ip
=
0
;
memcpy
(
&
ip
,
&
sin
.
sin_addr
.
s_addr
,
sizeof
(
sin
.
sin_addr
.
s_addr
));
if
(
get_nmbc_parent
(
ifr
.
ifr_name
,
&
nm
,
&
bc
)
<
0
)
{
fprintf
(
stderr
,
_
(
"Interface %s not initialized
\n
"
),
ifr
.
ifr_name
);
...
...
@@ -953,7 +953,7 @@ int main(int argc, char **argv)
/* If the next argument is a valid hostname, assume OK. */
safe_strncpy
(
host
,
*
spp
,
(
sizeof
host
));
/* FIXME: sa is too small for INET6 addresses, inet6 should use that too,
/* FIXME: sa is too small for INET6 addresses, inet6 should use that too,
broadcast is unexpected */
if
(
ap
->
getmask
)
{
switch
(
ap
->
getmask
(
host
,
&
samask
,
NULL
))
{
...
...
@@ -1020,14 +1020,14 @@ int main(int argc, char **argv)
* end, since it's deleted already! - Roman
*
* Should really use regex.h here, not sure though how well it'll go
* with the cross-platform support etc.
* with the cross-platform support etc.
*/
{
char
*
ptr
;
short
int
found_colon
=
0
;
for
(
ptr
=
ifr
.
ifr_name
;
*
ptr
;
ptr
++
)
if
(
*
ptr
==
':'
)
found_colon
++
;
if
(
!
(
found_colon
&&
*
(
ptr
-
1
)
==
'-'
))
goterr
|=
set_flag
(
ifr
.
ifr_name
,
(
IFF_UP
|
IFF_RUNNING
));
}
...
...
@@ -1075,7 +1075,7 @@ static int do_ifcmd(struct interface *x, struct ifcmd *ptr)
char
*
z
,
*
e
;
struct
sockaddr_in
*
sin
;
int
i
;
if
(
do_if_fetch
(
x
)
<
0
)
return
0
;
if
(
strncmp
(
x
->
name
,
ptr
->
base
,
ptr
->
baselen
)
!=
0
)
...
...
@@ -1091,13 +1091,13 @@ static int do_ifcmd(struct interface *x, struct ifcmd *ptr)
if
(
i
<
0
||
i
>
255
)
abort
();
searcher
[
i
]
=
1
;
/* copy */
sin
=
(
struct
sockaddr_in
*
)
&
x
->
dstaddr
;
if
(
sin
->
sin_addr
.
s_addr
!=
ptr
->
addr
)
{
return
0
;
}
if
(
ptr
->
flag
)
{
/* turn UP */
if
(
set_flag
(
x
->
name
,
IFF_UP
|
IFF_RUNNING
)
==
-
1
)
...
...
@@ -1107,7 +1107,7 @@ static int do_ifcmd(struct interface *x, struct ifcmd *ptr)
if
(
clr_flag
(
x
->
name
,
IFF_UP
)
==
-
1
)
return
-
1
;
}
return
1
;
/* all done! */
}
...
...
@@ -1117,7 +1117,7 @@ static int get_nmbc_parent(char *parent,
{
struct
interface
*
i
;
struct
sockaddr_in
*
sin
;
i
=
lookup_interface
(
parent
);
if
(
!
i
)
return
-
1
;
...
...
@@ -1137,19 +1137,19 @@ static int set_ifstate(char *parent, unsigned long ip,
char
buf
[
IFNAMSIZ
];
struct
ifcmd
pt
;
int
i
;
pt
.
base
=
parent
;
pt
.
baselen
=
strlen
(
parent
);
pt
.
addr
=
ip
;
pt
.
flag
=
flag
;
memset
(
searcher
,
0
,
sizeof
(
searcher
));
i
=
for_all_interfaces
((
int
(
*
)(
struct
interface
*
,
void
*
))
do_ifcmd
,
i
=
for_all_interfaces
((
int
(
*
)(
struct
interface
*
,
void
*
))
do_ifcmd
,
&
pt
);
if
(
i
==
-
1
)
return
-
1
;
if
(
i
==
1
)
return
0
;
/* add a new interface */
for
(
i
=
0
;
i
<
256
;
i
++
)
if
(
searcher
[
i
]
==
0
)
...
...
@@ -1157,7 +1157,7 @@ static int set_ifstate(char *parent, unsigned long ip,
if
(
i
==
256
)
return
-
1
;
/* FAILURE!!! out of ip addresses */
if
(
snprintf
(
buf
,
IFNAMSIZ
,
"%s:%d"
,
parent
,
i
)
>
IFNAMSIZ
)
return
-
1
;
if
(
set_ip_using
(
buf
,
SIOCSIFADDR
,
ip
)
==
-
1
)
...
...
include/interface.h
View file @
d1381f90
...
...
@@ -28,7 +28,7 @@ struct user_net_device_stats {
};
struct
interface
{
struct
interface
*
next
,
*
prev
;
struct
interface
*
next
,
*
prev
;
char
name
[
IFNAMSIZ
];
/* interface name */
short
type
;
/* if type */
short
flags
;
/* various flags */
...
...
@@ -87,7 +87,7 @@ extern const char *if_port_text[][4];
#endif
#if !defined(ifr_qlen)
/* Actually it is ifru_ivalue, but that is not present in 2.0 kernel headers */
/* Actually it is ifru_ivalue, but that is not present in 2.0 kernel headers */
#define ifr_qlen ifr_ifru.ifru_mtu
#endif
...
...
ipmaddr.c
View file @
d1381f90
...
...
@@ -400,7 +400,7 @@ int main(int argc, char **argv)
basename
=
argv
[
0
];
else
basename
++
;
while
(
argc
>
1
)
{
if
(
argv
[
1
][
0
]
!=
'-'
)
break
;
...
...
iptunnel.c
View file @
d1381f90
...
...
@@ -376,7 +376,7 @@ static int do_add(int cmd, int argc, char **argv)
return
do_add_ioctl
(
cmd
,
"gre0"
,
&
p
);
case
IPPROTO_IPV6
:
return
do_add_ioctl
(
cmd
,
"sit0"
,
&
p
);
default:
default:
fprintf
(
stderr
,
_
(
"cannot determine tunnel mode (ipip, gre or sit)
\n
"
));
return
-
1
;
}
...
...
@@ -391,13 +391,13 @@ int do_del(int argc, char **argv)
return
-
1
;
switch
(
p
.
iph
.
protocol
)
{
case
IPPROTO_IPIP
:
case
IPPROTO_IPIP
:
return
do_del_ioctl
(
p
.
name
[
0
]
?
p
.
name
:
"tunl0"
,
&
p
);
case
IPPROTO_GRE
:
case
IPPROTO_GRE
:
return
do_del_ioctl
(
p
.
name
[
0
]
?
p
.
name
:
"gre0"
,
&
p
);
case
IPPROTO_IPV6
:
case
IPPROTO_IPV6
:
return
do_del_ioctl
(
p
.
name
[
0
]
?
p
.
name
:
"sit0"
,
&
p
);
default:
default:
return
do_del_ioctl
(
p
.
name
,
&
p
);
}
return
-
1
;
...
...
@@ -538,7 +538,7 @@ static int do_show(int argc, char **argv)
return
-
1
;
switch
(
p
.
iph
.
protocol
)
{
case
IPPROTO_IPIP
:
case
IPPROTO_IPIP
:
err
=
do_get_ioctl
(
p
.
name
[
0
]
?
p
.
name
:
"tunl0"
,
&
p
);
break
;
case
IPPROTO_GRE
:
...
...
@@ -597,7 +597,7 @@ int main(int argc, char **argv)
basename
=
argv
[
0
];
else
basename
++
;
while
(
argc
>
1
)
{
if
(
argv
[
1
][
0
]
!=
'-'
)
break
;
...
...
lib/af.c
View file @
d1381f90
...
...
@@ -342,7 +342,7 @@ void print_aflist(int type) {
if
((
type
==
1
&&
((
*
afp
)
->
rprint
==
NULL
))
||
((
*
afp
)
->
af
==
0
))
{
afp
++
;
continue
;
}
if
((
count
%
3
)
==
0
)
fprintf
(
stderr
,
count
?
"
\n
"
:
" "
);
if
((
count
%
3
)
==
0
)
fprintf
(
stderr
,
count
?
"
\n
"
:
" "
);
txt
=
(
*
afp
)
->
name
;
if
(
!
txt
)
txt
=
".."
;
fprintf
(
stderr
,
"%s (%s) "
,
txt
,(
*
afp
)
->
title
);
count
++
;
...
...
lib/ash.c
View file @
d1381f90
...
...
@@ -57,7 +57,7 @@ pr_ash(const char *ptr)
struct
hwtype
ash_hwtype
;
static
int
static
int
in_ash
(
char
*
bufp
,
struct
sockaddr
*
sap
)
{
char
*
ptr
;
...
...
lib/ddp_gr.c
View file @
d1381f90
...
...
@@ -2,7 +2,7 @@
* lib/ddp_gr.c Prinbting of DDP (AppleTalk) routing table
* used by the NET-LIB.
*
* NET-LIB
* NET-LIB
*
* Version: $Id: ddp_gr.c,v 1.4 2002/06/02 05:25:15 ecki Exp $
*
...
...
@@ -87,7 +87,7 @@ int DDP_rprint(int options)
}
fclose
(
fp
);
return
0
;
}
...
...
lib/econet.c
View file @
d1381f90
...
...
@@ -54,7 +54,7 @@ ec_sprint(struct sockaddr *sap, int numeric)
return
ec_print
((
const
char
*
)
&
sec
->
addr
);
}
static
int
static
int
ec_input
(
int
type
,
char
*
bufp
,
struct
sockaddr
*
sap
)
{
struct
sockaddr_ec
*
sec
=
(
struct
sockaddr_ec
*
)
sap
;
...
...
lib/eui64.c
View file @
d1381f90
...
...
@@ -6,7 +6,7 @@
* Author: Daniel Stodden <stodden@in.tum.de>
* Copyright 2001 Daniel Stodden
*
* blueprinted from ether.c
* blueprinted from ether.c
* Copyright 1993 MicroWalt Corporation
*
* This program is free software; you can redistribute it
...
...
@@ -54,7 +54,7 @@ static const char *pr_eui64(const char *ptr)
static
char
buff
[
64
];
snprintf
(
buff
,
sizeof
(
buff
),
"%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X"
,
(
ptr
[
0
]
&
0377
),
(
ptr
[
1
]
&
0377
),
(
ptr
[
2
]
&
0377
),
(
ptr
[
3
]
&
0377
),
(
ptr
[
0
]
&
0377
),
(
ptr
[
1
]
&
0377
),
(
ptr
[
2
]
&
0377
),
(
ptr
[
3
]
&
0377
),
(
ptr
[
4
]
&
0377
),
(
ptr
[
5
]
&
0377
),
(
ptr
[
6
]
&
0377
),
(
ptr
[
7
]
&
0377
)
);
return
(
buff
);
...
...
@@ -79,7 +79,7 @@ static int in_eui64( char *bufp, struct sockaddr *sap )
i
=
0
;
orig
=
bufp
;
while
((
*
bufp
!=
'\0'
)
&&
(
i
<
EUI64_ALEN
))
{
val
=
0
;
c
=
*
bufp
++
;
...
...
@@ -120,7 +120,7 @@ static int in_eui64( char *bufp, struct sockaddr *sap )
*
ptr
++
=
(
unsigned
char
)
(
val
&
0377
);
i
++
;
/* We might get a semicolon here - not required. */
if
(
*
bufp
==
':'
)
{
if
(
_DEBUG
&&
i
==
EUI64_ALEN
)
...
...
lib/getargs.c
View file @
d1381f90
...
...
@@ -29,7 +29,7 @@
/* Split the input string into multiple fields. */
int
getargs
(
char
*
string
,
char
*
arguments
[])
{
int
len
=
strlen
(
string
);
int
len
=
strlen
(
string
);
char
temp
[
len
+
1
];
char
*
sp
,
*
ptr
;
int
i
,
argc
;
...
...
lib/hdlclapb.c
View file @
d1381f90
/*
* lib/hdlclapb.c
* lib/hdlclapb.c
* This file contains the HDLC/LAPB support for the NET-2 base
* distribution.
*
* Version: $Id: hdlclapb.c,v 1.5 2000/03/05 11:26:02 philip Exp $
*
* Original Author:
* Original Author:
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* Copyright 1993 MicroWalt Corporation
*
...
...
lib/hw.c
View file @
d1381f90
...
...
@@ -101,7 +101,7 @@ static struct hwtype *hwtypes[] =
#if HAVE_HWTR
&
tr_hwtype
,
#ifdef ARPHRD_IEEE802_TR
&
tr_hwtype1
,
&
tr_hwtype1
,
#endif
#endif
#if HAVE_HWAX25
...
...
@@ -221,7 +221,7 @@ void hwinit()
#if HAVE_HWTR
tr_hwtype
.
title
=
_
(
"16/4 Mbps Token Ring"
);
#ifdef ARPHRD_IEEE802_TR
tr_hwtype1
.
title
=
_
(
"16/4 Mbps Token Ring (New)"
)
;
tr_hwtype1
.
title
=
_
(
"16/4 Mbps Token Ring (New)"
)
;
#endif
#endif
#if HAVE_HWEC
...
...
@@ -285,7 +285,7 @@ void print_hwlist(int type) {
if
(((
type
==
1
)
&&
((
*
hwp
)
->
alen
==
0
))
||
((
*
hwp
)
->
type
==
-
1
))
{
hwp
++
;
continue
;
}
if
((
count
%
3
)
==
0
)
fprintf
(
stderr
,
count
?
"
\n
"
:
" "
);
if
((
count
%
3
)
==
0
)
fprintf
(
stderr
,
count
?
"
\n
"
:
" "
);
txt
=
(
*
hwp
)
->
name
;
if
(
!
txt
)
txt
=
".."
;
fprintf
(
stderr
,
"%s (%s) "
,
txt
,(
*
hwp
)
->
title
);
count
++
;
...
...
lib/inet.c
View file @
d1381f90
...
...
@@ -14,11 +14,11 @@
*960203 {1.23} Bernd Eckenfels : net-features support
*960217 {1.24} Bernd Eckenfels : get_sname
*960219 {1.25} Bernd Eckenfels : extern int h_errno
*960329 {1.26} Bernd Eckenfels : resolve 255.255.255.255
*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
*991007 Kurt Garloff : rresolve, resolve: may be hosts
* <garloff@suse.de> store type (host?) in cache
* <garloff@suse.de> store type (host?) in cache
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
...
...
@@ -96,9 +96,9 @@ static int INET_resolve(char *name, struct sockaddr_in *sin, int hostfirst)
#ifdef DEBUG
if
(
hostfirst
)
fprintf
(
stderr
,
"gethostbyname (%s)
\n
"
,
name
);
#endif
if
(
hostfirst
&&
if
(
hostfirst
&&
(
hp
=
gethostbyname
(
name
))
!=
(
struct
hostent
*
)
NULL
)
{
memcpy
((
char
*
)
&
sin
->
sin_addr
,
(
char
*
)
hp
->
h_addr_list
[
0
],
memcpy
((
char
*
)
&
sin
->
sin_addr
,
(
char
*
)
hp
->
h_addr_list
[
0
],
sizeof
(
struct
in_addr
));
return
0
;
}
...
...
@@ -127,18 +127,18 @@ static int INET_resolve(char *name, struct sockaddr_in *sin, int hostfirst)
errno
=
h_errno
;
return
-
1
;
}
memcpy
((
char
*
)
&
sin
->
sin_addr
,
(
char
*
)
hp
->
h_addr_list
[
0
],
memcpy
((
char
*
)
&
sin
->
sin_addr
,
(
char
*
)
hp
->
h_addr_list
[
0
],
sizeof
(
struct
in_addr
));
return
0
;
}
/* numeric: & 0x8000: default instead of *,
* & 0x4000: host instead of net,
/* numeric: & 0x8000: default instead of *,
* & 0x4000: host instead of net,
* & 0x0fff: don't resolve
*/
static
int
INET_rresolve
(
char
*
name
,
size_t
len
,
struct
sockaddr_in
*
sin
,
static
int
INET_rresolve
(
char
*
name
,
size_t
len
,
struct
sockaddr_in
*
sin
,
int
numeric
,
unsigned
int
netmask
)
{
struct
hostent
*
ent
;
...
...
@@ -243,21 +243,21 @@ static const 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
,
sizeof
(
buff
),
(
struct
sockaddr_in
*
)
sap
,
if
(
INET_rresolve
(
buff
,
sizeof
(
buff
),
(
struct
sockaddr_in
*
)
sap
,
numeric
,
0xffffff00
)
!=
0
)
return
(
NULL
);
return
(
buff
);
}
char
*
INET_sprintmask
(
struct
sockaddr
*
sap
,
int
numeric
,
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
,
sizeof
(
buff
),
(
struct
sockaddr_in
*
)
sap
,
if
(
INET_rresolve
(
buff
,
sizeof
(
buff
),
(
struct
sockaddr_in
*
)
sap
,
numeric
,
netmask
)
!=
0
)
return
(
NULL
);
return
(
buff
);
...
...
lib/inet6.c
View file @
d1381f90
...
...
@@ -44,20 +44,20 @@
extern
int
h_errno
;
/* some netdb.h versions don't export this */
char
*
fix_v4_address
(
char
*
buf
,
struct
in6_addr
*
in6
)
{
if
(
IN6_IS_ADDR_V4MAPPED
(
in6
->
s6_addr
))
{
char
*
s
=
strchr
(
buf
,
'.'
);
if
(
s
)
{
char
*
fix_v4_address
(
char
*
buf
,
struct
in6_addr
*
in6
)
{
if
(
IN6_IS_ADDR_V4MAPPED
(
in6
->
s6_addr
))
{
char
*
s
=
strchr
(
buf
,
'.'
);
if
(
s
)
{
while
(
s
>
buf
&&
*
s
!=
':'
)
--
s
;
if
(
*
s
==
':'
)
++
s
;
else
s
=
NULL
;
}
if
(
*
s
==
':'
)
++
s
;
else
s
=
NULL
;
}
if
(
s
)
return
s
;
}
return
buf
;
}
}
return
buf
;
}
static
int
INET6_resolve
(
char
*
name
,
struct
sockaddr_in6
*
sin6
)
{
...
...
@@ -163,8 +163,8 @@ static int INET6_getsock(char *bufp, struct sockaddr *sap)
if
(
inet_pton
(
AF_INET6
,
bufp
,
sin6
->
sin6_addr
.
s6_addr
)
<=
0
)
return
(
-
1
);
p
=
fix_v4_address
(
bufp
,
&
sin6
->
sin6_addr
);
if
(
p
!=
bufp
)
memcpy
(
bufp
,
p
,
strlen
(
p
)
+
1
);
if
(
p
!=
bufp
)
memcpy
(
bufp
,
p
,
strlen
(
p
)
+
1
);
return
16
;
/* ?;) */
}
...
...
lib/inet6_gr.c
View file @
d1381f90
...
...
@@ -63,7 +63,7 @@ int rprint_fib6(int ext, int numeric)
struct
sockaddr_in6
saddr6
,
snaddr6
;
int
num
,
iflags
,
metric
,
refcnt
,
use
,
prefix_len
,
slen
;
FILE
*
fp
=
fopen
(
_PATH_PROCNET_ROUTE6
,
"r"
);
char
addr6p
[
8
][
5
],
saddr6p
[
8
][
5
],
naddr6p
[
8
][
5
];
if
(
!
fp
)
{
...
...
@@ -101,7 +101,7 @@ int rprint_fib6(int ext, int numeric)
if
(
numeric
&
RTF_CACHE
)
continue
;
}
/* Fetch and resolve the target address. */
snprintf
(
addr6
,
sizeof
(
addr6
),
"%s:%s:%s:%s:%s:%s:%s:%s"
,
addr6p
[
0
],
addr6p
[
1
],
addr6p
[
2
],
addr6p
[
3
],
...
...
lib/inet_gr.c
View file @
d1381f90
...
...
@@ -33,7 +33,7 @@
#include "proc.h"
extern
struct
aftype
inet_aftype
;
extern
char
*
INET_sprintmask
(
struct
sockaddr
*
sap
,
int
numeric
,
extern
char
*
INET_sprintmask
(
struct
sockaddr
*
sap
,
int
numeric
,
unsigned
int
netmask
);
int
rprint_fib
(
int
ext
,
int
numeric
)
...
...
@@ -104,9 +104,9 @@ int rprint_fib(int ext, int numeric)
/* Fetch and resolve the genmask. */
(
void
)
inet_aftype
.
input
(
1
,
mask_addr
,
&
snet_mask
);
sin_netmask
=
(
struct
sockaddr_in
*
)
&
snet_mask
;
strcpy
(
net_addr
,
INET_sprintmask
(
&
snet_target
,
strcpy
(
net_addr
,
INET_sprintmask
(
&
snet_target
,
(
numeric
|
0x8000
|
(
iflags
&
RTF_HOST
?
0x4000
:
0
)),
sin_netmask
->
sin_addr
.
s_addr
));
net_addr
[
15
]
=
'\0'
;
...
...
@@ -221,17 +221,17 @@ int rprint_cache(int ext, int numeric)
return
1
;
}
/* Okay, first thing we need to know is the format of the rt_cache.
/* Okay, first thing we need to know is the format of the rt_cache.
* I am aware of two possible layouts:
* 2.2.0
* "Iface\tDestination\tGateway \tFlags\t\tRefCnt\tUse\tMetric\tSource\t\tMTU\tWindow\tIRTT\tTOS\tHHRef\tHHUptod\tSpecDst"
* "%s\t%08lX\t%08lX\t%8X\t%d\t%u\t%d\t%08lX\t%d\t%u\t%u\t%02X\t%d\t%1d\t%08X"
* "%s\t%08lX\t%08lX\t%8X\t%d\t%u\t%d\t%08lX\t%d\t%u\t%u\t%02X\t%d\t%1d\t%08X"
*
* 2.0.36
* "Iface\tDestination\tGateway \tFlags\tRefCnt\tUse\tMetric\tSource\t\tMTU\tWindow\tIRTT\tHH\tARP"
* "%s\t%08lX\t%08lX\t%02X\t%d\t%u\t%d\t%08lX\t%d\t%lu\t%u\t%d\t%1d"
*/
format
=
proc_guess_fmt
(
_PATH_PROCNET_RTCACHE
,
fp
,
"IRTT"
,
1
,
"TOS"
,
2
,
"HHRef"
,
4
,
"HHUptod"
,
8
,
"SpecDst"
,
16
,
"HH"
,
32
,
"ARP"
,
64
,
NULL
);
printf
(
_
(
"Kernel IP routing cache
\n
"
));
...
...
@@ -251,7 +251,7 @@ int rprint_cache(int ext, int numeric)
printf
(
"ERROR: proc_guess_fmt(%s,... returned: %d
\n
"
,
_PATH_PROCNET_RTCACHE
,
format
);
break
;
}
rewind
(
fp
);
if
(
ext
==
1
)
...
...
@@ -333,7 +333,7 @@ int rprint_cache(int ext, int numeric)
if
(
num
<
12
)
continue
;
}
/* Fetch and resolve the target address. */
(
void
)
inet_aftype
.
input
(
1
,
dest_addr
,
&
snet
);
...
...
lib/interface.c
View file @
d1381f90
/* Code to manipulate interface information, shared between ifconfig and
netstat.
netstat.
10/1998 partly rewriten by Andi Kleen to support an interface list.
I don't claim that the list operations are efficient @).
10/1998 partly rewriten by Andi Kleen to support an interface list.
I don't claim that the list operations are efficient @).
8/2000 Andi Kleen make the list operations a bit more efficient.
People are crazy enough to use thousands of aliases now.
...
...
@@ -103,23 +103,23 @@ static struct interface *if_cache_add(char *name)
/* the cache is sorted, so if we hit a smaller if, exit */
for
(
ife
=
int_last
;
ife
;
ife
=
ife
->
prev
)
{
int
n
=
nstrcmp
(
ife
->
name
,
name
);
if
(
n
==
0
)
return
ife
;
if
(
n
<
0
)
break
;
int
n
=
nstrcmp
(
ife
->
name
,
name
);
if
(
n
==
0
)
return
ife
;
if
(
n
<
0
)
break
;
}
new
(
new
);
safe_strncpy
(
new
->
name
,
name
,
IFNAMSIZ
);
new
(
new
);
safe_strncpy
(
new
->
name
,
name
,
IFNAMSIZ
);
nextp
=
ife
?
&
ife
->
next
:
&
int_list
;
// keep sorting
new
->
prev
=
ife
;
new
->
next
=
*
nextp
;
if
(
new
->
next
)
new
->
next
->
prev
=
new
;
new
->
next
=
*
nextp
;
if
(
new
->
next
)
new
->
next
->
prev
=
new
;
else
int_last
=
new
;
*
nextp
=
new
;
return
new
;
int_last
=
new
;
*
nextp
=
new
;
return
new
;
}
struct
interface
*
lookup_interface
(
char
*
name
)
...
...
@@ -131,7 +131,7 @@ struct interface *lookup_interface(char *name)
/* otherwise we read a limited list */
if
(
if_readlist_proc
(
name
)
<
0
)
return
NULL
;
return
if_cache_add
(
name
);
}
...
...
@@ -170,7 +170,7 @@ static int if_readconf(void)
int
skfd
;
/* SIOCGIFCONF currently seems to only work properly on AF_INET sockets
(as of 2.1.128) */
(as of 2.1.128) */
skfd
=
get_socket_for_af
(
AF_INET
);
if
(
skfd
<
0
)
{
fprintf
(
stderr
,
_
(
"warning: no inet socket available: %s
\n
"
),
...
...
@@ -323,9 +323,9 @@ static int if_readlist_proc(char *target)
fh
=
fopen
(
_PATH_PROCNET_DEV
,
"r"
);
if
(
!
fh
)
{
fprintf
(
stderr
,
_
(
"Warning: cannot open %s (%s). Limited output.
\n
"
),
_PATH_PROCNET_DEV
,
strerror
(
errno
));
_PATH_PROCNET_DEV
,
strerror
(
errno
));
return
-
2
;
}
}
if
(
fgets
(
buf
,
sizeof
buf
,
fh
))
/* eat line */
;
if
(
fgets
(
buf
,
sizeof
buf
,
fh
))
...
...
@@ -360,7 +360,7 @@ static int if_readlist_proc(char *target)
err
=
0
;
while
(
fgets
(
buf
,
sizeof
buf
,
fh
))
{
char
*
s
,
name
[
IFNAMSIZ
];
s
=
get_name
(
name
,
buf
);
s
=
get_name
(
name
,
buf
);
ife
=
if_cache_add
(
name
);
get_dev_fields
(
s
,
ife
);
ife
->
statistics_valid
=
1
;
...
...
@@ -379,10 +379,10 @@ static int if_readlist_proc(char *target)
return
err
;
}
int
if_readlist
(
void
)
{
/* caller will/should check not to call this too often
* (i.e. only if if_list_all == 0
int
if_readlist
(
void
)
{
/* caller will/should check not to call this too often
* (i.e. only if if_list_all == 0
*/
int
proc_err
,
conf_err
;
...
...
@@ -395,7 +395,7 @@ int if_readlist(void)
return
-
1
;
else
return
0
;
}
}
/* Support for fetching an IPX address */
...
...
@@ -412,7 +412,7 @@ int if_fetch(struct interface *ife)
{
struct
ifreq
ifr
;
int
fd
;
char
*
ifname
=
ife
->
name
;
char
*
ifname
=
ife
->
name
;
strcpy
(
ifr
.
ifr_name
,
ifname
);
if
(
ioctl
(
skfd
,
SIOCGIFFLAGS
,
&
ifr
)
<
0
)
...
...
@@ -562,29 +562,29 @@ int if_fetch(struct interface *ife)
}
int
do_if_fetch
(
struct
interface
*
ife
)
{
{
if
(
if_fetch
(
ife
)
<
0
)
{
char
*
errmsg
;
if
(
errno
==
ENODEV
)
{
/* Give better error message for this case. */
errmsg
=
_
(
"Device not found"
);
}
else
{
errmsg
=
strerror
(
errno
);
char
*
errmsg
;
if
(
errno
==
ENODEV
)
{
/* Give better error message for this case. */
errmsg
=
_
(
"Device not found"
);
}
else
{
errmsg
=
strerror
(
errno
);
}
fprintf
(
stderr
,
_
(
"%s: error fetching interface information: %s
\n
"
),
ife
->
name
,
errmsg
);
return
-
1
;
}
return
0
;
return
0
;
}
int
do_if_print
(
struct
interface
*
ife
,
void
*
cookie
)
{
int
*
opt_a
=
(
int
*
)
cookie
;
int
res
;
int
res
;
res
=
do_if_fetch
(
ife
);
if
(
res
>=
0
)
{
res
=
do_if_fetch
(
ife
);
if
(
res
>=
0
)
{
if
((
ife
->
flags
&
IFF_UP
)
||
*
opt_a
)
ife_print
(
ife
);
}
...
...
@@ -653,7 +653,7 @@ void ife_print_long(struct interface *ptr)
const
char
*
Rext
=
"B"
;
const
char
*
Text
=
"B"
;
static
char
flags
[
200
];
#if HAVE_AFIPX
static
struct
aftype
*
ipxtype
=
NULL
;
#endif
...
...
@@ -726,7 +726,7 @@ void ife_print_long(struct interface *ptr)
flags
[
strlen
(
flags
)
-
1
]
=
'>'
;
else
flags
[
strlen
(
flags
)
-
1
]
=
0
;
printf
(
_
(
"%s: %s mtu %d"
),
ptr
->
name
,
flags
,
ptr
->
mtu
);
...
...
@@ -768,8 +768,8 @@ void ife_print_long(struct interface *ptr)
addr6p
[
4
],
addr6p
[
5
],
addr6p
[
6
],
addr6p
[
7
]);
inet6_aftype
.
input
(
1
,
addr6
,
(
struct
sockaddr
*
)
&
sap
);
printf
(
_
(
" %s %s prefixlen %d"
),
inet6_aftype
.
name
,
inet6_aftype
.
sprint
((
struct
sockaddr
*
)
&
sap
,
1
),
inet6_aftype
.
name
,
inet6_aftype
.
sprint
((
struct
sockaddr
*
)
&
sap
,
1
),
plen
);
printf
(
_
(
" scopeid 0x%x"
),
scope
);
...
...
@@ -835,7 +835,7 @@ void ife_print_long(struct interface *ptr)
}
#endif
/* For some hardware types (eg Ash, ATM) we don't print the
/* For some hardware types (eg Ash, ATM) we don't print the
hardware address if it's null. */
if
(
hw
->
print
!=
NULL
&&
(
!
(
hw_null_address
(
hw
,
ptr
->
hwaddr
)
&&
hw
->
suppress_null_addr
)))
...
...
@@ -863,8 +863,8 @@ void ife_print_long(struct interface *ptr)
* not for the aliases, although strictly speaking they're shared
* by all addresses.
*/
rx
=
ptr
->
stats
.
rx_bytes
;
short_rx
=
rx
*
10
;
rx
=
ptr
->
stats
.
rx_bytes
;
short_rx
=
rx
*
10
;
if
(
rx
>
1125899906842624ull
)
{
short_rx
/=
1125899906842624ull
;
Rext
=
"PiB"
;
...
...
@@ -901,9 +901,9 @@ void ife_print_long(struct interface *ptr)
}
printf
(
" "
);
printf
(
_
(
"RX packets %llu bytes %llu (%lu.%lu %s)
\n
"
),
ptr
->
stats
.
rx_packets
,
rx
,
(
unsigned
long
)(
short_rx
/
10
),
printf
(
_
(
"RX packets %llu bytes %llu (%lu.%lu %s)
\n
"
),
ptr
->
stats
.
rx_packets
,
rx
,
(
unsigned
long
)(
short_rx
/
10
),
(
unsigned
long
)(
short_rx
%
10
),
Rext
);
if
(
can_compress
)
{
printf
(
" "
);
...
...
@@ -911,14 +911,14 @@ void ife_print_long(struct interface *ptr)
}
printf
(
" "
);
printf
(
_
(
"RX errors %lu dropped %lu overruns %lu frame %lu
\n
"
),
ptr
->
stats
.
rx_errors
,
ptr
->
stats
.
rx_dropped
,
ptr
->
stats
.
rx_errors
,
ptr
->
stats
.
rx_dropped
,
ptr
->
stats
.
rx_fifo_errors
,
ptr
->
stats
.
rx_frame_errors
);
printf
(
" "
);
printf
(
_
(
"TX packets %llu bytes %llu (%lu.%lu %s)
\n
"
),
ptr
->
stats
.
tx_packets
,
tx
,
(
unsigned
long
)(
short_tx
/
10
),
ptr
->
stats
.
tx_packets
,
tx
,
(
unsigned
long
)(
short_tx
/
10
),
(
unsigned
long
)(
short_tx
%
10
),
Text
);
if
(
can_compress
)
{
printf
(
" "
);
...
...
@@ -936,7 +936,7 @@ void ife_print_long(struct interface *ptr)
printf
(
" device "
);
if
(
ptr
->
map
.
irq
)
printf
(
_
(
"interrupt %d "
),
ptr
->
map
.
irq
);
if
(
ptr
->
map
.
base_addr
>=
0x100
)
/* Only print devices using it for
if
(
ptr
->
map
.
base_addr
>=
0x100
)
/* Only print devices using it for
I/O maps */
printf
(
_
(
"base 0x%x "
),
ptr
->
map
.
base_addr
);
if
(
ptr
->
map
.
mem_start
)
{
...
...
lib/ipx.c
View file @
d1381f90
...
...
@@ -133,7 +133,7 @@ static int IPX_input(int type, char *bufp, struct sockaddr *sap)
if
(
!
sai
)
return
(
-
1
);
sai
->
sipx_family
=
AF_IPX
;
sai
->
sipx_network
=
htonl
(
0
);
sai
->
sipx_node
[
0
]
=
sai
->
sipx_node
[
1
]
=
sai
->
sipx_node
[
2
]
=
...
...
lib/ipx_gr.c
View file @
d1381f90
...
...
@@ -47,7 +47,7 @@ int IPX_rprint(int options)
if
(
!
fp
)
{
fp
=
fopen
(
_PATH_PROCNET_IPX_ROUTE2
,
"r"
);
}
if
(
!
fp
)
{
perror
(
NULL
);
printf
(
_
(
"IPX routing not in file %s or %s found.
\n
"
),
_PATH_PROCNET_IPX_ROUTE1
,
_PATH_PROCNET_IPX_ROUTE2
);
...
...
lib/irda.c
View file @
d1381f90
/*********************************************************************
*
*
* Filename: irda.c
* Version: 0.2
* Description: A second attempt to make ifconfig understand IrDA
...
...
@@ -10,22 +10,22 @@
* Modified by: Dag Brattli <dagb@cs.uit.no>
* Modified at: Wed May 1 11:51:44 CEST 2002
* Modified by: Christoph Bartelmus <christoph@bartelmus.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
********************************************************************/
#include "config.h"
...
...
@@ -63,7 +63,7 @@ static const char *irda_print(const char *ptr)
{
static
char
buff
[
12
];
snprintf
(
buff
,
12
,
"%02x:%02x:%02x:%02x"
,
ptr
[
3
],
ptr
[
2
],
snprintf
(
buff
,
12
,
"%02x:%02x:%02x:%02x"
,
ptr
[
3
],
ptr
[
2
],
ptr
[
1
],
ptr
[
0
]);
return
(
buff
);
...
...
lib/net-features.h
View file @
d1381f90
...
...
@@ -20,7 +20,7 @@
* your option) any later version.
*/
/*
/*
* This needs to be included AFTER the KErnel Header Files
* one of the FEATURE_ should be defined to get the Feature Variable
* definition included
...
...
lib/net-support.h
View file @
d1381f90
...
...
@@ -46,7 +46,7 @@ struct aftype {
int
(
*
rinput
)
(
int
typ
,
int
ext
,
char
**
argv
);
/* may modify src */
int
(
*
getmask
)
(
char
*
src
,
struct
sockaddr
*
mask
,
char
*
name
);
int
(
*
getmask
)
(
char
*
src
,
struct
sockaddr
*
mask
,
char
*
name
);
int
fd
;
char
*
flag_file
;
...
...
lib/netrom.c
View file @
d1381f90
...
...
@@ -11,7 +11,7 @@
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* Copyright 1993 MicroWalt Corporation
*
*
* Changes:
* 980701 {1.21} Arnaldo Carvalho de Melo - GNU gettext instead of catgets,
* strncpy instead of strcpy for
...
...
lib/netrom_gr.c
View file @
d1381f90
...
...
@@ -10,7 +10,7 @@
*
* Changes:
* 980701 {0.02} Arnaldo Carvalho de Melo GNU gettext instead of catgets
*
*
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
...
...
lib/nstrcmp.c
View file @
d1381f90
/* Copyright 1998 by Andi Kleen. Subject to the GPL. */
/* rewritten by bernd eckenfels because of complicated alias semantic */
/* $Id: nstrcmp.c,v 1.4 2004/06/03 22:49:17 ecki Exp $ */
/* $Id: nstrcmp.c,v 1.4 2004/06/03 22:49:17 ecki Exp $ */
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -12,7 +12,7 @@ char* cutalias(char* name)
{
int
digit
=
0
;
int
pos
;
for
(
pos
=
strlen
(
name
);
pos
>
0
;
pos
--
)
{
if
(
name
[
pos
-
1
]
==
':'
&&
digit
)
...
...
@@ -58,41 +58,41 @@ int nstrcmp(const char *ap, const char *bp)
if
(
res
!=
0
)
{
free
(
a
);
free
(
b
);
return
res
;
}
if
(
aindex
>
bindex
)
{
free
(
a
);
free
(
b
);
return
1
;
}
if
(
aindex
<
bindex
)
{
free
(
a
);
free
(
b
);
return
-
1
;
}
an
=
a
+
aindex
;
bn
=
b
+
bindex
;
av
=
atoi
(
an
);
bv
=
atoi
(
bn
);
if
(
av
<
bv
)
{
free
(
a
);
free
(
b
);
return
-
1
;
}
if
(
av
>
bv
)
{
free
(
a
);
free
(
b
);
return
1
;
}
av
=
-
1
;
if
(
aalias
!=
NULL
)
av
=
atoi
(
aalias
);
bv
=
-
1
;
if
(
balias
!=
NULL
)
bv
=
atoi
(
balias
);
free
(
a
);
free
(
b
);
if
(
av
<
bv
)
return
-
1
;
if
(
av
>
bv
)
return
1
;
return
0
;
}
...
...
@@ -118,7 +118,7 @@ int dotest(char* a, char* b, int exp)
int
main
()
{
int
err
=
0
;
err
|=
dotest
(
"eth1"
,
"eth1"
,
0
);
err
|=
dotest
(
"eth0:1"
,
"eth0:1"
,
0
);
err
|=
dotest
(
"lan"
,
"lan"
,
0
);
...
...
@@ -129,7 +129,7 @@ int main()
err
|=
dotest
(
"a:"
,
"a:"
,
0
);
err
|=
dotest
(
":a"
,
":a"
,
0
);
err
|=
dotest
(
"a"
,
"aa"
,
-
1
);
err
|=
dotest
(
"a"
,
"aa"
,
-
1
);
err
|=
dotest
(
"eth0"
,
"eth1"
,
-
1
);
err
|=
dotest
(
"eth1"
,
"eth20"
,
-
1
);
err
|=
dotest
(
"eth20"
,
"eth100"
,
-
1
);
...
...
@@ -139,10 +139,10 @@ int main()
err
|=
dotest
(
"eth1:10"
,
"eth13:10"
,
-
1
);
err
|=
dotest
(
"eth1:1"
,
"eth1:13"
,
-
1
);
err
|=
dotest
(
"a"
,
"a:"
,
-
1
);
err
|=
dotest
(
"aa"
,
"a"
,
1
);
err
|=
dotest
(
"eth2"
,
"eth1"
,
1
);
err
|=
dotest
(
"eth13"
,
"eth1"
,
1
);
err
|=
dotest
(
"eth13"
,
"eth1"
,
1
);
err
|=
dotest
(
"eth2"
,
"eth"
,
1
);
err
|=
dotest
(
"eth2:10"
,
"eth2:1"
,
1
);
err
|=
dotest
(
"eth2:5"
,
"eth2:4"
,
1
);
...
...
lib/pathnames.h
View file @
d1381f90
/*
* lib/pathnames.h This file contains the definitions of the path
* lib/pathnames.h This file contains the definitions of the path
* names used by the NET-LIB.
*
* NET-LIB
* NET-LIB
*
* Version: lib/pathnames.h 1.37 (1997-08-23)
*
...
...
lib/ppp.c
View file @
d1381f90
...
...
@@ -8,7 +8,7 @@
* Copyright 1993 MicroWalt Corporation
*
* Modified by Alan Cox, May 94 to cover NET-3
*
*
* Changes:
* 980701 {1.12} Arnaldo Carvalho de Melo - GNU gettext instead of catgets
*
...
...
lib/proc.c
View file @
d1381f90
/* Tolerant /proc file parser. Copyright 1998 Andi Kleen */
/* $Id: proc.c,v 1.5 2007/12/01 18:44:57 ecki Exp $ */
/* Fixme: cannot currently cope with removed fields */
/* $Id: proc.c,v 1.5 2007/12/01 18:44:57 ecki Exp $ */
/* Fixme: cannot currently cope with removed fields */
#include <string.h>
#include <stdarg.h>
...
...
@@ -51,7 +51,7 @@ char *proc_gen_fmt(char *name, int more, FILE * fh,...)
return
strdup
(
format
);
}
/*
/*
* this will generate a bitmask of present/missing fields in the header of
* a /proc file.
*/
...
...
@@ -84,12 +84,12 @@ FILE *proc_fopen(const char *name)
if
(
fd
==
NULL
)
return
NULL
;
if
(
!
buffer
)
{
pagesz
=
getpagesize
();
buffer
=
malloc
(
pagesz
);
}
setvbuf
(
fd
,
buffer
,
_IOFBF
,
pagesz
);
return
fd
;
}
lib/proc.h
View file @
d1381f90
/*
/*
* prototypes for proc.c
*/
char
*
proc_gen_fmt
(
char
*
name
,
int
more
,
FILE
*
fh
,...);
...
...
lib/tr.c
View file @
d1381f90
...
...
@@ -63,11 +63,11 @@ static int in_tr(char *bufp, struct sockaddr *sap)
int
i
,
val
;
#ifdef ARPHRD_IEEE802_TR
if
(
kernel_version
()
<
KRELEASE
(
2
,
3
,
30
))
{
if
(
kernel_version
()
<
KRELEASE
(
2
,
3
,
30
))
{
sap
->
sa_family
=
tr_hwtype
.
type
;
}
else
{
}
else
{
sap
->
sa_family
=
tr_hwtype1
.
type
;
}
}
#else
sap
->
sa_family
=
tr_hwtype
.
type
;
#warning "Limited functionality, no support for ARPHRD_IEEE802_TR (old kernel headers?)"
...
...
lib/util.c
View file @
d1381f90
/* Copyright 1998 by Andi Kleen. Subject to the GPL. */
/* Copyright 1998 by Andi Kleen. Subject to the GPL. */
/* $Id: util.c,v 1.4 1998/11/17 15:17:02 freitag Exp $ */
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -43,9 +43,9 @@ int kernel_version(void)
}
/* Like strncpy but make sure the resulting string is always 0 terminated. */
/* Like strncpy but make sure the resulting string is always 0 terminated. */
char
*
safe_strncpy
(
char
*
dst
,
const
char
*
src
,
size_t
size
)
{
{
dst
[
size
-
1
]
=
'\0'
;
return
strncpy
(
dst
,
src
,
size
-
1
);
return
strncpy
(
dst
,
src
,
size
-
1
);
}
lib/util.h
View file @
d1381f90
...
...
@@ -12,7 +12,7 @@ int kernel_version(void);
int
nstrcmp
(
const
char
*
,
const
char
*
);
char
*
safe_strncpy
(
char
*
dst
,
const
char
*
src
,
size_t
size
);
char
*
safe_strncpy
(
char
*
dst
,
const
char
*
src
,
size_t
size
);
#define netmin(a,b) ((a)<(b) ? (a) : (b))
...
...
lib/x25.c
View file @
d1381f90
...
...
@@ -156,7 +156,7 @@ struct hwtype x25_hwtype = {
};
struct
aftype
x25_aftype
=
{
{
"x25"
,
NULL
,
/*"CCITT X.25", */
AF_X25
,
X25_ADDR_LEN
,
X25_print
,
X25_sprint
,
X25_input
,
X25_herror
,
X25_rprint
,
X25_rinput
,
NULL
/* getmask */
,
...
...
lib/x25_sr.c
View file @
d1381f90
...
...
@@ -112,7 +112,7 @@ static int X25_setroute(int action, int options, char **args)
perror
(
"socket"
);
return
(
E_SOCK
);
}
/* Tell the kernel to accept this route. */
if
(
action
==
RTACTION_DEL
)
{
if
(
ioctl
(
skfd
,
SIOCDELRT
,
&
rt
)
<
0
)
{
...
...
@@ -138,14 +138,14 @@ int X25_rinput(int action, int options, char **args)
if
(
action
==
RTACTION_FLUSH
)
{
fprintf
(
stderr
,
"Flushing `x25' routing table not supported
\n
"
);
return
(
usage
());
}
}
if
(
options
&
FLAG_CACHE
)
{
fprintf
(
stderr
,
"Modifying `x25' routing cache not supported
\n
"
);
return
(
usage
());
}
}
if
((
*
args
==
NULL
)
||
(
action
==
RTACTION_HELP
))
return
(
usage
());
return
(
X25_setroute
(
action
,
options
,
args
));
}
#endif
/* HAVE_AFX25 */
mii-tool.c
View file @
d1381f90
...
...
@@ -169,7 +169,7 @@ const struct {
{
"1000baseT"
,
{
0
,
ADVERTISE_1000HALF
|
ADVERTISE_1000FULL
}
},
};
#define NMEDIA (sizeof(media)/sizeof(media[0]))
/* Parse an argument list of media types */
static
int
parse_media
(
char
*
arg
,
unsigned
*
bmcr2
)
{
...
...
@@ -479,7 +479,7 @@ int main(int argc, char **argv)
{
int
i
,
c
,
ret
,
errflag
=
0
;
unsigned
ctrl1000
=
0
;
while
((
c
=
getopt_long
(
argc
,
argv
,
"A:F:p:lrRvVw?"
,
longopts
,
0
))
!=
EOF
)
switch
(
c
)
{
case
'A'
:
nway_advertise
=
parse_media
(
optarg
,
&
ctrl1000
);
break
;
...
...
@@ -515,7 +515,7 @@ int main(int argc, char **argv)
}
if
(
verbose
>
1
)
printf
(
"Using SIOCGMIIPHY=0x%x
\n
"
,
SIOCGMIIPHY
);
printf
(
"Using SIOCGMIIPHY=0x%x
\n
"
,
SIOCGMIIPHY
);
/* No remaining args means show all interfaces. */
if
(
optind
==
argc
)
{
...
...
nameif.c
View file @
d1381f90
/*
/*
* Name Interfaces based on MAC address.
* Writen 2000 by Andi Kleen.
* Subject to the Gnu Public License, version 2.
* Subject to the Gnu Public License, version 2.
* TODO: make it support token ring etc.
* $Id: nameif.c,v 1.4 2003/09/11 03:46:49 ak Exp $
*/
#ifndef _GNU_SOURCE
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <stdio.h>
...
...
@@ -21,68 +21,68 @@
#include <net/if.h>
#include <linux/sockios.h>
#include <errno.h>
#include "intl.h"
#include "intl.h"
#include "net-support.h"
#include "util.h"
const
char
default_conf
[]
=
"/etc/mactab"
;
const
char
*
fname
=
default_conf
;
int
use_syslog
;
int
ctl_sk
=
-
1
;
void
err
(
char
*
msg
)
{
if
(
use_syslog
)
{
syslog
(
LOG_ERR
,
"%s: %m"
,
msg
);
}
else
{
perror
(
msg
);
}
exit
(
1
);
const
char
default_conf
[]
=
"/etc/mactab"
;
const
char
*
fname
=
default_conf
;
int
use_syslog
;
int
ctl_sk
=
-
1
;
void
err
(
char
*
msg
)
{
if
(
use_syslog
)
{
syslog
(
LOG_ERR
,
"%s: %m"
,
msg
);
}
else
{
perror
(
msg
);
}
exit
(
1
);
}
void
complain
(
char
*
fmt
,
...)
{
void
complain
(
char
*
fmt
,
...)
{
va_list
ap
;
va_start
(
ap
,
fmt
);
if
(
use_syslog
)
{
if
(
use_syslog
)
{
vsyslog
(
LOG_ERR
,
fmt
,
ap
);
}
else
{
vfprintf
(
stderr
,
fmt
,
ap
);
fputc
(
'\n'
,
stderr
);
fputc
(
'\n'
,
stderr
);
}
va_end
(
ap
);
va_end
(
ap
);
exit
(
1
);
}
}
void
warning
(
char
*
fmt
,
...)
{
void
warning
(
char
*
fmt
,
...)
{
va_list
ap
;
va_start
(
ap
,
fmt
);
if
(
use_syslog
)
{
if
(
use_syslog
)
{
vsyslog
(
LOG_ERR
,
fmt
,
ap
);
}
else
{
vfprintf
(
stderr
,
fmt
,
ap
);
fputc
(
'\n'
,
stderr
);
fputc
(
'\n'
,
stderr
);
}
va_end
(
ap
);
}
va_end
(
ap
);
}
int
parsemac
(
char
*
str
,
unsigned
char
*
mac
)
{
char
*
s
;
while
((
s
=
strsep
(
&
str
,
":"
))
!=
NULL
)
{
{
char
*
s
;
while
((
s
=
strsep
(
&
str
,
":"
))
!=
NULL
)
{
unsigned
byte
;
if
(
sscanf
(
s
,
"%x"
,
&
byte
)
!=
1
||
byte
>
0xff
)
if
(
sscanf
(
s
,
"%x"
,
&
byte
)
!=
1
||
byte
>
0xff
)
return
-
1
;
*
mac
++
=
byte
;
}
*
mac
++
=
byte
;
}
return
0
;
}
}
void
opensock
(
void
)
{
if
(
ctl_sk
<
0
)
ctl_sk
=
socket
(
PF_INET
,
SOCK_DGRAM
,
0
);
if
(
ctl_sk
<
0
)
ctl_sk
=
socket
(
PF_INET
,
SOCK_DGRAM
,
0
);
}
#ifndef ifr_newname
...
...
@@ -92,7 +92,7 @@ void opensock(void)
int
setname
(
char
*
oldname
,
char
*
newname
)
{
struct
ifreq
ifr
;
opensock
();
opensock
();
memset
(
&
ifr
,
0
,
sizeof
(
struct
ifreq
));
safe_strncpy
(
ifr
.
ifr_name
,
oldname
,
IFNAMSIZ
);
safe_strncpy
(
ifr
.
ifr_newname
,
newname
,
IFNAMSIZ
);
...
...
@@ -103,107 +103,107 @@ int getmac(char *name, unsigned char *mac)
{
int
r
;
struct
ifreq
ifr
;
opensock
();
opensock
();
memset
(
&
ifr
,
0
,
sizeof
(
struct
ifreq
));
safe_strncpy
(
ifr
.
ifr_name
,
name
,
IFNAMSIZ
);
r
=
ioctl
(
ctl_sk
,
SIOCGIFHWADDR
,
&
ifr
);
memcpy
(
mac
,
ifr
.
ifr_hwaddr
.
sa_data
,
6
);
return
r
;
memcpy
(
mac
,
ifr
.
ifr_hwaddr
.
sa_data
,
6
);
return
r
;
}
struct
change
{
struct
change
{
struct
change
*
next
;
int
found
;
char
ifname
[
IFNAMSIZ
+
1
];
unsigned
char
mac
[
6
];
};
};
struct
change
*
clist
;
struct
change
*
lookupmac
(
unsigned
char
*
mac
)
{
struct
change
*
lookupmac
(
unsigned
char
*
mac
)
{
struct
change
*
ch
;
for
(
ch
=
clist
;
ch
;
ch
=
ch
->
next
)
for
(
ch
=
clist
;
ch
;
ch
=
ch
->
next
)
if
(
!
memcmp
(
ch
->
mac
,
mac
,
6
))
return
ch
;
return
NULL
;
}
return
NULL
;
}
int
addchange
(
char
*
p
,
struct
change
*
ch
,
char
*
pos
)
{
if
(
strchr
(
ch
->
ifname
,
':'
))
warning
(
_
(
"alias device %s at %s probably has no mac"
),
ch
->
ifname
,
pos
);
if
(
parsemac
(
p
,
ch
->
mac
)
<
0
)
complain
(
_
(
"cannot parse MAC `%s' at %s"
),
p
,
pos
);
warning
(
_
(
"alias device %s at %s probably has no mac"
),
ch
->
ifname
,
pos
);
if
(
parsemac
(
p
,
ch
->
mac
)
<
0
)
complain
(
_
(
"cannot parse MAC `%s' at %s"
),
p
,
pos
);
ch
->
next
=
clist
;
clist
=
ch
;
return
0
;
return
0
;
}
void
readconf
(
void
)
{
char
*
line
;
size_t
linel
;
int
linenum
;
char
*
line
;
size_t
linel
;
int
linenum
;
FILE
*
ifh
;
char
*
p
;
int
n
;
struct
change
*
ch
=
NULL
;
ifh
=
fopen
(
fname
,
"r"
);
if
(
!
ifh
)
complain
(
_
(
"opening configuration file %s: %s"
),
fname
,
strerror
(
errno
));
if
(
!
ifh
)
complain
(
_
(
"opening configuration file %s: %s"
),
fname
,
strerror
(
errno
));
line
=
NULL
;
line
=
NULL
;
linel
=
0
;
linenum
=
1
;
linenum
=
1
;
while
(
getdelim
(
&
line
,
&
linel
,
'\n'
,
ifh
)
>
0
)
{
char
pos
[
20
];
char
pos
[
20
];
sprintf
(
pos
,
_
(
"line %d"
),
linenum
);
sprintf
(
pos
,
_
(
"line %d"
),
linenum
);
if
((
p
=
strchr
(
line
,
'#'
))
!=
NULL
)
*
p
=
'\0'
;
p
=
line
;
p
=
line
;
while
(
isspace
(
*
p
))
++
p
;
++
p
;
if
(
*
p
==
'\0'
)
continue
;
n
=
strcspn
(
p
,
"
\t
"
);
if
(
n
>
IFNAMSIZ
-
1
)
complain
(
_
(
"interface name too long at line %d"
),
line
);
continue
;
n
=
strcspn
(
p
,
"
\t
"
);
if
(
n
>
IFNAMSIZ
-
1
)
complain
(
_
(
"interface name too long at line %d"
),
line
);
ch
=
xmalloc
(
sizeof
(
struct
change
));
memcpy
(
ch
->
ifname
,
p
,
n
);
ch
->
ifname
[
n
]
=
0
;
p
+=
n
;
p
+=
strspn
(
p
,
"
\t
"
);
n
=
strspn
(
p
,
"0123456789ABCDEFabcdef:"
);
p
[
n
]
=
0
;
memcpy
(
ch
->
ifname
,
p
,
n
);
ch
->
ifname
[
n
]
=
0
;
p
+=
n
;
p
+=
strspn
(
p
,
"
\t
"
);
n
=
strspn
(
p
,
"0123456789ABCDEFabcdef:"
);
p
[
n
]
=
0
;
addchange
(
p
,
ch
,
pos
);
linenum
++
;
}
fclose
(
ifh
);
}
fclose
(
ifh
);
}
struct
option
lopt
[]
=
{
struct
option
lopt
[]
=
{
{
"syslog"
,
0
,
NULL
,
's'
},
{
"config-file"
,
1
,
NULL
,
'c'
},
{
"help"
,
0
,
NULL
,
'?'
},
{
NULL
},
};
{
"help"
,
0
,
NULL
,
'?'
},
{
NULL
},
};
void
usage
(
void
)
{
fprintf
(
stderr
,
_
(
"usage: nameif [-c configurationfile] [-s] {ifname macaddress}
\n
"
));
fprintf
(
stderr
,
_
(
"usage: nameif [-c configurationfile] [-s] {ifname macaddress}
\n
"
));
exit
(
E_USAGE
);
}
int
main
(
int
ac
,
char
**
av
)
{
FILE
*
ifh
;
int
main
(
int
ac
,
char
**
av
)
{
FILE
*
ifh
;
char
*
p
;
int
n
;
int
linenum
;
int
linenum
;
char
*
line
=
NULL
;
size_t
linel
=
0
;
int
ret
=
0
;
...
...
@@ -211,10 +211,10 @@ int main(int ac, char **av)
for
(;;)
{
int
c
=
getopt_long
(
ac
,
av
,
"c:s"
,
lopt
,
NULL
);
if
(
c
==
-
1
)
break
;
switch
(
c
)
{
switch
(
c
)
{
default:
case
'?'
:
usage
();
usage
();
case
'c'
:
fname
=
optarg
;
break
;
...
...
@@ -224,76 +224,76 @@ int main(int ac, char **av)
}
}
if
(
use_syslog
)
if
(
use_syslog
)
openlog
(
"nameif"
,
0
,
LOG_LOCAL0
);
while
(
optind
<
ac
)
{
struct
change
*
ch
=
xmalloc
(
sizeof
(
struct
change
));
while
(
optind
<
ac
)
{
struct
change
*
ch
=
xmalloc
(
sizeof
(
struct
change
));
char
pos
[
30
];
if
((
ac
-
optind
)
&
1
)
if
((
ac
-
optind
)
&
1
)
usage
();
if
(
strlen
(
av
[
optind
])
+
1
>
IFNAMSIZ
)
if
(
strlen
(
av
[
optind
])
+
1
>
IFNAMSIZ
)
complain
(
_
(
"interface name `%s' too long"
),
av
[
optind
]);
strcpy
(
ch
->
ifname
,
av
[
optind
]);
optind
++
;
sprintf
(
pos
,
_
(
"argument %d"
),
optind
);
addchange
(
av
[
optind
],
ch
,
pos
);
optind
++
;
}
strcpy
(
ch
->
ifname
,
av
[
optind
]);
optind
++
;
sprintf
(
pos
,
_
(
"argument %d"
),
optind
);
addchange
(
av
[
optind
],
ch
,
pos
);
optind
++
;
}
if
(
!
clist
||
fname
!=
default_conf
)
readconf
();
if
(
!
clist
||
fname
!=
default_conf
)
readconf
();
ifh
=
fopen
(
"/proc/net/dev"
,
"r"
);
if
(
!
ifh
)
complain
(
_
(
"open of /proc/net/dev: %s"
),
strerror
(
errno
));
ifh
=
fopen
(
"/proc/net/dev"
,
"r"
);
if
(
!
ifh
)
complain
(
_
(
"open of /proc/net/dev: %s"
),
strerror
(
errno
));
linenum
=
0
;
while
(
getdelim
(
&
line
,
&
linel
,
'\n'
,
ifh
)
>
0
)
{
struct
change
*
ch
;
struct
change
*
ch
;
unsigned
char
mac
[
6
];
if
(
linenum
++
<
2
)
if
(
linenum
++
<
2
)
continue
;
p
=
line
;
while
(
isspace
(
*
p
))
p
=
line
;
while
(
isspace
(
*
p
))
++
p
;
n
=
strcspn
(
p
,
":
\t
"
);
p
[
n
]
=
0
;
if
(
n
>
IFNAMSIZ
-
1
)
complain
(
_
(
"interface name `%s' too long"
),
p
);
if
(
getmac
(
p
,
mac
)
<
0
)
n
=
strcspn
(
p
,
":
\t
"
);
p
[
n
]
=
0
;
if
(
n
>
IFNAMSIZ
-
1
)
complain
(
_
(
"interface name `%s' too long"
),
p
);
if
(
getmac
(
p
,
mac
)
<
0
)
continue
;
ch
=
lookupmac
(
mac
);
if
(
!
ch
)
ch
=
lookupmac
(
mac
);
if
(
!
ch
)
continue
;
ch
->
found
=
1
;
if
(
strcmp
(
p
,
ch
->
ifname
))
{
if
(
setname
(
p
,
ch
->
ifname
)
<
0
)
ch
->
found
=
1
;
if
(
strcmp
(
p
,
ch
->
ifname
))
{
if
(
setname
(
p
,
ch
->
ifname
)
<
0
)
complain
(
_
(
"cannot change name of %s to %s: %s"
),
p
,
ch
->
ifname
,
strerror
(
errno
));
}
}
fclose
(
ifh
);
while
(
clist
)
{
p
,
ch
->
ifname
,
strerror
(
errno
));
}
}
fclose
(
ifh
);
while
(
clist
)
{
struct
change
*
ch
=
clist
;
clist
=
clist
->
next
;
if
(
!
ch
->
found
){
warning
(
_
(
"interface '%s' not found"
),
ch
->
ifname
);
warning
(
_
(
"interface '%s' not found"
),
ch
->
ifname
);
ret
=
1
;
}
free
(
ch
);
free
(
ch
);
}
if
(
use_syslog
)
closelog
();
return
ret
;
}
}
netstat.c
View file @
d1381f90
...
...
@@ -23,24 +23,24 @@
* Modified:
*
*960116 {1.01} Bernd Eckenfels: verbose, cleanups
*960204 {1.10} Bernd Eckenfels: aftrans, usage, new route_info,
*960204 {1.10} Bernd Eckenfels: aftrans, usage, new route_info,
* DLFT_AF
*960204 {1.11} Bernd Eckenfels: netlink support
*960204 {1.12} Bernd Eckenfels: route_init()
*960215 {1.13} Bernd Eckenfels: netlink_print honors HAVE_
*960217 {1.14} Bernd Eckenfels: masq_info from Jos Vos and
*960217 {1.14} Bernd Eckenfels: masq_info from Jos Vos and
* ax25_info from Jonathan Naylor.
*960218 {1.15} Bernd Eckenfels: ipx_info rewritten, -e for tcp/ipx
*960220 {1.16} Bernd Eckenfels: minor output reformats, -a for -x
*960221 {1.17} Bernd Eckenfels: route_init->getroute_init
*960426 {1.18} Bernd Eckenfels: new RTACTION, SYM/NUM, FIB/CACHE
*960517 {1.19} Bernd Eckenfels: usage() spelling fix and --unix inode,
*960517 {1.19} Bernd Eckenfels: usage() spelling fix and --unix inode,
* ':' is part of sock_addr for --inet
*960822 {x.xx} Frank Strauss: INET6 support
*
*970406 {1.33} Philip Copeland Added snmp reporting support module -s
* code provided by Andi Kleen
* (relly needs to be kernel hooked but
* (relly needs to be kernel hooked but
* this will do in the meantime)
* minor header file misplacement tidy up.
*980815 {1.xx} Stephane Fillod: X.25 support
...
...
@@ -58,7 +58,7 @@
*
*990420 {1.38} Tuan Hoang removed a useless assignment from igmp_do_one()
*20010404 {1.39} Arnaldo Carvalho de Melo - use setlocale
*20081201 {1.42} Brian Micek added -L|--udplite options for RFC 3828
*20081201 {1.42} Brian Micek added -L|--udplite options for RFC 3828
*20020722 {1.51} Thomas Preusser added SCTP over IPv4 support
*
* This program is free software; you can redistribute it
...
...
@@ -289,18 +289,18 @@ static void prg_cache_add(unsigned long inode, char *name, const char *scon)
return
;
}
}
if
(
!
(
*
pnp
=
malloc
(
sizeof
(
**
pnp
))))
if
(
!
(
*
pnp
=
malloc
(
sizeof
(
**
pnp
))))
return
;
pn
=
*
pnp
;
pn
->
next
=
NULL
;
pn
->
inode
=
inode
;
if
(
strlen
(
name
)
>
sizeof
(
pn
->
name
)
-
1
)
if
(
strlen
(
name
)
>
sizeof
(
pn
->
name
)
-
1
)
name
[
sizeof
(
pn
->
name
)
-
1
]
=
'\0'
;
strcpy
(
pn
->
name
,
name
);
{
int
len
=
(
strlen
(
scon
)
-
sizeof
(
pn
->
scon
))
+
1
;
if
(
len
>
0
)
if
(
len
>
0
)
strcpy
(
pn
->
scon
,
&
scon
[
len
+
1
]);
else
strcpy
(
pn
->
scon
,
scon
);
...
...
@@ -356,7 +356,7 @@ static int extract_type_1_socket_inode(const char lname[], unsigned long * inode
*/
if
(
strlen
(
lname
)
<
PRG_SOCKET_PFXl
+
3
)
return
(
-
1
);
if
(
memcmp
(
lname
,
PRG_SOCKET_PFX
,
PRG_SOCKET_PFXl
))
return
(
-
1
);
if
(
lname
[
strlen
(
lname
)
-
1
]
!=
']'
)
return
(
-
1
);
...
...
@@ -417,17 +417,17 @@ static void prg_cache_load(void)
if
(
!
(
dirproc
=
opendir
(
PATH_PROC
)))
goto
fail
;
while
(
errno
=
0
,
direproc
=
readdir
(
dirproc
))
{
for
(
cs
=
direproc
->
d_name
;
*
cs
;
cs
++
)
if
(
!
isdigit
(
*
cs
))
if
(
!
isdigit
(
*
cs
))
break
;
if
(
*
cs
)
if
(
*
cs
)
continue
;
procfdlen
=
snprintf
(
line
,
sizeof
(
line
),
PATH_PROC_X_FD
,
direproc
->
d_name
);
if
(
procfdlen
<=
0
||
procfdlen
>=
sizeof
(
line
)
-
5
)
if
(
procfdlen
<=
0
||
procfdlen
>=
sizeof
(
line
)
-
5
)
continue
;
errno
=
0
;
dirfd
=
opendir
(
line
);
if
(
!
dirfd
)
{
if
(
errno
==
EACCES
)
if
(
errno
==
EACCES
)
eacces
=
1
;
continue
;
}
...
...
@@ -437,7 +437,7 @@ static void prg_cache_load(void)
/* Skip . and .. */
if
(
!
isdigit
(
direfd
->
d_name
[
0
]))
continue
;
if
(
procfdlen
+
1
+
strlen
(
direfd
->
d_name
)
+
1
>
sizeof
(
line
))
if
(
procfdlen
+
1
+
strlen
(
direfd
->
d_name
)
+
1
>
sizeof
(
line
))
continue
;
memcpy
(
line
+
procfdlen
-
PATH_FD_SUFFl
,
PATH_FD_SUFF
"/"
,
PATH_FD_SUFFl
+
1
);
...
...
@@ -452,23 +452,23 @@ static void prg_cache_load(void)
continue
;
if
(
!
cmdlp
)
{
if
(
procfdlen
-
PATH_FD_SUFFl
+
PATH_CMDLINEl
>=
sizeof
(
line
)
-
5
)
if
(
procfdlen
-
PATH_FD_SUFFl
+
PATH_CMDLINEl
>=
sizeof
(
line
)
-
5
)
continue
;
strcpy
(
line
+
procfdlen
-
PATH_FD_SUFFl
,
PATH_CMDLINE
);
fd
=
open
(
line
,
O_RDONLY
);
if
(
fd
<
0
)
if
(
fd
<
0
)
continue
;
cmdllen
=
read
(
fd
,
cmdlbuf
,
sizeof
(
cmdlbuf
)
-
1
);
if
(
close
(
fd
))
if
(
close
(
fd
))
continue
;
if
(
cmdllen
==
-
1
)
if
(
cmdllen
==
-
1
)
continue
;
if
(
cmdllen
<
sizeof
(
cmdlbuf
)
-
1
)
if
(
cmdllen
<
sizeof
(
cmdlbuf
)
-
1
)
cmdlbuf
[
cmdllen
]
=
'\0'
;
if
(
cmdlbuf
[
0
]
==
'/'
&&
(
cmdlp
=
strrchr
(
cmdlbuf
,
'/'
)))
if
(
cmdlbuf
[
0
]
==
'/'
&&
(
cmdlp
=
strrchr
(
cmdlbuf
,
'/'
)))
cmdlp
++
;
else
else
cmdlp
=
cmdlbuf
;
}
...
...
@@ -483,14 +483,14 @@ static void prg_cache_load(void)
prg_cache_add
(
inode
,
finbuf
,
"-"
);
#endif
}
closedir
(
dirfd
);
closedir
(
dirfd
);
dirfd
=
NULL
;
}
if
(
dirproc
)
if
(
dirproc
)
closedir
(
dirproc
);
if
(
dirfd
)
if
(
dirfd
)
closedir
(
dirfd
);
if
(
!
eacces
)
if
(
!
eacces
)
return
;
if
(
prg_cache_loaded
==
1
)
{
fail:
...
...
@@ -669,7 +669,7 @@ static void igmp_do_one(int lnr, const char *line,const char *prot)
((
struct
sockaddr
*
)
&
mcastaddr
)
->
sa_family
);
return
;
}
safe_strncpy
(
mcast_addr
,
ap
->
sprint
((
struct
sockaddr
*
)
&
mcastaddr
,
safe_strncpy
(
mcast_addr
,
ap
->
sprint
((
struct
sockaddr
*
)
&
mcastaddr
,
flag_not
&
FLAG_NUM_HOST
),
sizeof
(
mcast_addr
));
printf
(
"%-15s %-6d %s
\n
"
,
device
,
refcnt
,
mcast_addr
);
#endif
...
...
@@ -701,13 +701,13 @@ static void igmp_do_one(int lnr, const char *line,const char *prot)
fprintf
(
stderr
,
_
(
"warning, got bogus igmp line %d.
\n
"
),
lnr
);
return
;
}
if
((
ap
=
get_afntype
(((
struct
sockaddr
*
)
&
mcastaddr
)
->
sa_family
))
==
NULL
)
{
fprintf
(
stderr
,
_
(
"netstat: unsupported address family %d !
\n
"
),
((
struct
sockaddr
*
)
&
mcastaddr
)
->
sa_family
);
return
;
}
safe_strncpy
(
mcast_addr
,
ap
->
sprint
((
struct
sockaddr
*
)
&
mcastaddr
,
safe_strncpy
(
mcast_addr
,
ap
->
sprint
((
struct
sockaddr
*
)
&
mcastaddr
,
flag_not
&
FLAG_NUM_HOST
),
sizeof
(
mcast_addr
));
printf
(
"%-15s %-6d %s
\n
"
,
device
,
refcnt
,
mcast_addr
);
#endif
...
...
@@ -762,7 +762,7 @@ static int x25_info(void)
vr
,
vs
,
sendq
,
recvq
);
}
fclose
(
f
);
return
0
;
return
0
;
}
#endif
...
...
@@ -815,7 +815,7 @@ static void print_ip_service(struct sockaddr_in *addr, char const *protname,
else
buf
[
size
-
2
-
bfsl
]
=
'\0'
;
}
else
bfs
[
size
-
2
-
bufl
]
=
'\0'
;
}
}
}
strcat
(
buf
,
":"
);
strcat
(
buf
,
bfs
);
...
...
@@ -1186,7 +1186,7 @@ static int udp_info(void)
static
int
udplite_info
(
void
)
{
INFO_GUTS6
(
_PATH_PROCNET_UDPLITE
,
_PATH_PROCNET_UDPLITE6
,
INFO_GUTS6
(
_PATH_PROCNET_UDPLITE
,
_PATH_PROCNET_UDPLITE6
,
"AF INET (udplite)"
,
udp_do_one
,
"udpl"
,
"udpl6"
);
}
...
...
@@ -1213,7 +1213,7 @@ static void raw_do_one(int lnr, const char *line,const char *prot)
"%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %lu %*s
\n
"
,
&
d
,
local_addr
,
&
local_port
,
rem_addr
,
&
rem_port
,
&
state
,
&
txq
,
&
rxq
,
&
timer_run
,
&
time_len
,
&
retr
,
&
uid
,
&
timeout
,
&
inode
);
if
(
num
<
10
)
{
fprintf
(
stderr
,
_
(
"warning, got bogus raw line.
\n
"
));
return
;
...
...
@@ -1559,7 +1559,7 @@ static int ipx_info(void)
struct
sockaddr
sa
;
unsigned
sport
=
0
,
dport
=
0
;
struct
stat
s
;
f
=
proc_fopen
(
_PATH_PROCNET_IPX_SOCKET1
);
if
(
!
f
)
{
if
(
errno
!=
ENOENT
)
{
...
...
@@ -2046,18 +2046,18 @@ int main
if
(
flag_int
+
flag_rou
+
flag_mas
+
flag_sta
>
1
)
usage
();
if
((
flag_inet
||
flag_inet6
||
flag_sta
)
&&
if
((
flag_inet
||
flag_inet6
||
flag_sta
)
&&
!
(
flag_tcp
||
flag_sctp
||
flag_udp
||
flag_udplite
||
flag_raw
))
flag_tcp
=
flag_sctp
=
flag_udp
=
flag_udplite
=
flag_raw
=
1
;
if
((
flag_tcp
||
flag_sctp
||
flag_udp
||
flag_udplite
||
flag_raw
||
flag_igmp
)
&&
if
((
flag_tcp
||
flag_sctp
||
flag_udp
||
flag_udplite
||
flag_raw
||
flag_igmp
)
&&
!
(
flag_inet
||
flag_inet6
))
flag_inet
=
flag_inet6
=
1
;
if
(
flag_bluetooth
&&
!
(
flag_l2cap
||
flag_rfcomm
))
flag_l2cap
=
flag_rfcomm
=
1
;
flag_arg
=
flag_tcp
+
flag_sctp
+
flag_udplite
+
flag_udp
+
flag_raw
+
flag_unx
flag_arg
=
flag_tcp
+
flag_sctp
+
flag_udplite
+
flag_udp
+
flag_raw
+
flag_unx
+
flag_ipx
+
flag_ax25
+
flag_netrom
+
flag_igmp
+
flag_x25
+
flag_rose
+
flag_l2cap
+
flag_rfcomm
;
...
...
@@ -2084,7 +2084,7 @@ int main
if
(
flag_sta
)
{
if
(
!
afname
[
0
])
strcpy
(
afname
,
DFLT_AF
);
if
(
!
strcmp
(
afname
,
"inet"
))
{
#if HAVE_AFINET
inittab
();
...
...
@@ -2105,7 +2105,7 @@ int main
}
exit
(
0
);
}
if
(
flag_rou
)
{
int
options
=
0
;
...
...
plipconfig.c
View file @
d1381f90
...
...
@@ -4,7 +4,7 @@
Copyright (c) 1994 John Paul Morrison (VE7JPM).
version 0.2
Changed by Alan Cox, to reflect the way SIOCDEVPRIVATE is meant to work
and for the extra parameter added by Niibe.
...
...
route.c
View file @
d1381f90
...
...
@@ -10,7 +10,7 @@
* (derived from FvK's 'route.c 1.70 01/04/94')
*
* Modifications:
* Johannes Stille: for Net-2Debugged by
* Johannes Stille: for Net-2Debugged by
* <johannes@titan.os.open.de>
* Linus Torvalds: Misc Changes
* Alan Cox: add the new mtu/window stuff
...
...
@@ -19,7 +19,7 @@
* {1.80} Bernd Eckenfels: reject, metric, irtt, 1.2.x support.
* {1.81} Bernd Eckenfels: reject routes need a dummy device
*960127 {1.82} Bernd Eckenfels: 'mod' and 'dyn' 'reinstate' added
*960129 {1.83} Bernd Eckenfels: resolve and getsock now in lib/,
*960129 {1.83} Bernd Eckenfels: resolve and getsock now in lib/,
* REJECT displays '-' as gatway.
*960202 {1.84} Bernd Eckenfels: net-features support added
*960203 {1.85} Bernd Eckenfels: "#ifdef' in '#if' for net-features
...
...
slattach.c
View file @
d1381f90
...
...
@@ -40,7 +40,7 @@
#include <limits.h>
#include <pwd.h>
#include <signal.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
...
...
@@ -82,7 +82,7 @@ struct {
const
char
*
speed
;
int
code
;
}
tty_speeds
[]
=
{
/* table of usable baud rates */
{
"50"
,
B50
},
{
"75"
,
B75
},
{
"50"
,
B50
},
{
"75"
,
B75
},
{
"110"
,
B110
},
{
"300"
,
B300
},
{
"600"
,
B600
},
{
"1200"
,
B1200
},
{
"2400"
,
B2400
},
{
"4800"
,
B4800
},
...
...
@@ -151,7 +151,7 @@ tty_already_locked(char *nam)
/* that lock. */
i
=
fscanf
(
fd
,
"%d"
,
&
pid
);
(
void
)
fclose
(
fd
);
if
(
i
!=
1
)
/* Lock file format's wrong! Kill't */
return
(
0
);
...
...
@@ -298,7 +298,7 @@ tty_set_parity(struct termios *tty, char *parity)
switch
(
toupper
(
*
parity
))
{
case
'N'
:
tty
->
c_cflag
&=
~
(
PARENB
|
PARODD
);
break
;
break
;
case
'O'
:
tty
->
c_cflag
&=
~
(
PARENB
|
PARODD
);
...
...
@@ -347,7 +347,7 @@ tty_set_raw(struct termios *tty)
tty
->
c_lflag
=
(
0
);
/* local flags */
speed
=
(
tty
->
c_cflag
&
CBAUD
);
/* save current speed */
tty
->
c_cflag
=
(
HUPCL
|
CREAD
);
/* UART flags */
if
(
opt_L
)
if
(
opt_L
)
tty
->
c_cflag
|=
CLOCAL
;
else
tty
->
c_cflag
|=
CRTSCTS
;
...
...
@@ -416,7 +416,7 @@ static int
tty_get_name
(
char
*
name
)
{
if
(
ioctl
(
tty_fd
,
SIOCGIFNAME
,
name
)
<
0
)
{
if
(
opt_q
==
0
)
if
(
opt_q
==
0
)
perror
(
"tty_get_name"
);
return
(
-
errno
);
}
...
...
@@ -470,7 +470,7 @@ tty_open(char *name, const char *speed)
if
(
name
!=
NULL
)
{
if
(
name
[
0
]
!=
'/'
)
{
if
(
strlen
(
name
+
6
)
>
sizeof
(
pathbuf
))
{
if
(
opt_q
==
0
)
fprintf
(
stderr
,
if
(
opt_q
==
0
)
fprintf
(
stderr
,
_
(
"slattach: tty name too long
\n
"
));
return
(
-
1
);
}
...
...
@@ -531,7 +531,7 @@ tty_open(char *name, const char *speed)
if
(
tty_get_disc
(
&
tty_sdisc
)
<
0
)
{
if
(
opt_q
==
0
)
fprintf
(
stderr
,
_
(
"slattach: tty_open: cannot get current line disc!
\n
"
));
return
(
-
errno
);
}
}
tty_ldisc
=
tty_sdisc
;
/* Put this terminal line in a 8-bit transparent mode. */
...
...
@@ -597,7 +597,7 @@ usage(void)
}
static
void
static
void
version
(
void
)
{
printf
(
"%s
\n
%s
\n
"
,
Release
,
Signature
);
...
...
@@ -694,7 +694,7 @@ main(int argc, char *argv[])
usage
();
/*NOTREACHED*/
}
if
(
setvbuf
(
stdout
,
0
,
_IOLBF
,
0
))
{
if
(
opt_q
==
0
)
fprintf
(
stderr
,
_
(
"slattach: setvbuf(stdout,0,_IOLBF,0) : %s
\n
"
),
strerror
(
errno
));
...
...
statistics.c
View file @
d1381f90
/*
* Copyright 1997,1999,2000 Andi Kleen. Subject to the GPL.
* Copyright 1997,1999,2000 Andi Kleen. Subject to the GPL.
* $Id: statistics.c,v 1.23 2010-10-29 19:24:36 ecki Exp $
* 19980630 - i18n - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* 19981113 - i18n fixes - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* 19990101 - added net/netstat, -t, -u, -w supprt - Bernd Eckenfels
* 19980630 - i18n - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* 19981113 - i18n fixes - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* 19990101 - added net/netstat, -t, -u, -w supprt - Bernd Eckenfels
*/
#include <ctype.h>
#include <stdio.h>
...
...
@@ -36,26 +36,26 @@ struct entry {
enum
State
type
;
};
struct
statedesc
{
struct
statedesc
{
int
indent
;
char
*
title
;
};
char
*
title
;
};
struct
statedesc
states
[]
=
{
struct
statedesc
states
[]
=
{
[
number
]
=
{
4
,
NULL
},
[
opt_number
]
=
{
4
,
NULL
},
[
opt_number
]
=
{
4
,
NULL
},
[
i_forward
]
=
{
4
,
NULL
},
[
i_inp_icmp
]
=
{
8
,
N_
(
"ICMP input histogram:"
)
},
[
i_outp_icmp
]
=
{
8
,
N_
(
"ICMP output histogram:"
)
},
[
MaxState
]
=
{
0
},
};
};
static
enum
State
state
;
#define I_STATIC (1<<16)
/* static configuration option. */
#define I_TITLE (1<<17)
/*
/*
* XXX check against the snmp mib rfc.
*
* Don't mark the first field as translatable! It's a snmp MIB standard.
...
...
@@ -218,19 +218,19 @@ struct entry Tcpexttab[] =
{
"SyncookiesFailed"
,
N_
(
"%llu invalid SYN cookies received"
),
opt_number
},
{
"EmbryonicRsts"
,
N_
(
"%llu resets received for embryonic SYN_RECV sockets"
),
opt_number
},
opt_number
},
{
"PruneCalled"
,
N_
(
"%llu packets pruned from receive queue because of socket"
" buffer overrun"
),
opt_number
},
" buffer overrun"
),
opt_number
},
/* obsolete: 2.2.0 doesn't do that anymore */
{
"RcvPruned"
,
N_
(
"%llu packets pruned from receive queue"
),
opt_number
},
{
"OfoPruned"
,
N_
(
"%llu packets dropped from out-of-order queue because of"
" socket buffer overrun"
),
opt_number
},
" socket buffer overrun"
),
opt_number
},
{
"OutOfWindowIcmps"
,
N_
(
"%llu ICMP packets dropped because they were "
"out-of-window"
),
opt_number
},
"out-of-window"
),
opt_number
},
{
"LockDroppedIcmps"
,
N_
(
"%llu ICMP packets dropped because"
" socket was locked"
),
opt_number
},
{
"TW"
,
N_
(
"%llu TCP sockets finished time wait in fast timer"
),
opt_number
},
{
"TWRecycled"
,
N_
(
"%llu time wait sockets recycled by time stamp"
),
opt_number
},
{
"TWRecycled"
,
N_
(
"%llu time wait sockets recycled by time stamp"
),
opt_number
},
{
"TWKilled"
,
N_
(
"%llu TCP sockets finished time wait in slow timer"
),
opt_number
},
{
"PAWSPassive"
,
N_
(
"%llu passive connections rejected because of"
" time stamp"
),
opt_number
},
...
...
@@ -254,8 +254,8 @@ struct entry Tcpexttab[] =
{
"TCPHPHits"
,
N_
(
"%llu packet headers predicted"
),
number
},
{
"TCPHPHitsToUser"
,
N_
(
"%llu packets header predicted and "
"directly queued to user"
),
opt_number
},
{
"SockMallocOOM"
,
N_
(
"Ran %llu times out of system memory during "
"packet sending"
),
opt_number
},
{
"SockMallocOOM"
,
N_
(
"Ran %llu times out of system memory during "
"packet sending"
),
opt_number
},
{
"TCPPureAcks"
,
N_
(
"%llu acknowledgments not containing data payload received"
),
opt_number
},
{
"TCPHPAcks"
,
N_
(
"%llu predicted acknowledgments"
),
opt_number
},
{
"TCPRenoRecovery"
,
N_
(
"%llu times recovered from packet loss due to fast retransmit"
),
opt_number
},
...
...
@@ -303,7 +303,7 @@ struct tabtab {
char
*
title
;
struct
entry
*
tab
;
size_t
size
;
int
*
flag
;
int
*
flag
;
};
struct
tabtab
snmptabs
[]
=
...
...
@@ -339,11 +339,11 @@ void printval(struct tabtab *tab, char *title, unsigned long long val)
char
buf
[
512
];
key
.
title
=
title
;
if
(
tab
->
tab
)
if
(
tab
->
tab
)
ent
=
bsearch
(
&
key
,
tab
->
tab
,
tab
->
size
/
sizeof
(
struct
entry
),
sizeof
(
struct
entry
),
cmpentries
);
if
(
!
ent
)
{
/* try our best */
if
(
val
)
if
(
val
)
printf
(
"%*s%s: %llu
\n
"
,
states
[
state
].
indent
,
""
,
title
,
val
);
return
;
}
...
...
@@ -364,7 +364,7 @@ void printval(struct tabtab *tab, char *title, unsigned long long val)
buf
[
0
]
=
'\0'
;
switch
(
type
)
{
case
opt_number
:
if
(
val
==
0
)
if
(
val
==
0
)
break
;
/*FALL THOUGH*/
case
number
:
...
...
@@ -394,7 +394,7 @@ struct tabtab *newtable(struct tabtab *tabs, char *title)
{
struct
tabtab
*
t
;
static
struct
tabtab
dummytab
;
for
(
t
=
tabs
;
t
->
title
;
t
++
)
{
if
(
!
strcmp
(
title
,
t
->
title
))
{
if
(
*
(
t
->
flag
))
...
...
@@ -403,11 +403,11 @@ struct tabtab *newtable(struct tabtab *tabs, char *title)
return
t
;
}
}
if
(
!
f_unknown
)
return
NULL
;
if
(
!
f_unknown
)
return
NULL
;
printf
(
"%s:
\n
"
,
_
(
title
));
dummytab
.
title
=
title
;
dummytab
.
flag
=
&
f_unknown
;
dummytab
.
flag
=
&
f_unknown
;
return
&
dummytab
;
}
...
...
@@ -421,7 +421,7 @@ int process_fd(FILE *f, int all, char *filter)
if
(
buf1
[
0
]
==
'\n'
)
// skip empty first line in 2.6 kernels
continue
;
if
(
!
fgets
(
buf2
,
sizeof
buf2
,
f
))
break
;
sp
=
strchr
(
buf1
,
':'
);
...
...
@@ -444,8 +444,8 @@ int process_fd(FILE *f, int all, char *filter)
endflag
=
0
;
while
(
!
endflag
)
{
sp
+=
strspn
(
sp
,
"
\t\n
"
);
np
+=
strspn
(
np
,
"
\t\n
"
);
sp
+=
strspn
(
sp
,
"
\t\n
"
);
np
+=
strspn
(
np
,
"
\t\n
"
);
/*if (*np == '\0') goto formaterr; */
p
=
sp
+
strcspn
(
sp
,
"
\t\n
"
);
...
...
@@ -453,14 +453,14 @@ int process_fd(FILE *f, int all, char *filter)
endflag
=
1
;
*
p
=
'\0'
;
if
(
*
sp
!=
'\0'
&&
*
(
tab
->
flag
))
if
(
*
sp
!=
'\0'
&&
*
(
tab
->
flag
))
printval
(
tab
,
sp
,
strtoull
(
np
,
&
np
,
10
));
sp
=
p
+
1
;
}
}
return
0
;
formaterr:
return
-
1
;
}
...
...
@@ -507,7 +507,7 @@ void parsesnmp(int flag_raw, int flag_tcp, int flag_udp)
FILE
*
f
;
f_raw
=
flag_raw
;
f_tcp
=
flag_tcp
;
f_udp
=
flag_udp
;
f
=
proc_fopen
(
"/proc/net/snmp"
);
if
(
!
f
)
{
perror
(
_
(
"cannot open /proc/net/snmp"
));
...
...
@@ -530,12 +530,12 @@ void parsesnmp(int flag_raw, int flag_tcp, int flag_udp)
if
(
ferror
(
f
))
perror
(
"/proc/net/netstat"
);
fclose
(
f
);
}
return
;
}
void
parsesnmp6
(
int
flag_raw
,
int
flag_tcp
,
int
flag_udp
)
{
FILE
*
f
;
...
...
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