From: Ken Raeburn Date: Mon, 2 Feb 2009 20:56:18 +0000 (+0000) Subject: Collect hairy parts of krb5_is_ macros into one helper macro X-Git-Tag: krb5-1.8-alpha1~735 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=777f05d1b91d07ece4bd0e313e131b1a640cfad4;p=krb5.git Collect hairy parts of krb5_is_ macros into one helper macro git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21869 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/include/k5-int.h b/src/include/k5-int.h index 7de6c1a60..ee8508fe2 100644 --- a/src/include/k5-int.h +++ b/src/include/k5-int.h @@ -1302,57 +1302,26 @@ void KRB5_CALLCONV krb5_free_priv_enc_part */ /* allow either constructed or primitive encoding, so check for bit 6 set or reset */ -#define krb5_is_krb_ticket(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x61 ||\ - (dat)->data[0] == 0x41)) -#define krb5_is_krb_authenticator(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x62 ||\ - (dat)->data[0] == 0x42)) -#define krb5_is_as_req(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x6a ||\ - (dat)->data[0] == 0x4a)) -#define krb5_is_as_rep(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x6b ||\ - (dat)->data[0] == 0x4b)) -#define krb5_is_tgs_req(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x6c ||\ - (dat)->data[0] == 0x4c)) -#define krb5_is_tgs_rep(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x6d ||\ - (dat)->data[0] == 0x4d)) -#define krb5_is_ap_req(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x6e ||\ - (dat)->data[0] == 0x4e)) -#define krb5_is_ap_rep(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x6f ||\ - (dat)->data[0] == 0x4f)) -#define krb5_is_krb_safe(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x74 ||\ - (dat)->data[0] == 0x54)) -#define krb5_is_krb_priv(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x75 ||\ - (dat)->data[0] == 0x55)) -#define krb5_is_krb_cred(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x76 ||\ - (dat)->data[0] == 0x56)) -#define krb5_is_krb_enc_as_rep_part(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x79 ||\ - (dat)->data[0] == 0x59)) -#define krb5_is_krb_enc_tgs_rep_part(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x7a ||\ - (dat)->data[0] == 0x5a)) -#define krb5_is_krb_enc_ap_rep_part(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x7b ||\ - (dat)->data[0] == 0x5b)) -#define krb5_is_krb_enc_krb_priv_part(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x7c ||\ - (dat)->data[0] == 0x5c)) -#define krb5_is_krb_enc_krb_cred_part(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x7d ||\ - (dat)->data[0] == 0x5d)) -#define krb5_is_krb_error(dat)\ - ((dat) && (dat)->length && ((dat)->data[0] == 0x7e ||\ - (dat)->data[0] == 0x5e)) +#define krb5int_is_app_tag(dat,tag)\ + ((dat) && (dat)->length && \ + ((((dat)->data[0] & ~0x20) == ((tag) | 0x40)))) +#define krb5_is_krb_ticket(dat) krb5int_is_app_tag(dat, 1) +#define krb5_is_krb_authenticator(dat) krb5int_is_app_tag(dat, 2) +#define krb5_is_as_req(dat) krb5int_is_app_tag(dat, 10) +#define krb5_is_as_rep(dat) krb5int_is_app_tag(dat, 11) +#define krb5_is_tgs_req(dat) krb5int_is_app_tag(dat, 12) +#define krb5_is_tgs_rep(dat) krb5int_is_app_tag(dat, 13) +#define krb5_is_ap_req(dat) krb5int_is_app_tag(dat, 14) +#define krb5_is_ap_rep(dat) krb5int_is_app_tag(dat, 15) +#define krb5_is_krb_safe(dat) krb5int_is_app_tag(dat, 20) +#define krb5_is_krb_priv(dat) krb5int_is_app_tag(dat, 21) +#define krb5_is_krb_cred(dat) krb5int_is_app_tag(dat, 22) +#define krb5_is_krb_enc_as_rep_part(dat) krb5int_is_app_tag(dat, 25) +#define krb5_is_krb_enc_tgs_rep_part(dat) krb5int_is_app_tag(dat, 26) +#define krb5_is_krb_enc_ap_rep_part(dat) krb5int_is_app_tag(dat, 27) +#define krb5_is_krb_enc_krb_priv_part(dat) krb5int_is_app_tag(dat, 28) +#define krb5_is_krb_enc_krb_cred_part(dat) krb5int_is_app_tag(dat, 29) +#define krb5_is_krb_error(dat) krb5int_is_app_tag(dat, 30) /************************************************************************* * Prototypes for krb5_encode.c