Ejemplo n.º 1
0
/*
 *  appUsageLong();
 *
 *    Print complete usage information to USAGE_FH.  Pass this
 *    function to skOptionsSetUsageCallback(); skOptionsParse() will
 *    call this funciton and then exit the program when the --help
 *    option is given.
 */
static void
appUsageLong(
    void)
{
#define USAGE_MSG                                                          \
    ("<PREFIX_SWITCH> [<PREFIX_SWITCH>...] [SWITCHES] [FILES]\n"           \
     "\tRead SiLK Flow records from FILES named on the command line or\n"  \
     "\tfrom the standard input, keep the specified number of most\n"      \
     "\tsignificant bits for each IP address, and write the modified\n"    \
     "\trecords to the specified output file or to the standard output.\n")

    FILE *fh = USAGE_FH;
    int i, j;

    fprintf(fh, "%s %s", skAppName(), USAGE_MSG);

    fprintf(fh, "\nPREFIX SWITCHES:\n");
    /* print everything before --output-path */
    for (i=0; appOptions[i].name && appOptions[i].val < OPT_OUTPUT_PATH; ++i) {
        fprintf(fh, "--%s %s. %s\n", appOptions[i].name,
                SK_OPTION_HAS_ARG(appOptions[i]), appHelp[i]);
    }

    /* print the first three switches again as aliases---use a
     * different variable!! */
    for (j = 0;
         appOptions[j].name && appOptions[j].val <= OPT_4NHIP_PREFIX_LENGTH;
         ++j)
    {
        fprintf(fh, "--%s %s. Alias for --%s\n", appOptions[j].name + 1,
                SK_OPTION_HAS_ARG(appOptions[j]), appOptions[j].name);
    }

    /* print remaining options */
    fprintf(fh, "\nSWITCHES:\n");
    skOptionsDefaultUsage(fh);
    for ( ; appOptions[i].name; ++i) {
        fprintf(fh, "--%s %s. %s\n", appOptions[i].name,
                SK_OPTION_HAS_ARG(appOptions[i]), appHelp[i]);
    }

    skOptionsCtxOptionsUsage(optctx, fh);
    skIPv6PolicyUsage(fh);
    skCompMethodOptionsUsage(fh);
    skOptionsNotesUsage(fh);
    sksiteOptionsUsage(fh);
}
Ejemplo n.º 2
0
/*
 *  void pmap_filter_help(FILE *fh, const struct option *option, void *cbdata)
 *
 *    Writes dynamically created option help for filter options to fh.
 */
static void
pmap_filter_help(
    FILE                   *fh,
    const struct option    *option,
    void                   *cbdata)
{
    directed_pmap_data_t *dir_data  = (directed_pmap_data_t *)cbdata;
    pmap_data_t          *pmap_data = dir_data->data;

    fprintf(fh, "--%s %s. ", option->name, SK_OPTION_HAS_ARG(*option));
    switch (dir_data->dir) {
      case DIR_SOURCE:
        switch (skPrefixMapGetContentType(pmap_data->pmap)) {
          case SKPREFIXMAP_CONT_ADDR_V4:
          case SKPREFIXMAP_CONT_ADDR_V6:
            fprintf(fh, "Source address");
            break;
          case SKPREFIXMAP_CONT_PROTO_PORT:
            fprintf(fh, "Protocol/Source-port pair");
            break;
        }

        fprintf(fh, (" map to a label specified\n"
                     "\tin this comma separated list of labels."
                     "  The mapping is defined by the\n"
                     "\tprefix map file '%s'"),
                pmap_data->filepath);
        break;
      case DIR_DEST:
        fprintf(fh, "As previous switch for the ");
        switch (skPrefixMapGetContentType(pmap_data->pmap)) {
          case SKPREFIXMAP_CONT_ADDR_V4:
          case SKPREFIXMAP_CONT_ADDR_V6:
            fprintf(fh, "destination address");
            break;
          case SKPREFIXMAP_CONT_PROTO_PORT:
            fprintf(fh, "protocol/dest-port pair");
            break;
        }
        break;
      case DIR_ANY:
        fprintf(fh, "As previous switch for either ");
        switch (skPrefixMapGetContentType(pmap_data->pmap)) {
          case SKPREFIXMAP_CONT_ADDR_V4:
          case SKPREFIXMAP_CONT_ADDR_V6:
            fprintf(fh, "source or destination address");
            break;
          case SKPREFIXMAP_CONT_PROTO_PORT:
            fprintf(fh, "protocol/source or destination port pair");
            break;
        }
        break;
    }
    fprintf(fh, "\n");
}
Ejemplo n.º 3
0
/*
 *  legacyOptionsUsage(fh);
 *
 *    Print the usage information for the legacy options to the named
 *    file handle.
 */
void
legacyOptionsUsage(
    FILE               *fh)
{
    int i;

    fprintf(fh, "\nLEGACY SWITCHES:\n");
    for (i = 0; legacyOptions[i].name; i++ ) {
        fprintf(fh, "--%s %s. %s\n", legacyOptions[i].name,
                SK_OPTION_HAS_ARG(legacyOptions[i]), legacyHelp[i]);
    }
}
Ejemplo n.º 4
0
/*
 *  appUsageLong();
 *
 *    Print complete usage information to USAGE_FH.  Pass this
 *    function to skOptionsSetUsageCallback(); skOptionsParse() will
 *    call this funciton and then exit the program when the --help
 *    option is given.
 */
