Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-stable
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
emulab
emulab-stable
Commits
4c0d54fc
Commit
4c0d54fc
authored
Jan 11, 2006
by
Junxing Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stub files for Plab
parent
5e78b7a0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
4 deletions
+9
-4
pelab/stub/Makefile
pelab/stub/Makefile
+1
-1
pelab/stub/stub-pcap.c
pelab/stub/stub-pcap.c
+3
-2
pelab/stub/stubd.c
pelab/stub/stubd.c
+5
-1
No files found.
pelab/stub/Makefile
View file @
4c0d54fc
...
@@ -2,7 +2,7 @@ all: stubd stub-monitor
...
@@ -2,7 +2,7 @@ all: stubd stub-monitor
stubd
:
stubd.o stub-pcap.o stub.h
stubd
:
stubd.o stub-pcap.o stub.h
gcc
-g
-Wall
-lm
-lpcap
stubd.o stub-pcap.o
-o
stubd
gcc
-g
-Wall
-lm
-lpcap
stubd.o stub-pcap.o
-o
stubd
monitor-stub
:
monitor-stub
.c stub.h
stub-monitor
:
stub-monitor
.c stub.h
gcc
-g
-Wall
stub-monitor.c
-o
stub-monitor
gcc
-g
-Wall
stub-monitor.c
-o
stub-monitor
stubd.o
:
stubd.c stub.h
stubd.o
:
stubd.c stub.h
gcc
-g
-Wall
-c
stubd.c
gcc
-g
-Wall
-c
stubd.c
...
...
pelab/stub/stub-pcap.c
View file @
4c0d54fc
...
@@ -103,6 +103,7 @@ int search_sniff_rcvdb(int path_id, u_long seqnum) {
...
@@ -103,6 +103,7 @@ int search_sniff_rcvdb(int path_id, u_long seqnum) {
void
pop_sniff_rcvdb
(
int
path_id
,
u_long
to_seqnum
){
void
pop_sniff_rcvdb
(
int
path_id
,
u_long
to_seqnum
){
int
to_index
=
search_sniff_rcvdb
(
path_id
,
to_seqnum
);
int
to_index
=
search_sniff_rcvdb
(
path_id
,
to_seqnum
);
if
(
to_index
!=
-
1
)
{
if
(
to_index
!=
-
1
)
{
//if the packet has no payload or the last sent seqnum equals the pop number
if
((
sniff_rcvdb
[
path_id
].
records
[
to_index
].
seq_end
==
sniff_rcvdb
[
path_id
].
records
[
to_index
].
seq_start
)
if
((
sniff_rcvdb
[
path_id
].
records
[
to_index
].
seq_end
==
sniff_rcvdb
[
path_id
].
records
[
to_index
].
seq_start
)
||
(
sniff_rcvdb
[
path_id
].
records
[
to_index
].
seq_end
-
1
==
to_seqnum
))
{
||
(
sniff_rcvdb
[
path_id
].
records
[
to_index
].
seq_end
-
1
==
to_seqnum
))
{
sniff_rcvdb
[
path_id
].
start
=
(
to_index
+
1
)
%
SNIFF_WINSIZE
;
//complete pop-up
sniff_rcvdb
[
path_id
].
start
=
(
to_index
+
1
)
%
SNIFF_WINSIZE
;
//complete pop-up
...
@@ -181,7 +182,7 @@ u_int16_t handle_IP(u_char *args, const struct pcap_pkthdr* pkthdr, const u_char
...
@@ -181,7 +182,7 @@ u_int16_t handle_IP(u_char *args, const struct pcap_pkthdr* pkthdr, const u_char
ip_dst
=
ip
->
ip_dst
.
s_addr
;
ip_dst
=
ip
->
ip_dst
.
s_addr
;
if
(
flag_debug
){
if
(
flag_debug
){
//
For an unknown reason, inet_ntoa returns the same string if called twice in one fprintf
//
Note:inet_ntoa returns the same string if called twice in one line due to static string buffer
fprintf
(
stdout
,
"IP src:%s "
,
inet_ntoa
(
ip
->
ip_src
));
fprintf
(
stdout
,
"IP src:%s "
,
inet_ntoa
(
ip
->
ip_src
));
fprintf
(
stdout
,
"dst:%s hlen:%d version:%d len:%d
\n
"
,
inet_ntoa
(
ip
->
ip_dst
),
hlen
,
version
,
len
);
fprintf
(
stdout
,
"dst:%s hlen:%d version:%d len:%d
\n
"
,
inet_ntoa
(
ip
->
ip_dst
),
hlen
,
version
,
len
);
}
}
...
@@ -327,7 +328,7 @@ void init_pcap(int to_ms) {
...
@@ -327,7 +328,7 @@ void init_pcap(int to_ms) {
char
string_filter
[
128
];
char
string_filter
[
128
];
//struct in_addr addr;
//struct in_addr addr;
dev
=
"
eth0"
;
//"vnet
";
dev
=
"
vnet"
;
//"eth0
";
/* ask pcap for the network address and mask of the device */
/* ask pcap for the network address and mask of the device */
pcap_lookupnet
(
dev
,
&
netp
,
&
maskp
,
errbuf
);
pcap_lookupnet
(
dev
,
&
netp
,
&
maskp
,
errbuf
);
...
...
pelab/stub/stubd.c
View file @
4c0d54fc
...
@@ -232,7 +232,11 @@ int receive_monitor(int sockfd) {
...
@@ -232,7 +232,11 @@ int receive_monitor(int sockfd) {
memcpy
(
&
tmpulong
,
nextptr
,
SIZEOF_LONG
);
memcpy
(
&
tmpulong
,
nextptr
,
SIZEOF_LONG
);
destnum
=
ntohl
(
tmpulong
);
destnum
=
ntohl
(
tmpulong
);
//receive dest addrs
//return success if no dest addr is given
if
(
destnum
==
0
){
return
1
;
}
//otherwise, receive dest addrs
if
(
recv_all
(
sockfd
,
buf
,
destnum
*
SIZEOF_LONG
)
==
0
)
{
if
(
recv_all
(
sockfd
,
buf
,
destnum
*
SIZEOF_LONG
)
==
0
)
{
return
0
;
return
0
;
}
}
...
...
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