-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreceiver.c
More file actions
47 lines (38 loc) · 1.12 KB
/
Copy pathreceiver.c
File metadata and controls
47 lines (38 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* receiver.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include "util.h"
#include "cs431vde.h"
int
main(int argc, char *argv[])
{
int fds[2];
uint8_t frame[1600];
ssize_t frame_len;
char *data_as_hex;
int connect_to_remote_switch = 0;
char *local_vde_cmd[] = {"vde_plug", "/home/entuyenabo/cs432/cs431/tmp/net2.vde", NULL};
char *remote_vde_cmd[] = { "ssh", "entuyenabo@weathertop.cs.middlebury.edu",
"/home/entuyenabo/cs431/bin/vde_plug",
NULL };
char **vde_cmd = connect_to_remote_switch ? remote_vde_cmd : local_vde_cmd;
if(connect_to_vde_switch(fds, vde_cmd) < 0) {
printf("Could not connect to switch, exiting.\n");
exit(1);
}
while((frame_len = receive_ethernet_frame(fds[0], frame)) > 0) {
data_as_hex = binary_to_hex(frame, frame_len);
printf("received frame, length %ld:\n", frame_len);
puts(data_as_hex);
free(data_as_hex);
}
if(frame_len < 0) {
perror("read");
exit(1);
}
return 0;
}