Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iproute2
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
iproute2
Commits
c7699875
Commit
c7699875
authored
Jul 07, 2004
by
net[shemminger]!shemminger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import patch ipxfrm-20040707_2.diff
(Logical change 1.53)
parent
7798b523
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
2284 additions
and
15 deletions
+2284
-15
include/libnetlink.h
include/libnetlink.h
+2
-0
include/utils.h
include/utils.h
+11
-4
ip/Makefile
ip/Makefile
+1
-1
ip/ip.c
ip/ip.c
+5
-1
ip/ip_common.h
ip/ip_common.h
+1
-0
ip/ipxfrm.c
ip/ipxfrm.c
+808
-0
ip/xfrm.h
ip/xfrm.h
+102
-0
ip/xfrm_policy.c
ip/xfrm_policy.c
+671
-0
ip/xfrm_state.c
ip/xfrm_state.c
+636
-0
lib/libnetlink.c
lib/libnetlink.c
+20
-2
lib/utils.c
lib/utils.c
+27
-7
No files found.
include/libnetlink.h
View file @
c7699875
...
@@ -15,6 +15,7 @@ struct rtnl_handle
...
@@ -15,6 +15,7 @@ struct rtnl_handle
};
};
extern
int
rtnl_open
(
struct
rtnl_handle
*
rth
,
unsigned
subscriptions
);
extern
int
rtnl_open
(
struct
rtnl_handle
*
rth
,
unsigned
subscriptions
);
extern
int
rtnl_open_byproto
(
struct
rtnl_handle
*
rth
,
unsigned
subscriptions
,
int
protocol
);
extern
void
rtnl_close
(
struct
rtnl_handle
*
rth
);
extern
void
rtnl_close
(
struct
rtnl_handle
*
rth
);
extern
int
rtnl_wilddump_request
(
struct
rtnl_handle
*
rth
,
int
fam
,
int
type
);
extern
int
rtnl_wilddump_request
(
struct
rtnl_handle
*
rth
,
int
fam
,
int
type
);
extern
int
rtnl_dump_request
(
struct
rtnl_handle
*
rth
,
int
type
,
void
*
req
,
int
len
);
extern
int
rtnl_dump_request
(
struct
rtnl_handle
*
rth
,
int
type
,
void
*
req
,
int
len
);
...
@@ -36,6 +37,7 @@ extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data);
...
@@ -36,6 +37,7 @@ extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data);
extern
int
rta_addattr_l
(
struct
rtattr
*
rta
,
int
maxlen
,
int
type
,
void
*
data
,
int
alen
);
extern
int
rta_addattr_l
(
struct
rtattr
*
rta
,
int
maxlen
,
int
type
,
void
*
data
,
int
alen
);
extern
int
parse_rtattr
(
struct
rtattr
*
tb
[],
int
max
,
struct
rtattr
*
rta
,
int
len
);
extern
int
parse_rtattr
(
struct
rtattr
*
tb
[],
int
max
,
struct
rtattr
*
rta
,
int
len
);
extern
int
parse_rtattr_byindex
(
struct
rtattr
*
tb
[],
int
max
,
struct
rtattr
*
rta
,
int
len
);
extern
int
rtnl_listen
(
struct
rtnl_handle
*
,
int
(
*
handler
)(
struct
sockaddr_nl
*
,
struct
nlmsghdr
*
n
,
void
*
),
extern
int
rtnl_listen
(
struct
rtnl_handle
*
,
int
(
*
handler
)(
struct
sockaddr_nl
*
,
struct
nlmsghdr
*
n
,
void
*
),
void
*
jarg
);
void
*
jarg
);
...
...
include/utils.h
View file @
c7699875
...
@@ -22,6 +22,9 @@ extern char * _SL_;
...
@@ -22,6 +22,9 @@ extern char * _SL_;
#ifndef IPPROTO_AH
#ifndef IPPROTO_AH
#define IPPROTO_AH 51
#define IPPROTO_AH 51
#endif
#endif
#ifndef IPPROTO_COMP
#define IPPROTO_COMP 108
#endif
#define SPRINT_BSIZE 64
#define SPRINT_BSIZE 64
#define SPRINT_BUF(x) char x[SPRINT_BSIZE]
#define SPRINT_BUF(x) char x[SPRINT_BSIZE]
...
@@ -29,6 +32,8 @@ extern char * _SL_;
...
@@ -29,6 +32,8 @@ extern char * _SL_;
extern
void
incomplete_command
(
void
)
__attribute__
((
noreturn
));
extern
void
incomplete_command
(
void
)
__attribute__
((
noreturn
));
#define NEXT_ARG() do { argv++; if (--argc <= 0) incomplete_command(); } while(0)
#define NEXT_ARG() do { argv++; if (--argc <= 0) incomplete_command(); } while(0)
#define NEXT_ARG_OK() (argc - 1 > 0)
#define PREV_ARG() do { argv--; argc++; } while(0)
typedef
struct
typedef
struct
{
{
...
@@ -56,17 +61,18 @@ struct ipx_addr {
...
@@ -56,17 +61,18 @@ struct ipx_addr {
u_int8_t
ipx_node
[
IPX_NODE_LEN
];
u_int8_t
ipx_node
[
IPX_NODE_LEN
];
};
};
extern
__u32
get_addr32
(
char
*
name
);
extern
__u32
get_addr32
(
c
onst
c
har
*
name
);
extern
int
get_addr_1
(
inet_prefix
*
dst
,
const
char
*
arg
,
int
family
);
extern
int
get_addr_1
(
inet_prefix
*
dst
,
const
char
*
arg
,
int
family
);
extern
int
get_prefix_1
(
inet_prefix
*
dst
,
char
*
arg
,
int
family
);
extern
int
get_prefix_1
(
inet_prefix
*
dst
,
c
onst
c
har
*
arg
,
int
family
);
extern
int
get_addr
(
inet_prefix
*
dst
,
char
*
arg
,
int
family
);
extern
int
get_addr
(
inet_prefix
*
dst
,
c
onst
c
har
*
arg
,
int
family
);
extern
int
get_prefix
(
inet_prefix
*
dst
,
char
*
arg
,
int
family
);
extern
int
get_prefix
(
inet_prefix
*
dst
,
c
onst
c
har
*
arg
,
int
family
);
extern
int
get_integer
(
int
*
val
,
const
char
*
arg
,
int
base
);
extern
int
get_integer
(
int
*
val
,
const
char
*
arg
,
int
base
);
extern
int
get_unsigned
(
unsigned
*
val
,
const
char
*
arg
,
int
base
);
extern
int
get_unsigned
(
unsigned
*
val
,
const
char
*
arg
,
int
base
);
#define get_byte get_u8
#define get_byte get_u8
#define get_ushort get_u16
#define get_ushort get_u16
#define get_short get_s16
#define get_short get_s16
extern
int
get_u64
(
__u64
*
val
,
const
char
*
arg
,
int
base
);
extern
int
get_u32
(
__u32
*
val
,
const
char
*
arg
,
int
base
);
extern
int
get_u32
(
__u32
*
val
,
const
char
*
arg
,
int
base
);
extern
int
get_u16
(
__u16
*
val
,
const
char
*
arg
,
int
base
);
extern
int
get_u16
(
__u16
*
val
,
const
char
*
arg
,
int
base
);
extern
int
get_s16
(
__s16
*
val
,
const
char
*
arg
,
int
base
);
extern
int
get_s16
(
__s16
*
val
,
const
char
*
arg
,
int
base
);
...
@@ -81,6 +87,7 @@ extern const char *format_host(int af, int len, const void *addr,
...
@@ -81,6 +87,7 @@ extern const char *format_host(int af, int len, const void *addr,
extern
const
char
*
rt_addr_n2a
(
int
af
,
int
len
,
const
void
*
addr
,
extern
const
char
*
rt_addr_n2a
(
int
af
,
int
len
,
const
void
*
addr
,
char
*
buf
,
int
buflen
);
char
*
buf
,
int
buflen
);
void
missarg
(
const
char
*
)
__attribute__
((
noreturn
));
void
invarg
(
const
char
*
,
const
char
*
)
__attribute__
((
noreturn
));
void
invarg
(
const
char
*
,
const
char
*
)
__attribute__
((
noreturn
));
void
duparg
(
const
char
*
,
const
char
*
)
__attribute__
((
noreturn
));
void
duparg
(
const
char
*
,
const
char
*
)
__attribute__
((
noreturn
));
void
duparg2
(
const
char
*
,
const
char
*
)
__attribute__
((
noreturn
));
void
duparg2
(
const
char
*
,
const
char
*
)
__attribute__
((
noreturn
));
...
...
ip/Makefile
View file @
c7699875
IPOBJ
=
ip.o ipaddress.o iproute.o iprule.o
\
IPOBJ
=
ip.o ipaddress.o iproute.o iprule.o
\
rtm_map.o iptunnel.o ipneigh.o iplink.o ipmaddr.o
\
rtm_map.o iptunnel.o ipneigh.o iplink.o ipmaddr.o
\
ipmonitor.o ipmroute.o
ipmonitor.o ipmroute.o
ipxfrm.o xfrm_state.o xfrm_policy.o
RTMONOBJ
=
rtmon.o
RTMONOBJ
=
rtmon.o
...
...
ip/ip.c
View file @
c7699875
...
@@ -40,7 +40,7 @@ static void usage(void)
...
@@ -40,7 +40,7 @@ static void usage(void)
fprintf
(
stderr
,
fprintf
(
stderr
,
"Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
\n
"
"Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
\n
"
"where OBJECT := { link | addr | route | rule | neigh | tunnel |
\n
"
"where OBJECT := { link | addr | route | rule | neigh | tunnel |
\n
"
" maddr | mroute | monitor }
\n
"
" maddr | mroute | monitor
| xfrm
}
\n
"
" OPTIONS := { -V[ersion] | -s[tatistics] | -r[esolve] |
\n
"
" OPTIONS := { -V[ersion] | -s[tatistics] | -r[esolve] |
\n
"
" -f[amily] { inet | inet6 | ipx | dnet | link } | -o[neline] }
\n
"
);
" -f[amily] { inet | inet6 | ipx | dnet | link } | -o[neline] }
\n
"
);
exit
(
-
1
);
exit
(
-
1
);
...
@@ -136,6 +136,8 @@ int main(int argc, char **argv)
...
@@ -136,6 +136,8 @@ int main(int argc, char **argv)
return
do_iptunnel
(
argc
-
1
,
argv
+
1
);
return
do_iptunnel
(
argc
-
1
,
argv
+
1
);
if
(
strcmp
(
basename
,
"ipmonitor"
)
==
0
)
if
(
strcmp
(
basename
,
"ipmonitor"
)
==
0
)
return
do_ipmonitor
(
argc
-
1
,
argv
+
1
);
return
do_ipmonitor
(
argc
-
1
,
argv
+
1
);
if
(
strcmp
(
basename
,
"ipxfrm"
)
==
0
)
return
do_xfrm
(
argc
-
1
,
argv
+
1
);
if
(
argc
>
1
)
{
if
(
argc
>
1
)
{
if
(
matches
(
argv
[
1
],
"address"
)
==
0
)
if
(
matches
(
argv
[
1
],
"address"
)
==
0
)
...
@@ -158,6 +160,8 @@ int main(int argc, char **argv)
...
@@ -158,6 +160,8 @@ int main(int argc, char **argv)
return
do_iptunnel
(
argc
-
2
,
argv
+
2
);
return
do_iptunnel
(
argc
-
2
,
argv
+
2
);
if
(
matches
(
argv
[
1
],
"monitor"
)
==
0
)
if
(
matches
(
argv
[
1
],
"monitor"
)
==
0
)
return
do_ipmonitor
(
argc
-
2
,
argv
+
2
);
return
do_ipmonitor
(
argc
-
2
,
argv
+
2
);
if
(
matches
(
argv
[
1
],
"xfrm"
)
==
0
)
return
do_xfrm
(
argc
-
2
,
argv
+
2
);
if
(
matches
(
argv
[
1
],
"help"
)
==
0
)
if
(
matches
(
argv
[
1
],
"help"
)
==
0
)
usage
();
usage
();
fprintf
(
stderr
,
"Object
\"
%s
\"
is unknown, try
\"
ip help
\"
.
\n
"
,
argv
[
1
]);
fprintf
(
stderr
,
"Object
\"
%s
\"
is unknown, try
\"
ip help
\"
.
\n
"
,
argv
[
1
]);
...
...
ip/ip_common.h
View file @
c7699875
...
@@ -18,3 +18,4 @@ extern int do_iplink(int argc, char **argv);
...
@@ -18,3 +18,4 @@ extern int do_iplink(int argc, char **argv);
extern
int
do_ipmonitor
(
int
argc
,
char
**
argv
);
extern
int
do_ipmonitor
(
int
argc
,
char
**
argv
);
extern
int
do_multiaddr
(
int
argc
,
char
**
argv
);
extern
int
do_multiaddr
(
int
argc
,
char
**
argv
);
extern
int
do_multiroute
(
int
argc
,
char
**
argv
);
extern
int
do_multiroute
(
int
argc
,
char
**
argv
);
extern
int
do_xfrm
(
int
argc
,
char
**
argv
);
ip/ipxfrm.c
View file @
c7699875
This diff is collapsed.
Click to expand it.
ip/xfrm.h
View file @
c7699875
/* $USAGI: $ */
/*
* Copyright (C)2004 USAGI/WIDE Project
*
* 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, MA 02111-1307 USA
*/
/*
* Authors:
* Masahide NAKAMURA @USAGI
*/
#ifndef __XFRM_H__
#define __XFRM_H__ 1
#include <stdio.h>
#include <sys/socket.h>
#include <linux/xfrm.h>
#include "utils.h"
#define XFRM_MAX_DEPTH 6
#define XFRMS_RTA(x) ((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(struct xfrm_usersa_info))))
#define XFRMS_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct xfrm_usersa_info))
#define XFRMP_RTA(x) ((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(struct xfrm_userpolicy_info))))
#define XFRMP_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct xfrm_userpoilcy_info))
struct
xfrm_buffer
{
char
*
buf
;
int
size
;
int
offset
;
int
nlmsg_count
;
struct
rtnl_handle
*
rth
;
};
struct
xfrm_filter
{
int
use
;
struct
xfrm_usersa_info
xsinfo
;
__u32
id_src_mask
;
__u32
id_dst_mask
;
__u32
id_proto_mask
;
__u32
id_spi_mask
;
__u32
mode_mask
;
__u32
reqid_mask
;
__u32
state_flags_mask
;
struct
xfrm_userpolicy_info
xpinfo
;
__u32
dir_mask
;
__u32
sel_src_mask
;
__u32
sel_dst_mask
;
__u32
sel_dev_mask
;
__u32
upspec_proto_mask
;
__u32
upspec_sport_mask
;
__u32
upspec_dport_mask
;
__u32
index_mask
;
__u32
action_mask
;
__u32
priority_mask
;
};
#define XFRM_FILTER_MASK_FULL (~(__u32)0)
extern
struct
xfrm_filter
filter
;
int
do_xfrm_state
(
int
argc
,
char
**
argv
);
int
do_xfrm_policy
(
int
argc
,
char
**
argv
);
const
char
*
strxf_flags
(
__u8
flags
);
const
char
*
strxf_share
(
__u8
share
);
void
xfrm_id_info_print
(
xfrm_address_t
*
saddr
,
struct
xfrm_id
*
id
,
__u8
mode
,
__u32
reqid
,
__u16
family
,
FILE
*
fp
,
const
char
*
prefix
);
void
xfrm_stats_print
(
struct
xfrm_stats
*
s
,
FILE
*
fp
,
const
char
*
prefix
);
void
xfrm_lifetime_print
(
struct
xfrm_lifetime_cfg
*
cfg
,
struct
xfrm_lifetime_cur
*
cur
,
FILE
*
fp
,
const
char
*
prefix
);
void
xfrm_selector_print
(
struct
xfrm_selector
*
sel
,
__u16
family
,
FILE
*
fp
,
const
char
*
prefix
);
void
xfrm_xfrma_print
(
struct
rtattr
*
tb
[],
int
ntb
,
__u16
family
,
FILE
*
fp
,
const
char
*
prefix
);
int
xfrm_id_parse
(
xfrm_address_t
*
saddr
,
struct
xfrm_id
*
id
,
__u16
*
family
,
int
*
argcp
,
char
***
argvp
);
int
xfrm_mode_parse
(
__u8
*
mode
,
int
*
argcp
,
char
***
argvp
);
int
xfrm_reqid_parse
(
__u32
*
reqid
,
int
*
argcp
,
char
***
argvp
);
int
xfrm_selector_parse
(
struct
xfrm_selector
*
sel
,
int
*
argcp
,
char
***
argvp
);
int
xfrm_lifetime_cfg_parse
(
struct
xfrm_lifetime_cfg
*
lft
,
int
*
argcp
,
char
***
argvp
);
#endif
ip/xfrm_policy.c
View file @
c7699875
This diff is collapsed.
Click to expand it.
ip/xfrm_state.c
View file @
c7699875
This diff is collapsed.
Click to expand it.
lib/libnetlink.c
View file @
c7699875
...
@@ -30,13 +30,13 @@ void rtnl_close(struct rtnl_handle *rth)
...
@@ -30,13 +30,13 @@ void rtnl_close(struct rtnl_handle *rth)
close
(
rth
->
fd
);
close
(
rth
->
fd
);
}
}
int
rtnl_open
(
struct
rtnl_handle
*
rth
,
unsigned
subscriptions
)
int
rtnl_open
_byproto
(
struct
rtnl_handle
*
rth
,
unsigned
subscriptions
,
int
protocol
)
{
{
int
addr_len
;
int
addr_len
;
memset
(
rth
,
0
,
sizeof
(
rth
));
memset
(
rth
,
0
,
sizeof
(
rth
));
rth
->
fd
=
socket
(
AF_NETLINK
,
SOCK_RAW
,
NETLINK_ROUTE
);
rth
->
fd
=
socket
(
AF_NETLINK
,
SOCK_RAW
,
protocol
);
if
(
rth
->
fd
<
0
)
{
if
(
rth
->
fd
<
0
)
{
perror
(
"Cannot open netlink socket"
);
perror
(
"Cannot open netlink socket"
);
return
-
1
;
return
-
1
;
...
@@ -67,6 +67,11 @@ int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions)
...
@@ -67,6 +67,11 @@ int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions)
return
0
;
return
0
;
}
}
int
rtnl_open
(
struct
rtnl_handle
*
rth
,
unsigned
subscriptions
)
{
return
rtnl_open_byproto
(
rth
,
subscriptions
,
NETLINK_ROUTE
);
}
int
rtnl_wilddump_request
(
struct
rtnl_handle
*
rth
,
int
family
,
int
type
)
int
rtnl_wilddump_request
(
struct
rtnl_handle
*
rth
,
int
family
,
int
type
)
{
{
struct
{
struct
{
...
@@ -521,3 +526,16 @@ int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len)
...
@@ -521,3 +526,16 @@ int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len)
fprintf
(
stderr
,
"!!!Deficit %d, rta_len=%d
\n
"
,
len
,
rta
->
rta_len
);
fprintf
(
stderr
,
"!!!Deficit %d, rta_len=%d
\n
"
,
len
,
rta
->
rta_len
);
return
0
;
return
0
;
}
}
int
parse_rtattr_byindex
(
struct
rtattr
*
tb
[],
int
max
,
struct
rtattr
*
rta
,
int
len
)
{
int
i
=
0
;
while
(
RTA_OK
(
rta
,
len
))
{
if
(
rta
->
rta_type
<=
max
)
tb
[
i
++
]
=
rta
;
rta
=
RTA_NEXT
(
rta
,
len
);
}
if
(
len
)
fprintf
(
stderr
,
"!!!Deficit %d, rta_len=%d
\n
"
,
len
,
rta
->
rta_len
);
return
i
;
}
lib/utils.c
View file @
c7699875
...
@@ -58,6 +58,20 @@ int get_unsigned(unsigned *val, const char *arg, int base)
...
@@ -58,6 +58,20 @@ int get_unsigned(unsigned *val, const char *arg, int base)
return
0
;
return
0
;
}
}
int
get_u64
(
__u64
*
val
,
const
char
*
arg
,
int
base
)
{
unsigned
long
long
res
;
char
*
ptr
;
if
(
!
arg
||
!*
arg
)
return
-
1
;
res
=
strtoull
(
arg
,
&
ptr
,
base
);
if
(
!
ptr
||
ptr
==
arg
||
*
ptr
||
res
==
0xFFFFFFFFULL
)
return
-
1
;
*
val
=
res
;
return
0
;
}
int
get_u32
(
__u32
*
val
,
const
char
*
arg
,
int
base
)
int
get_u32
(
__u32
*
val
,
const
char
*
arg
,
int
base
)
{
{
unsigned
long
res
;
unsigned
long
res
;
...
@@ -186,7 +200,7 @@ int get_addr_1(inet_prefix *addr, const char *name, int family)
...
@@ -186,7 +200,7 @@ int get_addr_1(inet_prefix *addr, const char *name, int family)
return
0
;
return
0
;
}
}
int
get_prefix_1
(
inet_prefix
*
dst
,
char
*
arg
,
int
family
)
int
get_prefix_1
(
inet_prefix
*
dst
,
c
onst
c
har
*
arg
,
int
family
)
{
{
int
err
;
int
err
;
unsigned
plen
;
unsigned
plen
;
...
@@ -235,7 +249,7 @@ done:
...
@@ -235,7 +249,7 @@ done:
return
err
;
return
err
;
}
}
int
get_addr
(
inet_prefix
*
dst
,
char
*
arg
,
int
family
)
int
get_addr
(
inet_prefix
*
dst
,
c
onst
c
har
*
arg
,
int
family
)
{
{
if
(
family
==
AF_PACKET
)
{
if
(
family
==
AF_PACKET
)
{
fprintf
(
stderr
,
"Error:
\"
%s
\"
may be inet address, but it is not allowed in this context.
\n
"
,
arg
);
fprintf
(
stderr
,
"Error:
\"
%s
\"
may be inet address, but it is not allowed in this context.
\n
"
,
arg
);
...
@@ -248,7 +262,7 @@ int get_addr(inet_prefix *dst, char *arg, int family)
...
@@ -248,7 +262,7 @@ int get_addr(inet_prefix *dst, char *arg, int family)
return
0
;
return
0
;
}
}
int
get_prefix
(
inet_prefix
*
dst
,
char
*
arg
,
int
family
)
int
get_prefix
(
inet_prefix
*
dst
,
c
onst
c
har
*
arg
,
int
family
)
{
{
if
(
family
==
AF_PACKET
)
{
if
(
family
==
AF_PACKET
)
{
fprintf
(
stderr
,
"Error:
\"
%s
\"
may be inet prefix, but it is not allowed in this context.
\n
"
,
arg
);
fprintf
(
stderr
,
"Error:
\"
%s
\"
may be inet prefix, but it is not allowed in this context.
\n
"
,
arg
);
...
@@ -261,7 +275,7 @@ int get_prefix(inet_prefix *dst, char *arg, int family)
...
@@ -261,7 +275,7 @@ int get_prefix(inet_prefix *dst, char *arg, int family)
return
0
;
return
0
;
}
}
__u32
get_addr32
(
char
*
name
)
__u32
get_addr32
(
c
onst
c
har
*
name
)
{
{
inet_prefix
addr
;
inet_prefix
addr
;
if
(
get_addr_1
(
&
addr
,
name
,
AF_INET
))
{
if
(
get_addr_1
(
&
addr
,
name
,
AF_INET
))
{
...
@@ -277,6 +291,12 @@ void incomplete_command(void)
...
@@ -277,6 +291,12 @@ void incomplete_command(void)
exit
(
-
1
);
exit
(
-
1
);
}
}
void
missarg
(
const
char
*
key
)
{
fprintf
(
stderr
,
"Error: argument
\"
%s
\"
is required
\n
"
,
key
);
exit
(
-
1
);
}
void
invarg
(
const
char
*
msg
,
const
char
*
arg
)
void
invarg
(
const
char
*
msg
,
const
char
*
arg
)
{
{
fprintf
(
stderr
,
"Error: argument
\"
%s
\"
is wrong: %s
\n
"
,
arg
,
msg
);
fprintf
(
stderr
,
"Error: argument
\"
%s
\"
is wrong: %s
\n
"
,
arg
,
msg
);
...
@@ -344,7 +364,7 @@ int __get_hz(void)
...
@@ -344,7 +364,7 @@ int __get_hz(void)
if
(
getenv
(
"PROC_NET_PSCHED"
))
{
if
(
getenv
(
"PROC_NET_PSCHED"
))
{
snprintf
(
name
,
sizeof
(
name
)
-
1
,
"%s"
,
getenv
(
"PROC_NET_PSCHED"
));
snprintf
(
name
,
sizeof
(
name
)
-
1
,
"%s"
,
getenv
(
"PROC_NET_PSCHED"
));
}
else
if
(
getenv
(
"PROC_ROOT"
))
{
}
else
if
(
getenv
(
"PROC_ROOT"
))
{
snprintf
(
name
,
sizeof
(
name
)
-
1
,
"%s/net/psched"
,
getenv
(
"PROC_ROOT"
));
snprintf
(
name
,
sizeof
(
name
)
-
1
,
"%s/net/psched"
,
getenv
(
"PROC_ROOT"
));
}
else
{
}
else
{
strcpy
(
name
,
"/proc/net/psched"
);
strcpy
(
name
,
"/proc/net/psched"
);
...
@@ -427,7 +447,7 @@ char *resolve_address(const char *addr, int len, int af)
...
@@ -427,7 +447,7 @@ char *resolve_address(const char *addr, int len, int af)
sethostent
(
1
);
sethostent
(
1
);
fflush
(
stdout
);
fflush
(
stdout
);
if
((
h_ent
=
gethostbyaddr
(
addr
,
len
,
af
))
!=
NULL
)
if
((
h_ent
=
gethostbyaddr
(
addr
,
len
,
af
))
!=
NULL
)
n
->
name
=
strdup
(
h_ent
->
h_name
);
n
->
name
=
strdup
(
h_ent
->
h_name
);
/* Even if we fail, "negative" entry is remembered. */
/* Even if we fail, "negative" entry is remembered. */
...
@@ -436,7 +456,7 @@ char *resolve_address(const char *addr, int len, int af)
...
@@ -436,7 +456,7 @@ char *resolve_address(const char *addr, int len, int af)
#endif
#endif
const
char
*
format_host
(
int
af
,
int
len
,
const
void
*
addr
,
const
char
*
format_host
(
int
af
,
int
len
,
const
void
*
addr
,
char
*
buf
,
int
buflen
)
char
*
buf
,
int
buflen
)
{
{
#ifdef RESOLVE_HOSTNAMES
#ifdef RESOLVE_HOSTNAMES
...
...
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