2022-05-10 06:43:27 +00:00
|
|
|
//
|
|
|
|
// Created by xajhu on 2021/6/29 0029.
|
|
|
|
//
|
|
|
|
#include <uv.h>
|
2022-06-02 08:18:43 +00:00
|
|
|
#include <zlog.h>
|
2022-10-28 08:46:55 +00:00
|
|
|
#include <stdlib.h>
|
2022-05-10 06:43:27 +00:00
|
|
|
#include "cmdline.h"
|
|
|
|
#include "task_manager.h"
|
|
|
|
#include "init.h"
|
2022-10-28 08:46:55 +00:00
|
|
|
#if LWIP_ON
|
2022-05-10 06:43:27 +00:00
|
|
|
#include "user_info.h"
|
|
|
|
#include "lwip/tcpip.h"
|
2022-09-28 02:48:02 +00:00
|
|
|
#endif
|
2022-10-28 07:37:01 +00:00
|
|
|
|
|
|
|
#ifdef OPENDHCPD_ON
|
2022-09-19 01:53:11 +00:00
|
|
|
#include "open_dhcp/dhcpd.h"
|
2022-10-28 08:46:55 +00:00
|
|
|
#include "user_errno.h"
|
2022-10-28 07:37:01 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef OPENDHCPDDNS_ON
|
|
|
|
#include "dual_server/dualsvr.h"
|
|
|
|
#endif
|
2022-05-10 06:43:27 +00:00
|
|
|
|
2022-09-19 01:53:11 +00:00
|
|
|
#if LWIP_ON
|
2022-05-10 06:43:27 +00:00
|
|
|
static void test_init(void *arg) { /* remove compiler warning */
|
|
|
|
sys_sem_t *init_sem;
|
|
|
|
|
|
|
|
init_sem = (sys_sem_t *)arg;
|
|
|
|
|
|
|
|
srand((unsigned int)time(0));
|
|
|
|
|
|
|
|
sys_sem_signal(init_sem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void lwip_init_env() {
|
|
|
|
err_t err;
|
|
|
|
sys_sem_t init_sem;
|
|
|
|
|
2022-10-28 07:37:01 +00:00
|
|
|
err = sys_sem_new(&init_sem, 0);
|
2022-05-10 06:43:27 +00:00
|
|
|
LWIP_UNUSED_ARG(err);
|
|
|
|
tcpip_init(test_init, &init_sem);
|
|
|
|
sys_sem_wait(&init_sem);
|
|
|
|
sys_sem_free(&init_sem);
|
|
|
|
}
|
2022-09-19 01:53:11 +00:00
|
|
|
#endif
|
2022-05-27 07:49:45 +00:00
|
|
|
|
2022-05-10 06:43:27 +00:00
|
|
|
int main(int argc, char **argv) {
|
2022-10-28 08:46:55 +00:00
|
|
|
int ret;
|
2022-10-28 07:37:01 +00:00
|
|
|
#ifdef OPENDHCPDDNS_ON
|
|
|
|
return dual_server_main(argc, argv);
|
2022-10-28 07:45:33 +00:00
|
|
|
#elif OPENDHCPD_ON
|
2022-10-28 08:46:55 +00:00
|
|
|
// return dhcpd_main(argc, argv);
|
|
|
|
//#else
|
2022-05-10 06:43:27 +00:00
|
|
|
uv_setup_args(argc, argv);
|
|
|
|
|
|
|
|
setvbuf(stdout, NULL, _IONBF, 0);
|
|
|
|
|
2022-10-28 08:46:55 +00:00
|
|
|
ret = menu_run(argc, argv);
|
|
|
|
|
|
|
|
if(ret == ERR_MENU_EXIT) {
|
|
|
|
user_uninit();
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
if (ret != ERR_SUCCESS) {
|
|
|
|
printf("Application setup error(%d), please used --help to show usage, exited!!!\n", ret);
|
|
|
|
user_uninit();
|
|
|
|
exit(0);
|
|
|
|
}
|
2022-05-10 06:43:27 +00:00
|
|
|
|
2022-09-19 01:53:11 +00:00
|
|
|
#if LWIP_ON
|
2022-05-27 07:49:45 +00:00
|
|
|
lwip_init_env();
|
2022-05-10 06:43:27 +00:00
|
|
|
user_info_init();
|
2022-09-19 01:53:11 +00:00
|
|
|
pppoe_session_init();
|
|
|
|
#endif
|
2022-05-10 06:43:27 +00:00
|
|
|
|
|
|
|
task_manager_run();
|
|
|
|
user_uninit();
|
|
|
|
|
|
|
|
return 0;
|
2022-09-19 01:53:11 +00:00
|
|
|
#endif
|
2022-05-10 06:43:27 +00:00
|
|
|
}
|