static void
appUsageLong(
    void)
{
#define USAGE_MSG                                                             \
    ("[SWITCHES] [FILES]\n"                                                   \
     "\tSummarize SiLK Flow records across time, producing textual output\n"  \
     "\twith counts of bytes, packets, and flow records for each time bin.\n" \
     "\tWhen no files given on command line, flows are read from STDIN.\n")

    FILE *fh = USAGE_FH;
    int i;

    fprintf(fh, "%s %s", skAppName(), USAGE_MSG);
    fprintf(fh, "\nSWITCHES:\n");
    skOptionsDefaultUsage(fh);

    for (i = 0; appOptions[i].name; ++i) {
        fprintf(fh, "--%s %s. ", appOptions[i].name,
                SK_OPTION_HAS_ARG(appOptions[i]));
        switch (appOptions[i].val) {
          case OPT_LOAD_SCHEME:
            loadschemeUsage(fh);
            break;
          case OPT_TIMESTAMP_FORMAT:
            timestampFormatUsage(fh);
            break;
          default:
            fprintf(fh, "%s\n", appHelp[i]);
            break;
        }
    }
    for (i = 0; deprecatedOptions[i].name; ++i) {
        fprintf(fh, "--%s %s. %s\n", deprecatedOptions[i].name,
                SK_OPTION_HAS_ARG(deprecatedOptions[i]), deprecatedHelp[i]);
    }

    skOptionsCtxOptionsUsage(optctx, fh);
    sksiteOptionsUsage(fh);
}
Ejemplo n.º 5
0
/*
 *  appUsageLong();
 *
 *    Print complete usage information to USAGE_FH.  Pass this
 *    function to skOptionsSetUsageCallback(); skOptionsParse() will
 *    call this funciton and then exit the program when the --help
 *    option is given.
 */
static void
appUsageLong(
    void)
{
    FILE *fh = USAGE_FH;
    unsigned int i;

#define USAGE_MSG                                                             \
    ("--keys=KEYS --counters=COUNTERS [SWITCHES] [FILES]\n"                   \
     "\tRead SiLK Flow records, bin the records by the fields in KEYS,\n"     \
     "\tcompute the COUNTERS field(s) for each KEYS, and write the binary\n"  \
     "\tAggregate Bag output to the standard output or the --output-path.\n"  \
     "\tRead SiLK Flows from the named files or from the standard input.\n")

    /* Create the string maps for --keys and --counters */
    createStringmaps();

    fprintf(fh, "%s %s", skAppName(), USAGE_MSG);

    fprintf(fh, "\nSWITCHES:\n");
    skOptionsDefaultUsage(fh);
    for (i = 0; appOptions[i].name; ++i) {
        fprintf(fh, "--%s %s. ", appOptions[i].name,
                SK_OPTION_HAS_ARG(appOptions[i]));
        switch ((appOptionsEnum)appOptions[i].val) {
          case OPT_KEYS:
            /* Dynamically build the help */
            fprintf(fh, "%s\n", appHelp[i]);
            skStringMapPrintUsage(key_name_map, fh, 4);
            break;
          case OPT_COUNTERS:
            fprintf(fh, "%s\n", appHelp[i]);
            skStringMapPrintUsage(counter_name_map, fh, 4);
            break;
          case OPT_OUTPUT_PATH:
            /* include the help for --notes and --invocation-strip
             * after --output-path */
            fprintf(fh, "%s\n", appHelp[i]);
            skAggBagOptionsUsage(fh);
            break;
          default:
            /* Simple help text from the appHelp array */
            fprintf(fh, "%s\n", appHelp[i]);
            break;
        }
    }

    skOptionsCtxOptionsUsage(optctx, fh);
    skIPv6PolicyUsage(fh);
    sksiteOptionsUsage(fh);
    /* skPluginOptionsUsage(fh); */
}
Ejemplo n.º 6
0
/*
 *  appUsageLong();
 *
 *    Print complete usage information to USAGE_FH.  Pass this
 *    function to skOptionsSetUsageCallback(); skOptionsParse() will
 *    call this funciton and then exit the program when the --help
 *    option is given.
 */
static void
appUsageLong(
    void)
{
#define USAGE_MSG                                                       \
    ("<SWITCHES>\n"                                                     \
     "\tA utility to simply print to stdout the list of files\n"        \
     "\tthat rwfilter would normally process for a given set of\n"      \
     "\tfile selection switches.\n")

    FILE *fh = USAGE_FH;
    int i;

    fprintf(fh, "%s %s", skAppName(), USAGE_MSG);
    fprintf(fh, "\nAPPLICATION SWITCHES\n");
    skOptionsDefaultUsage(fh);
    for (i = 0; appOptions[i].name; ++i) {
        fprintf(fh, "--%s %s. %s\n", appOptions[i].name,
                SK_OPTION_HAS_ARG(appOptions[i]), appHelp[i]);
    }
    fglobUsage(fh);
}