• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ enum_name函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中enum_name函数的典型用法代码示例。如果您正苦于以下问题:C++ enum_name函数的具体用法?C++ enum_name怎么用?C++ enum_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了enum_name函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
			);
	}
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:36,代码来源:ike_alg.c


示例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;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:14,代码来源:plutoalg.c


示例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 */
}
开发者ID:yottanami,项目名称:libreswan,代码行数:52,代码来源:ike_alg_status.c


示例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));
		}
	}

}
开发者ID:1309578252,项目名称:Openswan,代码行数:49,代码来源:db_ops.c


示例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");
}
开发者ID:vkartashov,项目名称:libreswan,代码行数:15,代码来源:spdb_print.c


示例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");
}
开发者ID:vkartashov,项目名称:libreswan,代码行数:15,代码来源:spdb_print.c


示例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);
  }
}
开发者ID:agx,项目名称:gst-plugins-bad,代码行数:28,代码来源:ts-parser.c


示例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++;
  }
}
开发者ID:Freyr666,项目名称:d,代码行数:25,代码来源:parse_ts.c


示例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");
		}
	}

}
开发者ID:libreswan,项目名称:libreswan,代码行数:60,代码来源:enumcheck.c


示例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;
}
开发者ID:gonzus,项目名称:tig,代码行数:35,代码来源:prompt.c


示例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 */
}
开发者ID:doctaweeks,项目名称:libreswan,代码行数:49,代码来源:crypto.c


示例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;
}
开发者ID:mcr,项目名称:bluerose,代码行数:50,代码来源:plutoalg.c


示例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();
}
开发者ID:hydromet,项目名称:libreswan,代码行数:68,代码来源:dpd.c


示例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;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:45,代码来源:plutoalg.c


示例16: snprint_esp_info

static int snprint_esp_info(char *ptr, size_t buflen, const char *sep,
			    const struct esp_info *esp_info)
{
	unsigned eklen = esp_info->enckeylen;
	unsigned aklen = esp_info->authkeylen;

	return snprintf(ptr, buflen, "%s%s(%d)_%03d-%s(%d)_%03d",
			sep,
			strip_prefix(enum_name(&esp_transformid_names,
					       esp_info->transid), "ESP_"),
			esp_info->transid, eklen,
			strip_prefix(strip_prefix(enum_name(&auth_alg_names,
							    esp_info->auth),
						  "AUTH_ALGORITHM_HMAC_"),
				     "AUTH_ALGORITHM_"),
			esp_info->auth,
			aklen);
}
开发者ID:intliang,项目名称:libreswan,代码行数:18,代码来源:plutoalg.c


示例17: 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) {
		static char v1namebuf[ENUM_SHOW_BUF_LEN];
		static char v2namebuf[ENUM_SHOW_BUF_LEN];
		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=%d, keydeflen=%d",
			  algo->algo_id,
			  enum_showb(&oakley_enc_names, algo->algo_id, v1namebuf, sizeof(v1namebuf)),
			  algo->algo_v2id,
			  enum_showb(&ikev2_trans_type_encr_names, algo->algo_v2id, v2namebuf, sizeof(v2namebuf)),
			  (int)((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),
			  (int)((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 */
}
开发者ID:jgimenez,项目名称:libreswan,代码行数:47,代码来源:ike_alg_status.c


示例18: extract_ppk_id

/*
 * used by responder, for extracting PPK_ID from IKEv2 Notify
 * PPK_ID Payload, we store PPK_ID and its type in payl
 */
bool extract_ppk_id(pb_stream *pbs, struct ppk_id_payload *payl)
{
	size_t len = pbs_left(pbs);
	u_char dst[PPK_ID_MAXLEN];
	int idtype;

	if (len > PPK_ID_MAXLEN) {
		loglog(RC_LOG_SERIOUS, "PPK ID length is too big");
		return FALSE;
	}
	if (len <= 1) {
		loglog(RC_LOG_SERIOUS, "PPK ID data must be at least 1 byte (received %zd bytes including ppk type byte)",
			len);
		return FALSE;
	}

	if (!in_raw(dst, len, pbs, "Unified PPK_ID Payload")) {
		loglog(RC_LOG_SERIOUS, "PPK ID data could not be read");
		return FALSE;
	}

	DBG(DBG_CONTROL, DBG_log("received PPK_ID type: %s",
		enum_name(&ikev2_ppk_id_type_names, dst[0])));

	idtype = (int)dst[0];
	switch (idtype) {
	case PPK_ID_FIXED:
		DBG(DBG_CONTROL, DBG_log("PPK_ID of type PPK_ID_FIXED."));
		break;

	case PPK_ID_OPAQUE:
	default:
		loglog(RC_LOG_SERIOUS, "PPK_ID type %d (%s) not supported",
			idtype, enum_name(&ikev2_ppk_id_type_names, idtype));
		return FALSE;
	}

	/* clone ppk id data without ppk id type byte */
	clonetochunk(payl->ppk_id, dst + 1, len - 1, "PPK_ID data");
	DBG(DBG_CONTROL, DBG_dump_chunk("Extracted PPK_ID", payl->ppk_id));

	return TRUE;
}
开发者ID:libreswan,项目名称:libreswan,代码行数:47,代码来源:ikev2_ppk.c


示例19: enum_name

/* find or construct a string to describe an enum value
 * Result may be in STATIC buffer -- NOT RE-ENTRANT!
 *
 * One consequence is that you cannot have two or more calls
 * as arguments in a single logging call.  Use enum_name instead.
 * (Of course that means that unnamed values will be shown
 * badly.)
 */
const char *enum_showb(enum_names *ed, unsigned long val, char *buf, size_t blen)
{
	const char *p = enum_name(ed, val);

	if (p == NULL) {
		snprintf(buf, blen, "%lu??", val);
		p = buf;
	}
	return p;
}
开发者ID:jgimenez,项目名称:libreswan,代码行数:18,代码来源:constants.c


示例20: get_request_name

const char *
get_request_name(enum request request)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(req_info); i++)
		if (req_info[i].request == request)
			return enum_name(req_info[i].name);
	return request == REQ_UNKNOWN ? "unknown" : "run request";
}
开发者ID:FAKERINHEART,项目名称:tig,代码行数:10,代码来源:request.c



注:本文中的enum_name函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ enumerate函数代码示例发布时间:2022-05-30
下一篇:
C++ entry_free函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap