int main(void) { struct sq_context *ctx; const char *options[] = {"listening_ports", LISTENING_PORT, NULL}; ctx = sq_start(callback, NULL, options); pause(); return 0; }
static void start_squeasel(int argc, char *argv[]) { struct sq_callbacks callbacks; char *options[MAX_OPTIONS]; int i; // Edit passwords file if -A option is specified if (argc > 1 && !strcmp(argv[1], "-A")) { if (argc != 6) { show_usage_and_exit(); } exit(sq_modify_passwords_file(argv[2], argv[3], argv[4], argv[5]) ? EXIT_SUCCESS : EXIT_FAILURE); } // Show usage if -h or --help options are specified if (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) { show_usage_and_exit(); } options[0] = NULL; set_option(options, "document_root", "."); // Update config based on command line arguments process_command_line_arguments(argv, options); // Make sure we have absolute paths for files and directories // https://github.com/cloudera/squeasel/issues/181 set_absolute_path(options, "document_root", argv[0]); set_absolute_path(options, "put_delete_auth_file", argv[0]); set_absolute_path(options, "cgi_interpreter", argv[0]); set_absolute_path(options, "access_log_file", argv[0]); set_absolute_path(options, "error_log_file", argv[0]); set_absolute_path(options, "global_auth_file", argv[0]); set_absolute_path(options, "ssl_certificate", argv[0]); // Make extra verification for certain options verify_existence(options, "document_root", 1); verify_existence(options, "cgi_interpreter", 0); verify_existence(options, "ssl_certificate", 0); // Setup signal handler: quit on Ctrl-C signal(SIGTERM, signal_handler); signal(SIGINT, signal_handler); // Start Squeasel memset(&callbacks, 0, sizeof(callbacks)); callbacks.log_message = &log_message; ctx = sq_start(&callbacks, NULL, (const char **) options); for (i = 0; options[i] != NULL; i++) { free(options[i]); } if (ctx == NULL) { die("%s", "Failed to start Squeasel."); } }
static int sq_txintr(struct sq_softc *sc) { int i; u_int32_t status; struct ifnet *ifp = &sc->sc_ethercom.ec_if; status = bus_space_read_4(sc->sc_hpct, sc->sc_hpch, HPC_ENETX_CTL); SQ_TRACE(SQ_TXINTR_ENTER, sc->sc_prevtx, status, sc->sc_nfreetx); if ((status & (ENETX_CTL_ACTIVE | TXSTAT_GOOD)) == 0) { if (status & TXSTAT_COLL) ifp->if_collisions++; if (status & TXSTAT_UFLOW) { printf("%s: transmit underflow\n", sc->sc_dev.dv_xname); ifp->if_oerrors++; } if (status & TXSTAT_16COLL) { printf("%s: max collisions reached\n", sc->sc_dev.dv_xname); ifp->if_oerrors++; ifp->if_collisions += 16; } } i = sc->sc_prevtx; while (sc->sc_nfreetx < SQ_NTXDESC) { /* * Check status first so we don't end up with a case of * the buffer not being finished while the DMA channel * has gone idle. */ status = bus_space_read_4(sc->sc_hpct, sc->sc_hpch, HPC_ENETX_CTL); SQ_CDTXSYNC(sc, i, sc->sc_txmap[i]->dm_nsegs, BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE); /* If not yet transmitted, try and start DMA engine again */ if ((sc->sc_txdesc[i].hdd_ctl & HDD_CTL_XMITDONE) == 0) { if ((status & ENETX_CTL_ACTIVE) == 0) { SQ_TRACE(SQ_RESTART_DMA, i, status, sc->sc_nfreetx); bus_space_write_4(sc->sc_hpct, sc->sc_hpch, HPC_ENETX_NDBP, SQ_CDTXADDR(sc, i)); /* Kick DMA channel into life */ bus_space_write_4(sc->sc_hpct, sc->sc_hpch, HPC_ENETX_CTL, ENETX_CTL_ACTIVE); /* * Set a watchdog timer in case the chip * flakes out. */ ifp->if_timer = 5; } else { SQ_TRACE(SQ_TXINTR_BUSY, i, status, sc->sc_nfreetx); } break; } /* Sync the packet data, unload DMA map, free mbuf */ bus_dmamap_sync(sc->sc_dmat, sc->sc_txmap[i], 0, sc->sc_txmap[i]->dm_mapsize, BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(sc->sc_dmat, sc->sc_txmap[i]); m_freem(sc->sc_txmbuf[i]); sc->sc_txmbuf[i] = NULL; ifp->if_opackets++; sc->sc_nfreetx++; SQ_TRACE(SQ_DONE_DMA, i, status, sc->sc_nfreetx); i = SQ_NEXTTX(i); } /* prevtx now points to next xmit packet not yet finished */ sc->sc_prevtx = i; /* If we have buffers free, let upper layers know */ if (sc->sc_nfreetx > 0) ifp->if_flags &= ~IFF_OACTIVE; /* If all packets have left the coop, cancel watchdog */ if (sc->sc_nfreetx == SQ_NTXDESC) ifp->if_timer = 0; SQ_TRACE(SQ_TXINTR_EXIT, sc->sc_prevtx, status, sc->sc_nfreetx); sq_start(ifp); return 1; }