/* * Called from boot code to establish ppp interfaces. */ void pppattach() { register struct ppp_softc *sc; register int i = 0; IOLog("\nPPP version 2.3.8-%s for NeXTSTEP and OPENSTEP\n", PPPVERSION); IOLog("by Stephen Perkins, Philip Prindeville, and Pete French\n"); if (install_ppp_ld() < 0) { IOLog("ppp: Could not install line discipline\n"); } for (sc = ppp_softc; i < NUM_PPP; sc++, i++) { sc->sc_if = if_attach(NULL, NULL, pppoutput, pppgetbuf, pppcontrol, "ppp", i, "Serial line PPP", PPP_MTU, IFF_POINTOPOINT, NETIFCLASS_VIRTUAL, (void *) sc); nbq_init(&sc->sc_freeq, &qparms[QFREE]); nbq_init(&sc->sc_rawq, &qparms[QRAW]); nbq_init(&sc->sc_fastq, &qparms[QFAST]); nbq_init(&sc->sc_slowq, &qparms[QSLOW]); nbq_init(&sc->sc_inq, &qparms[QIN]); nbq_init(&sc->sc_npq, &qparms[QNP]); nbq_init(&sc->sc_compq, &qparms[QCACHE]); IOLog(" ppp%d successfully attached.\n", i); } ipforwarding = 1; ipsendredirects = 1; IOLog("PPP Successfully Installed.\n\n"); }
static int c_worker_thread_final_init(struct c_worker_ctx *w_ctx) { cpu_set_t cpu; char ipc_path_str[64]; struct timeval tv = { C_PER_WORKER_TIMEO, 0 }; int i = 0; int c_listener = 0; extern ctrl_hdl_t ctrl_hdl; w_ctx->cmn_ctx.base = event_base_new(); assert(w_ctx->cmn_ctx.base); snprintf(ipc_path_str, 63, "%s%d", C_IPC_PATH, w_ctx->thread_idx); w_ctx->main_wrk_conn.rd_fd = open(ipc_path_str, O_RDONLY | O_NONBLOCK); assert(w_ctx->main_wrk_conn.rd_fd > 0); w_ctx->main_wrk_conn.rd_event = event_new(w_ctx->cmn_ctx.base, w_ctx->main_wrk_conn.rd_fd, EV_READ|EV_PERSIST, c_worker_ipc_read, (void*)w_ctx); event_add(w_ctx->main_wrk_conn.rd_event, NULL); w_ctx->worker_timer_event = evtimer_new(w_ctx->cmn_ctx.base, c_per_worker_timer_event, (void *)w_ctx); evtimer_add(w_ctx->worker_timer_event, &tv); for (i = 0; i < ctrl_hdl.n_appthreads; i++) { nbq_init(&w_ctx->work_qs[i].q); } c_listener = c_server_socket_create(INADDR_ANY, C_APP_WQ_LISTEN_PORT+w_ctx->thread_idx); assert(c_listener); w_ctx->c_app_accept_event = event_new(w_ctx->cmn_ctx.base, c_listener, EV_READ|EV_PERSIST, c_app_wq_accept, (void*)w_ctx); event_add(w_ctx->c_app_accept_event, NULL); /* Set cpu affinity */ CPU_ZERO(&cpu); CPU_SET(w_ctx->thread_idx, &cpu); pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpu); w_ctx->cmn_ctx.run_state = THREAD_STATE_RUNNING; return 0; }