wifidog源码分析(一)

网上已有源码详细的源码分析,此分析仅做个人记录 从main开始wifidog-gateway/src/gatway.c/* Reads the configuration file and then starts the main loop */int //读取配置文件,也就是/etc/wifidog.conf中的各项配置gw_main(int argc, char
摘要由CSDN通过智能技术生成

网上已有源码详细的源码分析,此分析仅做个人记录
从main开始wifidog-gateway/src/gatway.c

/* Reads the configuration file and then starts the main loop */
int              //读取配置文件,也就是/etc/wifidog.conf中的各项配置
gw_main(int argc, char **argv)
{
    s_config *config = config_get_config();   //获取配置
    config_init();                    //初始化配置

    parse_commandline(argc, argv);     //这里匹配wifidog命令行命令

    /* Initialize the config */
    config_read(config->configfile);      //从配置文件中读取配置
    config_validate();

    /* Initializes the linked list of connected clients */
    client_list_init();

    /* Init the signals to catch chld/quit/etc */
    init_signals();

    if (restart_orig_pid) {
        /*
         * We were restarted and our parent is waiting for us to talk to it over the socket
         */
        get_clients_from_parent();

        /*
         * At this point the parent will start destroying itself and the firewall. Let it finish it's job before we continue
         */
        while (kill(restart_orig_pid, 0) != -1) {
            debug(LOG_INFO, "Waiting for parent PID %d to die before continuing loading", restart_orig_pid);
            sleep(1);
        }

        debug(LOG_INFO, "Parent PID %d seems to be dead. Continuing loading.");
    }

    if (config->daemon) {          //开启进程,默认设置为后台运行,daemon初始化默认为1

        debug(LOG_INFO, "Forking into background");   

        switch (safe_fork()) {
        case 0:                /* child */
            setsid();
            append_x_restartargv();
            main_loop();                  //进入main loop,wifidog开始工作
            break;

        default:               /* parent */
            exit(0);
            break;
        }
    } else {
        append_x_restartargv();
        main_loop();
    }

    return (0);                 /* never reached */
}

wifidog-gateway/src/gatway.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值