本文整理汇总了C++中enum_name函数的典型用法代码示例。如果您正苦于以下问题:C++ enum_name函数的具体用法?C++ enum_name怎么用?C++ enum_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了enum_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ike_alg_show_status
/*
* Show registered IKE algorithms
*/
void
ike_alg_show_status(void)
{
unsigned alg, i;
struct ike_alg *algo;
IKE_EALG_FOR_EACH(algo) {
passert(algo != NULL);
alg=algo->algo_id;
whack_log(RC_COMMENT, "algorithm IKE encrypt: id=%d, name=%s, blocksize=%d, keydeflen=%d"
, alg
, enum_name(&oakley_enc_names, alg)
, ((struct encrypt_desc *)algo)->enc_blocksize
, ((struct encrypt_desc *)algo)->keydeflen
);
}
IKE_HALG_FOR_EACH(algo) {
whack_log(RC_COMMENT, "algorithm IKE hash: id=%d, name=%s, hashsize=%d"
, algo->algo_id
, enum_name(&oakley_hash_names, algo->algo_id)
, ((struct hash_desc *)algo)->hash_digest_size
);
}
#define IKE_DH_ALG_FOR_EACH(idx) for(idx = 0; idx != elemsof(oakley_group); idx++)
IKE_DH_ALG_FOR_EACH(i) {
const struct oakley_group_desc *gdesc=oakley_group+i;
whack_log(RC_COMMENT, "algorithm IKE dh group: id=%d, name=%s, bits=%d"
, gdesc->group
, enum_name(&oakley_group_names, gdesc->group)
, gdesc->bytes*BITS_PER_BYTE
);
}
}
示例2: doit
static int doit(unsigned protoid, const char *str)
{
struct alg_info *ai;
enum_names *enames, *anames, *gnames;
const char *err;
int i;
switch (protoid) {
case PROTO_IPSEC_ESP: {
struct alg_info_esp *ai_esp;
struct esp_info *esp_info;
enames=&esp_transformid_names;
anames=&auth_alg_names;
gnames=NULL;
ai_esp=alg_info_esp_create_from_str(str, &err);
ai = (struct alg_info *) ai_esp;
if (!ai) goto err;
alg_info_addref(ai);
ALG_INFO_ESP_FOREACH(ai_esp, esp_info, i) {
printf("(%d = \"%s\" [%d], ",
esp_info->esp_ealg_id,
enum_name(enames, esp_info->esp_ealg_id),
esp_info->esp_ealg_keylen);
printf("%d = \"%s\" [%d])\n",
esp_info->esp_aalg_id,
enum_name(anames, esp_info->esp_aalg_id),
esp_info->esp_aalg_keylen);
}
break;
}
case PROTO_ISAKMP: {
struct alg_info_ike *ai_ike;
struct ike_info *ike_info;
enames=&oakley_enc_names;
anames=&oakley_hash_names;
gnames=&oakley_group_names;
ai_ike = alg_info_ike_create_from_str(str, &err);
ai = (struct alg_info *) ai_ike;
if (!ai) goto err;
alg_info_addref(ai);
ALG_INFO_IKE_FOREACH(ai_ike, ike_info, i) {
printf("(%d = \"%s\" [%d], ",
ike_info->ike_ealg,
enum_name(enames, ike_info->ike_ealg),
ike_info->ike_eklen);
printf("%d = \"%s\" [%d], ",
ike_info->ike_halg,
enum_name(anames, ike_info->ike_halg),
ike_info->ike_hklen);
printf("%d = \"%s\")\n",
ike_info->ike_modp,
ike_info->ike_modp ?
enum_name(gnames, ike_info->ike_modp):
"<default>");
}
break;
}
开发者ID:jameshilliard,项目名称:actiontec_opensrc_mi424wr-rev-e-f_fw-20-10-7-5,代码行数:56,代码来源:alg_info_test.c
示例3: snprintf
char *alg_info_snprint_ike1(struct ike_info *ike_info
, int eklen, int aklen
, char *buf
, int buflen)
{
snprintf(buf, buflen-1, "%s(%d)_%03d-%s(%d)_%03d-%s(%d)"
, enum_name(&oakley_enc_names, ike_info->ike_ealg)+ sizeof("OAKLEY")
, ike_info->ike_ealg, eklen
, enum_name(&oakley_hash_names, ike_info->ike_halg)+ sizeof("OAKLEY")
, ike_info->ike_halg, aklen
, enum_name(&oakley_group_names, ike_info->ike_modp)+ sizeof("OAKLEY_GROUP")
, ike_info->ike_modp);
return buf;
}
示例4: ike_alg_show_status
/*
* Show registered IKE algorithms
*/
void ike_alg_show_status(void)
{
unsigned i;
struct ike_alg *algo;
whack_log(RC_COMMENT, "IKE algorithms supported:");
whack_log(RC_COMMENT, " "); /* spacer */
IKE_EALG_FOR_EACH(algo) {
struct esb_buf v1namebuf, v2namebuf;
passert(algo != NULL);
passert(algo->algo_id != 0 || algo->algo_v2id != 0);
whack_log(RC_COMMENT,
"algorithm IKE encrypt: v1id=%d, v1name=%s, v2id=%d, v2name=%s, blocksize=%zu, keydeflen=%u",
algo->algo_id,
enum_showb(&oakley_enc_names, algo->algo_id, &v1namebuf),
algo->algo_v2id,
enum_showb(&ikev2_trans_type_encr_names, algo->algo_v2id, &v2namebuf),
((struct encrypt_desc *)algo)->enc_blocksize,
((struct encrypt_desc *)algo)->keydeflen);
}
IKE_HALG_FOR_EACH(algo) {
/*
* ??? we think that hash_integ_len is meaningless
* (and 0) for IKE hashes
*/
pexpect(((struct hash_desc *)algo)->hash_integ_len == 0);
whack_log(RC_COMMENT,
"algorithm IKE hash: id=%d, name=%s, hashlen=%zu",
algo->algo_id,
enum_name(&oakley_hash_names, algo->algo_id),
((struct hash_desc *)algo)->hash_digest_len);
}
#define IKE_DH_ALG_FOR_EACH(idx) for ((idx) = 0; (idx) != oakley_group_size; (idx)++)
IKE_DH_ALG_FOR_EACH(i) {
const struct oakley_group_desc *gdesc = oakley_group + i;
whack_log(RC_COMMENT,
"algorithm IKE dh group: id=%d, name=%s, bits=%d",
gdesc->group,
enum_name(&oakley_group_names, gdesc->group),
(int)gdesc->bytes * BITS_PER_BYTE);
}
whack_log(RC_COMMENT, " "); /* spacer */
}
示例5: db_prop_print
static void db_prop_print(struct db_prop *p)
{
struct db_trans *t;
struct db_attr *a;
int ti, ai;
enum_names *n, *n_at, *n_av;
DBG_log("protoid=\"%s\"\n", enum_name(&protocol_names, p->protoid));
for (ti=0, t=p->trans; ti< p->trans_cnt; ti++, t++) {
switch( p->protoid) {
case PROTO_ISAKMP:
n=&isakmp_transformid_names;
break;
case PROTO_IPSEC_ESP:
n=&esp_transformid_names;
break;
case PROTO_IPSEC_AH:
n=&ah_transformid_names;
break;
default:
continue;
}
DBG_log(" transid=\"%s\"\n", enum_name(n, t->transid));
for (ai=0, a=t->attrs; ai < t->attr_cnt; ai++, a++) {
int i;
switch( p->protoid) {
case PROTO_ISAKMP:
n_at=&oakley_attr_names;
i=a->type|ISAKMP_ATTR_AF_TV;
n_av=oakley_attr_val_descs[(i)&ISAKMP_ATTR_RTYPE_MASK];
break;
case PROTO_IPSEC_AH:
case PROTO_IPSEC_ESP:
n_at=&ipsec_attr_names;
i=a->type|ISAKMP_ATTR_AF_TV;
n_av=ipsec_attr_val_descs[(i)&ISAKMP_ATTR_RTYPE_MASK];
break;
default:
continue;
}
DBG_log(" type=\"%s\" value=\"%s\"\n",
enum_name(n_at, i),
enum_name(n_av, a->val));
}
}
}
示例6: log_sa_attr_oakley
static void log_sa_attr_oakley(struct db_attr *at)
{
const struct enum_names *en = NULL;
if (at->type.oakley == OAKLEY_ATTR_undefined)
return;
if (at->type.oakley < oakley_attr_val_descs_roof)
en = oakley_attr_val_descs[at->type.oakley];
DBG_log(" type: %u(%s) val: %u(%s)\n",
at->type.oakley,
enum_name(&oakley_attr_names, at->type.oakley +
ISAKMP_ATTR_AF_TV),
at->val, en ? enum_name(en, at->val) : "unknown");
}
示例7: log_sa_attr_ipsec
static void log_sa_attr_ipsec(struct db_attr *at)
{
const struct enum_names *en = NULL;
if (at->type.ipsec == 0)
return;
if (at->type.ipsec < ipsec_attr_val_descs_roof)
en = ipsec_attr_val_descs[at->type.ipsec];
DBG_log(" type: %u(%s) val: %u(%s)\n",
at->type.ipsec,
enum_name(&ipsec_attr_names,
at->type.ipsec + ISAKMP_ATTR_AF_TV),
at->val, en ? enum_name(en, at->val) : "unknown");
}
示例8: dump_sdt
static void
dump_sdt (GstMpegTsSection * section)
{
const GstMpegTsSDT *sdt = gst_mpegts_section_get_sdt (section);
guint i, len;
g_assert (sdt);
g_printf (" original_network_id : 0x%04x\n", sdt->original_network_id);
g_printf (" actual_ts : %s\n",
sdt->actual_ts ? "TRUE" : "FALSE");
len = sdt->services->len;
g_printf (" %d Services:\n", len);
for (i = 0; i < len; i++) {
GstMpegTsSDTService *service = g_ptr_array_index (sdt->services, i);
g_print
(" service_id:0x%04x, EIT_schedule_flag:%d, EIT_present_following_flag:%d\n",
service->service_id, service->EIT_schedule_flag,
service->EIT_present_following_flag);
g_print
(" running_status:0x%02x (%s), free_CA_mode:%d (%s)\n",
service->running_status,
enum_name (GST_TYPE_MPEG_TS_RUNNING_STATUS, service->running_status),
service->free_CA_mode,
service->free_CA_mode ? "MAYBE SCRAMBLED" : "NOT SCRAMBLED");
dump_descriptors (service->descriptors, 9);
}
}
示例9: dump_pmt
static void
dump_pmt (GstMpegtsSection * section, ATS_METADATA* data)
{
const GstMpegtsPMT *pmt = gst_mpegts_section_get_pmt (section);
guint i, len;
ATS_CH_DATA* channel;
channel = ats_metadata_find_channel(data, pmt->program_number);
if (!channel) return;
len = pmt->streams->len;
channel->pids_num = 0;
for (i = 0; i < len; i++) {
const gchar* type;
GstMpegtsPMTStream *stream = g_ptr_array_index (pmt->streams, i);
if (stream->stream_type == 0x86) continue; /* Unknown type */
/* Getting pid's codec type */
type = enum_name (GST_TYPE_MPEGTS_STREAM_TYPE, stream->stream_type);
if (type[0] != 'a' && type[0] != 'v') continue;
channel->pids[channel->pids_num].to_be_analyzed = FALSE;
channel->pids[channel->pids_num].pid = stream->pid;
channel->pids[channel->pids_num].type = stream->stream_type;
channel->pids[channel->pids_num].codec = g_strdup(type);
channel->pids_num++;
}
}
示例10: test_enum_enum
static void test_enum_enum(const char *title, enum_enum_names *een,
unsigned long table, enum_names *en,
unsigned long val, bool val_ok)
{
printf("%s:\n", title);
{
printf(PREFIX "enum_enum_table %lu: ", table);
if (en == enum_enum_table(een, table)) {
printf("OK\n");
} else {
printf("ERROR\n");
}
}
printf(PREFIX "enum_enum_name %lu %lu: ", table, val);
const char *name = enum_enum_name(een, table, val);
if ((val_ok) == (name != NULL)) {
printf("OK\n");
} else {
printf("ERROR\n");
}
printf(PREFIX "enum_name table %lu: ", val);
if (en == NULL) {
printf("N/A\n");
} else if (name == enum_name(en, val)) {
printf("OK\n");
} else {
printf("ERROR\n");
}
LSWBUF(buf) {
printf(PREFIX "lswlog_enum_enum %lu %lu: ", table, val);
lswlog_enum_enum(buf, een, table, val);
/* ??? clang says that name might be NULL */
if (val_ok && name == NULL) {
printf("name == NULL\n");
} else if (val_ok && streq(buf->array, name)) {
printf("OK\n");
} else if (strlen(buf->array) > 0) {
printf("OK\n");
} else {
printf("ERROR [empty]\n");
}
}
LSWBUF(buf) {
printf(PREFIX "lswlog_enum_enum_short %lu %lu: ", table, val);
lswlog_enum_enum_short(buf, een, table, val);
if (val_ok && streq(buf->array, enum_short_name(en, val))) {
printf("OK\n");
} else if (strlen(buf->array) > 0) {
printf("OK\n");
} else {
printf("ERROR [empty]\n");
}
}
}
示例11: readline_set_generator
static char *
readline_set_generator(const char *text, int state)
{
static const char *words[] = {
#define DEFINE_OPTION_NAME(name, type, flags) #name " = ",
OPTION_INFO(DEFINE_OPTION_NAME)
#undef DEFINE_OPTION_NAME
NULL
};
static int index, len;
const char *name;
char *match = NULL; /* No match */
/* If it is a new word to complete, initialize */
if (!state) {
index = 0;
len = strlen(text);
}
/* Return the next name which partially matches */
while ((name = words[index])) {
name = enum_name(name);
index++;
if (strncmp(name, text, len) == 0) {
/* Ignore exact completion */
if (strlen(name) > len)
match = strdup(name);
break;
}
}
return match;
}
示例12: ike_alg_show_status
/*
* Show registered IKE algorithms
*/
void ike_alg_show_status(void)
{
whack_log(RC_COMMENT, "IKE algorithms supported:");
whack_log(RC_COMMENT, " "); /* spacer */
for (const struct encrypt_desc **algp = next_ike_encrypt_desc(NULL);
algp != NULL;
algp = next_ike_encrypt_desc(algp)) {
struct esb_buf v1namebuf, v2namebuf;
const struct encrypt_desc *alg = (*algp);
passert(alg->common.ikev1_oakley_id != 0 || alg->common.ikev2_id != 0);
whack_log(RC_COMMENT,
"algorithm IKE encrypt: v1id=%d, v1name=%s, v2id=%d, v2name=%s, blocksize=%zu, keydeflen=%u",
alg->common.ikev1_oakley_id,
enum_showb(&oakley_enc_names, alg->common.ikev1_oakley_id, &v1namebuf),
alg->common.ikev2_id,
enum_showb(&ikev2_trans_type_encr_names, alg->common.ikev2_id, &v2namebuf),
alg->enc_blocksize,
alg->keydeflen);
}
for (const struct prf_desc **algp = next_ike_prf_desc(NULL);
algp != NULL;
algp = next_ike_prf_desc(algp)) {
const struct prf_desc *alg = (*algp);
whack_log(RC_COMMENT,
"algorithm IKE hash: id=%d, name=%s, hashlen=%zu",
alg->common.ikev1_oakley_id,
enum_name(&oakley_hash_names, alg->common.ikev1_oakley_id),
alg->prf_output_size);
}
const struct oakley_group_desc *gdesc;
for (gdesc = next_oakley_group(NULL);
gdesc != NULL;
gdesc = next_oakley_group(gdesc)) {
whack_log(RC_COMMENT,
"algorithm IKE dh group: id=%d, name=%s, bits=%d",
gdesc->group,
enum_name(&oakley_group_names, gdesc->group),
(int)gdesc->bytes * BITS_PER_BYTE);
}
whack_log(RC_COMMENT, " "); /* spacer */
}
示例13: alg_info_snprint_esp
/*
* print which ESP algorithm has actually been selected, based upon which
* ones are actually loaded.
*/
int
alg_info_snprint_esp(char *buf, int buflen, struct alg_info_esp *alg_info)
{
char *ptr=buf;
int ret;
struct esp_info *esp_info;
int cnt;
int eklen, aklen;
const char *sep="";
ptr=buf;
buf[0]=0; strncat(buf, "none", buflen);
ALG_INFO_ESP_FOREACH(alg_info, esp_info, cnt) {
if (kernel_alg_esp_enc_ok(esp_info->esp_ealg_id, 0, NULL)) {
DBG_log("esp algid=%d not available", esp_info->esp_ealg_id);
continue;
}
if (kernel_alg_esp_auth_ok(esp_info->esp_aalg_id, NULL)) {
DBG_log("auth algid=%d not available", esp_info->esp_aalg_id);
continue;
}
eklen=esp_info->esp_ealg_keylen;
if (!eklen)
eklen=kernel_alg_esp_enc_keylen(esp_info->esp_ealg_id)*BITS_PER_BYTE;
aklen=esp_info->esp_aalg_keylen;
if (!aklen)
aklen=kernel_alg_esp_auth_keylen(esp_info->esp_aalg_id)*BITS_PER_BYTE;
ret=snprintf(ptr, buflen, "%s%s(%d)_%03d-%s(%d)_%03d"
, sep
, enum_name(&esp_transformid_names, esp_info->esp_ealg_id)+sizeof("ESP")
, esp_info->esp_ealg_id, eklen
, enum_name(&auth_alg_names, esp_info->esp_aalg_id)+sizeof("AUTH_ALGORITHM_HMAC")
, esp_info->esp_aalg_id, aklen);
ptr+=ret;
buflen-=ret;
if (buflen<0) break;
sep = ", ";
}
return ptr-buf;
}
示例14: dpd_timeout
/**
* DPD Timeout Function
*
* This function is called when a timeout DPD_EVENT occurs. We set clear/trap
* both the SA and the eroutes, depending on what the connection definition
* tells us (either 'hold' or 'clear')
*
* @param st A state structure that is fully negotiated
* @return void
*/
void dpd_timeout(struct state *st)
{
struct connection *c = st->st_connection;
int action = c->dpd_action;
/** delete the state, which is probably in phase 2 */
set_cur_connection(c);
libreswan_log("DPD: No response from peer - declaring peer dead");
switch (action) {
case DPD_ACTION_HOLD:
/** dpdaction=hold - Wipe the SA's but %trap the eroute so we don't
leak traffic. Also, being in %trap means new packets will
force an initiation of the conn again. */
libreswan_log("DPD: Putting connection into %%trap");
if (c->kind == CK_INSTANCE) {
DBG(DBG_DPD,
DBG_log(
"DPD: warning dpdaction=hold on instance futile - will be deleted"));
}
delete_states_by_connection(c, TRUE);
break;
case DPD_ACTION_CLEAR:
/** dpdaction=clear - Wipe the SA & eroute - everything */
libreswan_log("DPD: Clearing Connection");
/*
* For CK_INSTANCE, delete_states_by_connection() will clear
* Note that delete_states_by_connection changes c->kind but we need
* to remember what it was to know if we still need to unroute after delete
*/
if (c->kind == CK_INSTANCE) {
delete_states_by_connection(c, TRUE);
} else {
flush_pending_by_connection(c); /* remove any partial negotiations that are failing */
delete_states_by_connection(c, TRUE);
DBG(DBG_DPD,
DBG_log("DPD: unrouting connection (%s)",
enum_name(&connection_kind_names,
c->kind)));
unroute_connection(c); /* --unroute */
}
break;
case DPD_ACTION_RESTART:
/* dpdaction=restart - immediately renegotiate connections to the same peer. */
libreswan_log(
"DPD: Restarting all connections that share this peer");
restart_connections_by_peer(c);
break;
default:
bad_case(action);
}
reset_cur_connection();
}
示例15: alg_info_snprint_ike
int
alg_info_snprint_ike(char *buf, int buflen, struct alg_info_ike *alg_info)
{
char *ptr=buf;
int ret;
struct ike_info *ike_info;
int cnt;
int eklen, aklen;
const char *sep="";
struct encrypt_desc *enc_desc;
struct hash_desc *hash_desc;
ALG_INFO_IKE_FOREACH(alg_info, ike_info, cnt) {
if (ike_alg_enc_present(ike_info->ike_ealg)
&& (ike_alg_hash_present(ike_info->ike_halg))
&& (lookup_group(ike_info->ike_modp))) {
enc_desc=ike_alg_get_encrypter(ike_info->ike_ealg);
passert(enc_desc != NULL);
hash_desc=ike_alg_get_hasher(ike_info->ike_halg);
passert(hash_desc != NULL);
eklen=ike_info->ike_eklen;
if (!eklen)
eklen=enc_desc->keydeflen;
aklen=ike_info->ike_hklen;
if (!aklen)
aklen=hash_desc->hash_digest_len * BITS_PER_BYTE;
ret=snprintf(ptr, buflen, "%s%s(%d)_%03d-%s(%d)_%03d-%s(%d)"
, sep
, enum_name(&oakley_enc_names, ike_info->ike_ealg)+sizeof("OAKLEY")
, ike_info->ike_ealg, eklen
, enum_name(&oakley_hash_names, ike_info->ike_halg)+sizeof("OAKLEY")
, ike_info->ike_halg, aklen
, enum_name(&oakley_group_names, ike_info->ike_modp)+sizeof("OAKLEY_GROUP")
, ike_info->ike_modp);
ptr+=ret;
buflen-=ret;
if (buflen<0) break;
sep = ", ";
}
}
return ptr-buf;
}