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
ddb1129b
Commit
ddb1129b
authored
Jan 13, 2015
by
Vadim Kochan
Committed by
Stephen Hemminger
Jan 13, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use one func to print timestamp from nlmsg
Signed-off-by:
Vadim Kochan
<
vadim4j@gmail.com
>
parent
27b14f2e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
18 deletions
+15
-18
bridge/monitor.c
bridge/monitor.c
+2
-12
include/utils.h
include/utils.h
+2
-0
ip/ipmonitor.c
ip/ipmonitor.c
+1
-6
lib/utils.c
lib/utils.c
+10
-0
No files found.
bridge/monitor.c
View file @
ddb1129b
...
@@ -35,17 +35,6 @@ static void usage(void)
...
@@ -35,17 +35,6 @@ static void usage(void)
exit
(
-
1
);
exit
(
-
1
);
}
}
static
int
show_mark
(
FILE
*
fp
,
const
struct
nlmsghdr
*
n
)
{
char
*
tstr
;
time_t
secs
=
((
__u32
*
)
NLMSG_DATA
(
n
))[
0
];
long
usecs
=
((
__u32
*
)
NLMSG_DATA
(
n
))[
1
];
tstr
=
asctime
(
localtime
(
&
secs
));
tstr
[
strlen
(
tstr
)
-
1
]
=
0
;
fprintf
(
fp
,
"Timestamp: %s %lu us
\n
"
,
tstr
,
usecs
);
return
0
;
}
static
int
accept_msg
(
const
struct
sockaddr_nl
*
who
,
static
int
accept_msg
(
const
struct
sockaddr_nl
*
who
,
struct
nlmsghdr
*
n
,
void
*
arg
)
struct
nlmsghdr
*
n
,
void
*
arg
)
{
{
...
@@ -75,7 +64,8 @@ static int accept_msg(const struct sockaddr_nl *who,
...
@@ -75,7 +64,8 @@ static int accept_msg(const struct sockaddr_nl *who,
return
print_mdb
(
who
,
n
,
arg
);
return
print_mdb
(
who
,
n
,
arg
);
case
NLMSG_TSTAMP
:
case
NLMSG_TSTAMP
:
return
show_mark
(
fp
,
n
);
print_nlmsg_timestamp
(
fp
,
n
);
return
0
;
default:
default:
return
0
;
return
0
;
...
...
include/utils.h
View file @
ddb1129b
...
@@ -148,6 +148,7 @@ static inline __u32 nl_mgrp(__u32 group)
...
@@ -148,6 +148,7 @@ static inline __u32 nl_mgrp(__u32 group)
int
print_timestamp
(
FILE
*
fp
);
int
print_timestamp
(
FILE
*
fp
);
void
print_nlmsg_timestamp
(
FILE
*
fp
,
const
struct
nlmsghdr
*
n
);
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
...
@@ -160,4 +161,5 @@ struct iplink_req;
...
@@ -160,4 +161,5 @@ struct iplink_req;
int
iplink_parse
(
int
argc
,
char
**
argv
,
struct
iplink_req
*
req
,
int
iplink_parse
(
int
argc
,
char
**
argv
,
struct
iplink_req
*
req
,
char
**
name
,
char
**
type
,
char
**
link
,
char
**
dev
,
char
**
name
,
char
**
type
,
char
**
link
,
char
**
dev
,
int
*
group
,
int
*
index
);
int
*
group
,
int
*
index
);
#endif
/* __UTILS_H__ */
#endif
/* __UTILS_H__ */
ip/ipmonitor.c
View file @
ddb1129b
...
@@ -126,12 +126,7 @@ static int accept_msg(const struct sockaddr_nl *who,
...
@@ -126,12 +126,7 @@ static int accept_msg(const struct sockaddr_nl *who,
return
0
;
return
0
;
}
}
if
(
n
->
nlmsg_type
==
NLMSG_TSTAMP
)
{
if
(
n
->
nlmsg_type
==
NLMSG_TSTAMP
)
{
char
*
tstr
;
print_nlmsg_timestamp
(
fp
,
n
);
time_t
secs
=
((
__u32
*
)
NLMSG_DATA
(
n
))[
0
];
long
usecs
=
((
__u32
*
)
NLMSG_DATA
(
n
))[
1
];
tstr
=
asctime
(
localtime
(
&
secs
));
tstr
[
strlen
(
tstr
)
-
1
]
=
0
;
fprintf
(
fp
,
"Timestamp: %s %lu us
\n
"
,
tstr
,
usecs
);
return
0
;
return
0
;
}
}
if
(
n
->
nlmsg_type
!=
NLMSG_ERROR
&&
n
->
nlmsg_type
!=
NLMSG_NOOP
&&
if
(
n
->
nlmsg_type
!=
NLMSG_ERROR
&&
n
->
nlmsg_type
!=
NLMSG_NOOP
&&
...
...
lib/utils.c
View file @
ddb1129b
...
@@ -868,3 +868,13 @@ int inet_get_addr(const char *src, __u32 *dst, struct in6_addr *dst6)
...
@@ -868,3 +868,13 @@ int inet_get_addr(const char *src, __u32 *dst, struct in6_addr *dst6)
else
else
return
inet_pton
(
AF_INET
,
src
,
dst
);
return
inet_pton
(
AF_INET
,
src
,
dst
);
}
}
void
print_nlmsg_timestamp
(
FILE
*
fp
,
const
struct
nlmsghdr
*
n
)
{
char
*
tstr
;
time_t
secs
=
((
__u32
*
)
NLMSG_DATA
(
n
))[
0
];
long
usecs
=
((
__u32
*
)
NLMSG_DATA
(
n
))[
1
];
tstr
=
asctime
(
localtime
(
&
secs
));
tstr
[
strlen
(
tstr
)
-
1
]
=
0
;
fprintf
(
fp
,
"Timestamp: %s %lu us
\n
"
,
tstr
,
usecs
);
}
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