/* * This is where you should define all your AutoGen AutoOpts option parsing. * Any user specified option should have it's bit turned on in the 'provides' * bit mask. * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN */ int dlt_user_parse_opts(tcpeditdlt_t *ctx) { tcpeditdlt_plugin_t *plugin; user_config_t *config; assert(ctx); plugin = tcpedit_dlt_getplugin(ctx, dlt_value); config = plugin->config; /* * --user-dlt will override the output DLT type, otherwise we'll use * the DLT of the decoder */ if (HAVE_OPT(USER_DLT)) { config->dlt = OPT_VALUE_USER_DLT; } else { config->dlt = ctx->decoder->dlt; } /* --user-dlink */ if (HAVE_OPT(USER_DLINK)) { int ct = STACKCT_OPT(USER_DLINK); char **list = STACKLST_OPT(USER_DLINK); int first = 1; do { char *p = *list++; if (first) { config->length = read_hexstring(p, config->l2server, USER_L2MAXLEN); memcpy(config->l2client, config->l2server, config->length); } else { if (config->length != read_hexstring(p, config->l2client, USER_L2MAXLEN)) { tcpedit_seterr(ctx->tcpedit, "%s", "both --dlink's must contain the same number of bytes"); return TCPEDIT_ERROR; } } first = 0; } while (--ct > 0); } return TCPEDIT_OK; /* success */ }
int main(int argc, char * argv[]) { unsigned char buffer[512]; int i; for (i=0; cases[i].size; i++) { memset(buffer, 0xcc, sizeof(buffer)); read_hexstring(buffer, cases[i].size, cases[i].pattern); printf("case %d: pattern=[%s], result=", i, cases[i].pattern); dump_hex(stdout, "[", "]\n", '-', buffer, cases[i].size); } }