static gboolean timeout_renew(gpointer user_data) { struct connman_dhcpv6 *dhcp = user_data; if (check_restart(dhcp) < 0) return FALSE; dhcp->RT = calc_delay(dhcp->RT, REN_MAX_RT); DBG("renew RT timeout %d msec", dhcp->RT); dhcp->timeout = g_timeout_add(dhcp->RT, timeout_renew, dhcp); g_dhcp_client_start(dhcp->dhcp_client, NULL); return FALSE; }
int main(int argc, char **argv) { int err; int pid; int sock; fd_set socklist; int status; int ssl_sock, tcp_sock, max_sock; int select_ret; struct timeval tv; SSL_CTX *ctx; // disable stdout buffering setvbuf(stdout, NULL, _IONBF, 0); if (argc < 2) { printf("Usage: %s master|slave\n", argv[0]); exit(0); } if (!strcmp(argv[1], "master")) { global_type = MASTER; } else { global_type = SLAVE; } if (getuid() != 0) { printf("Not root user\n"); exit(6); } exec_sisinfoc(); ctx = ssl_init(); ssl_sock = tcp_create_socket(7779); tcp_sock = tcp_create_socket(7776); while (1) { tv.tv_sec = 60; tv.tv_usec = 0; FD_ZERO(&socklist); /* Always clear the structure first. */ FD_SET(ssl_sock, &socklist); FD_SET(tcp_sock, &socklist); max_sock = (tcp_sock > ssl_sock ? tcp_sock : ssl_sock); max_sock += 1; select_ret = select(max_sock, &socklist, NULL, NULL, &tv); if (select_ret == -1) { perror("Select"); exit(0); } while (wait3(&status, WNOHANG, 0) > 0); check_restart(); exec_sisinfoc(); exec_scavenge(); if (select_ret > 0) { if (FD_ISSET(tcp_sock, &socklist)) { //printf("TCP connection %d\n", select_ret); ssl_or_tcp_fork(tcp_sock, NULL); } if (FD_ISSET(ssl_sock, &socklist)) { //printf("SSl connection %d\n", select_ret); ssl_or_tcp_fork(ssl_sock, ctx); } } } }