Пример #1
0
/*
 * see header
 */
payload_t *payload_create(payload_type_t type)
{
	switch (type)
	{
		case HEADER:
			return (payload_t*)ike_header_create();
		case SECURITY_ASSOCIATION:
			return (payload_t*)sa_payload_create();
		case PROPOSAL_SUBSTRUCTURE:
			return (payload_t*)proposal_substructure_create();
		case TRANSFORM_SUBSTRUCTURE:
			return (payload_t*)transform_substructure_create();
		case TRANSFORM_ATTRIBUTE:
			return (payload_t*)transform_attribute_create();
		case NONCE:
			return (payload_t*)nonce_payload_create();
		case ID_INITIATOR:
			return (payload_t*)id_payload_create(ID_INITIATOR);
		case ID_RESPONDER:
			return (payload_t*)id_payload_create(ID_RESPONDER);
#ifdef ME
		case ID_PEER:
			return (payload_t*)id_payload_create(ID_PEER);
#endif /* ME */
		case AUTHENTICATION:
			return (payload_t*)auth_payload_create();
		case CERTIFICATE:
			return (payload_t*)cert_payload_create();
		case CERTIFICATE_REQUEST:
			return (payload_t*)certreq_payload_create();
		case TRAFFIC_SELECTOR_SUBSTRUCTURE:
			return (payload_t*)traffic_selector_substructure_create();
		case TRAFFIC_SELECTOR_INITIATOR:
			return (payload_t*)ts_payload_create(TRUE);
		case TRAFFIC_SELECTOR_RESPONDER:
			return (payload_t*)ts_payload_create(FALSE);
		case KEY_EXCHANGE:
			return (payload_t*)ke_payload_create();
		case NOTIFY:
			return (payload_t*)notify_payload_create();
		case DELETE:
			return (payload_t*)delete_payload_create(0);
		case VENDOR_ID:
			return (payload_t*)vendor_id_payload_create();
		case CONFIGURATION:
			return (payload_t*)cp_payload_create();
		case CONFIGURATION_ATTRIBUTE:
			return (payload_t*)configuration_attribute_create();
		case EXTENSIBLE_AUTHENTICATION:
			return (payload_t*)eap_payload_create();
		case ENCRYPTED:
			return (payload_t*)encryption_payload_create();
		default:
			return (payload_t*)unknown_payload_create(type);
	}
}
Пример #2
0
/*
 * see header
 */
payload_t *payload_create(payload_type_t type)
{
	switch (type)
	{
		case PL_HEADER:
			return (payload_t*)ike_header_create();
		case PLV2_SECURITY_ASSOCIATION:
		case PLV1_SECURITY_ASSOCIATION:
			return (payload_t*)sa_payload_create(type);
		case PLV2_PROPOSAL_SUBSTRUCTURE:
		case PLV1_PROPOSAL_SUBSTRUCTURE:
			return (payload_t*)proposal_substructure_create(type);
		case PLV2_TRANSFORM_SUBSTRUCTURE:
		case PLV1_TRANSFORM_SUBSTRUCTURE:
			return (payload_t*)transform_substructure_create(type);
		case PLV2_TRANSFORM_ATTRIBUTE:
		case PLV1_TRANSFORM_ATTRIBUTE:
			return (payload_t*)transform_attribute_create(type);
		case PLV2_NONCE:
		case PLV1_NONCE:
			return (payload_t*)nonce_payload_create(type);
		case PLV2_ID_INITIATOR:
		case PLV2_ID_RESPONDER:
		case PLV1_ID:
		case PLV1_NAT_OA:
		case PLV1_NAT_OA_DRAFT_00_03:
#ifdef ME
		case PLV2_ID_PEER:
#endif /* ME */
			return (payload_t*)id_payload_create(type);
		case PLV2_AUTH:
			return (payload_t*)auth_payload_create();
		case PLV2_CERTIFICATE:
		case PLV1_CERTIFICATE:
			return (payload_t*)cert_payload_create(type);
		case PLV2_CERTREQ:
		case PLV1_CERTREQ:
			return (payload_t*)certreq_payload_create(type);
		case PLV2_TRAFFIC_SELECTOR_SUBSTRUCTURE:
			return (payload_t*)traffic_selector_substructure_create();
		case PLV2_TS_INITIATOR:
			return (payload_t*)ts_payload_create(TRUE);
		case PLV2_TS_RESPONDER:
			return (payload_t*)ts_payload_create(FALSE);
		case PLV2_KEY_EXCHANGE:
		case PLV1_KEY_EXCHANGE:
			return (payload_t*)ke_payload_create(type);
		case PLV2_NOTIFY:
		case PLV1_NOTIFY:
			return (payload_t*)notify_payload_create(type);
		case PLV2_DELETE:
		case PLV1_DELETE:
			return (payload_t*)delete_payload_create(type, 0);
		case PLV2_VENDOR_ID:
		case PLV1_VENDOR_ID:
			return (payload_t*)vendor_id_payload_create(type);
		case PLV1_HASH:
		case PLV1_SIGNATURE:
		case PLV1_NAT_D:
		case PLV1_NAT_D_DRAFT_00_03:
			return (payload_t*)hash_payload_create(type);
		case PLV2_CONFIGURATION:
		case PLV1_CONFIGURATION:
			return (payload_t*)cp_payload_create(type);
		case PLV2_CONFIGURATION_ATTRIBUTE:
		case PLV1_CONFIGURATION_ATTRIBUTE:
			return (payload_t*)configuration_attribute_create(type);
		case PLV2_EAP:
			return (payload_t*)eap_payload_create();
		case PLV2_ENCRYPTED:
		case PLV1_ENCRYPTED:
			return (payload_t*)encrypted_payload_create(type);
		case PLV1_FRAGMENT:
			return (payload_t*)fragment_payload_create();
		case PLV2_FRAGMENT:
			return (payload_t*)encrypted_fragment_payload_create();
		default:
			return (payload_t*)unknown_payload_create(type);
	}
}