forked from pandax381/microps
/
microps.c
40 lines (38 loc) · 789 Bytes
/
microps.c
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
#include <stdio.h>
#include <pthread.h>
#include "microps.h"
int
microps_init (const struct microps_param *param) {
if (ethernet_init() == -1) {
goto ERROR;
}
if (ethernet_device_open(param->ethernet_device, param->ethernet_addr) == -1) {
goto ERROR;
}
if (arp_init() == -1) {
goto ERROR;
}
if (ip_init(param->ip_addr, param->ip_netmask, param->ip_gateway) == -1) {
goto ERROR;
}
if (icmp_init() == -1) {
goto ERROR;
}
if (udp_init() == -1) {
goto ERROR;
}
if (tcp_init() == -1) {
goto ERROR;
}
if (ethernet_device_run() == -1) {
goto ERROR;
}
return 0;
ERROR:
//microps_cleanup();
return -1;
}
void
microps_cleanup (void) {
ethernet_device_close();
}