154925bf6Swillf /*
254925bf6Swillf  * lib/krb5/os/accessor.c
354925bf6Swillf  *
454925bf6Swillf  * Copyright 1990 by the Massachusetts Institute of Technology.
554925bf6Swillf  * All Rights Reserved.
654925bf6Swillf  *
754925bf6Swillf  * Export of this software from the United States of America may
854925bf6Swillf  *   require a specific license from the United States Government.
954925bf6Swillf  *   It is the responsibility of any person or organization contemplating
1054925bf6Swillf  *   export to obtain such a license before exporting.
11*55fea89dSDan Cross  *
1254925bf6Swillf  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
1354925bf6Swillf  * distribute this software and its documentation for any purpose and
1454925bf6Swillf  * without fee is hereby granted, provided that the above copyright
1554925bf6Swillf  * notice appear in all copies and that both that copyright notice and
1654925bf6Swillf  * this permission notice appear in supporting documentation, and that
1754925bf6Swillf  * the name of M.I.T. not be used in advertising or publicity pertaining
1854925bf6Swillf  * to distribution of the software without specific, written prior
1954925bf6Swillf  * permission.  Furthermore if you modify this software you must label
2054925bf6Swillf  * your software as modified software and not distribute it in such a
2154925bf6Swillf  * fashion that it might be confused with the original M.I.T. software.
2254925bf6Swillf  * M.I.T. makes no representations about the suitability of
2354925bf6Swillf  * this software for any purpose.  It is provided "as is" without express
2454925bf6Swillf  * or implied warranty.
25*55fea89dSDan Cross  *
2654925bf6Swillf */
2754925bf6Swillf 
2854925bf6Swillf #include "k5-int.h"
2954925bf6Swillf #include "os-proto.h"
3054925bf6Swillf 
3154925bf6Swillf /* If this trick gets used elsewhere, move it to k5-platform.h.  */
3254925bf6Swillf #ifndef DESIGNATED_INITIALIZERS
335fb574e8SToomas Soome /* ANSI/ISO C 1999 supports this...  */
345fb574e8SToomas Soome #if __STDC_VERSION__ >= 199901L				\
3554925bf6Swillf    /* ...as does GCC, since version 2.something.  */	\
365fb574e8SToomas Soome    || (!defined __cplusplus && __GNUC__ >= 3)
375fb574e8SToomas Soome #define DESIGNATED_INITIALIZERS	1
385fb574e8SToomas Soome #else
395fb574e8SToomas Soome #define DESIGNATED_INITIALIZERS	0
405fb574e8SToomas Soome #endif
4154925bf6Swillf #endif
4254925bf6Swillf 
4354925bf6Swillf krb5_error_code KRB5_CALLCONV
krb5int_accessor(krb5int_access * internals,krb5_int32 version)4454925bf6Swillf krb5int_accessor(krb5int_access *internals, krb5_int32 version)
4554925bf6Swillf {
4654925bf6Swillf     if (version == KRB5INT_ACCESS_VERSION) {
4754925bf6Swillf #if DESIGNATED_INITIALIZERS
4854925bf6Swillf #define S(FIELD, VAL)   .FIELD = VAL
4954925bf6Swillf 	static const krb5int_access internals_temp = {
5054925bf6Swillf #else
5154925bf6Swillf #define S(FIELD, VAL)   internals_temp.FIELD = VAL
5254925bf6Swillf 	    krb5int_access internals_temp;
5354925bf6Swillf #endif
5454925bf6Swillf 	    S (free_addrlist, krb5int_free_addrlist),
5554925bf6Swillf 	    S (krb5_hmac, krb5_hmac),
5654925bf6Swillf 	    S (md5_hash_provider, &krb5int_hash_md5),
5754925bf6Swillf 	    S (arcfour_enc_provider, &krb5int_enc_arcfour),
5854925bf6Swillf 	    S (sendto_udp, &krb5int_sendto),
5954925bf6Swillf 	    S (add_host_to_list, krb5int_add_host_to_list),
6054925bf6Swillf #ifdef KRB5_DNS_LOOKUP
6154925bf6Swillf 	    S (make_srv_query_realm, krb5int_make_srv_query_realm),
6254925bf6Swillf 	    S (free_srv_dns_data, krb5int_free_srv_dns_data),
6354925bf6Swillf 	    S (use_dns_kdc, _krb5_use_dns_kdc),
6454925bf6Swillf #else
6554925bf6Swillf 	    S (make_srv_query_realm, 0),
6654925bf6Swillf 	    S (free_srv_dns_data, 0),
6754925bf6Swillf 	    S (use_dns_kdc, 0),
6854925bf6Swillf #endif
69ba7b222eSGlenn Barry             S (clean_hostname, krb5int_clean_hostname),
70ba7b222eSGlenn Barry 
7154925bf6Swillf #ifdef KRB5_KRB4_COMPAT
7254925bf6Swillf 	    S (krb_life_to_time, krb5int_krb_life_to_time),
7354925bf6Swillf 	    S (krb_time_to_life, krb5int_krb_time_to_life),
7454925bf6Swillf 	    S (krb524_encode_v4tkt, krb5int_encode_v4tkt),
7554925bf6Swillf #else
7654925bf6Swillf 	    S (krb_life_to_time, 0),
7754925bf6Swillf 	    S (krb_time_to_life, 0),
7854925bf6Swillf 	    S (krb524_encode_v4tkt, 0),
7954925bf6Swillf #endif
8054925bf6Swillf 	    S (krb5int_c_mandatory_cksumtype, krb5int_c_mandatory_cksumtype),
8154925bf6Swillf 	    S (krb5_ser_pack_int64, krb5_ser_pack_int64),
8254925bf6Swillf 	    S (krb5_ser_unpack_int64, krb5_ser_unpack_int64),
8354925bf6Swillf 	    S (asn1_ldap_encode_sequence_of_keys, krb5int_ldap_encode_sequence_of_keys),
8454925bf6Swillf 	    S (asn1_ldap_decode_sequence_of_keys, krb5int_ldap_decode_sequence_of_keys),
85159d09a2SMark Phalan 	    S (encode_krb5_pa_pk_as_req, encode_krb5_pa_pk_as_req),
86159d09a2SMark Phalan 	    S (encode_krb5_pa_pk_as_req_draft9, encode_krb5_pa_pk_as_req_draft9),
87159d09a2SMark Phalan             S (encode_krb5_pa_pk_as_rep, encode_krb5_pa_pk_as_rep),
88159d09a2SMark Phalan 	    S (encode_krb5_pa_pk_as_rep_draft9, encode_krb5_pa_pk_as_rep_draft9),
89159d09a2SMark Phalan 	    S (encode_krb5_auth_pack, encode_krb5_auth_pack),
90159d09a2SMark Phalan 	    S (encode_krb5_auth_pack_draft9, encode_krb5_auth_pack_draft9),
91159d09a2SMark Phalan 	    S (encode_krb5_kdc_dh_key_info, encode_krb5_kdc_dh_key_info),
92159d09a2SMark Phalan 	    S (encode_krb5_reply_key_pack, encode_krb5_reply_key_pack),
93159d09a2SMark Phalan 	    S (encode_krb5_reply_key_pack_draft9, encode_krb5_reply_key_pack_draft9),
94159d09a2SMark Phalan 	    S (encode_krb5_typed_data, encode_krb5_typed_data),
95159d09a2SMark Phalan 	    S (encode_krb5_td_trusted_certifiers, encode_krb5_td_trusted_certifiers),
96159d09a2SMark Phalan 	    S (encode_krb5_td_dh_parameters, encode_krb5_td_dh_parameters),
97159d09a2SMark Phalan 	    S (decode_krb5_pa_pk_as_req, decode_krb5_pa_pk_as_req),
98159d09a2SMark Phalan 	    S (decode_krb5_pa_pk_as_req_draft9, decode_krb5_pa_pk_as_req_draft9),
99159d09a2SMark Phalan 	    S (decode_krb5_pa_pk_as_rep, decode_krb5_pa_pk_as_rep),
100159d09a2SMark Phalan 	    S (decode_krb5_pa_pk_as_rep_draft9, decode_krb5_pa_pk_as_rep_draft9),
101159d09a2SMark Phalan 	    S (decode_krb5_auth_pack, decode_krb5_auth_pack),
102159d09a2SMark Phalan 	    S (decode_krb5_auth_pack_draft9, decode_krb5_auth_pack_draft9),
103159d09a2SMark Phalan 	    S (decode_krb5_kdc_dh_key_info, decode_krb5_kdc_dh_key_info),
104159d09a2SMark Phalan 	    S (decode_krb5_principal_name, decode_krb5_principal_name),
105159d09a2SMark Phalan 	    S (decode_krb5_reply_key_pack, decode_krb5_reply_key_pack),
106159d09a2SMark Phalan 	    S (decode_krb5_reply_key_pack_draft9, decode_krb5_reply_key_pack_draft9),
107159d09a2SMark Phalan 	    S (decode_krb5_typed_data, decode_krb5_typed_data),
108159d09a2SMark Phalan 	    S (decode_krb5_td_trusted_certifiers, decode_krb5_td_trusted_certifiers),
109159d09a2SMark Phalan 	    S (decode_krb5_td_dh_parameters, decode_krb5_td_dh_parameters),
110159d09a2SMark Phalan 	    S (decode_krb5_as_req, decode_krb5_as_req),
111159d09a2SMark Phalan 	    S (encode_krb5_kdc_req_body, encode_krb5_kdc_req_body),
112159d09a2SMark Phalan 	    S (krb5_free_kdc_req, krb5_free_kdc_req),
113159d09a2SMark Phalan 	    S (krb5int_set_prompt_types, krb5int_set_prompt_types),
114159d09a2SMark Phalan 	    S (encode_krb5_authdata_elt, encode_krb5_authdata_elt),
11554925bf6Swillf #if DESIGNATED_INITIALIZERS
11654925bf6Swillf 	};
11754925bf6Swillf #else
11854925bf6Swillf 	/*LINTED*/
11954925bf6Swillf 	0;
12054925bf6Swillf #endif
12154925bf6Swillf 	*internals = internals_temp;
12254925bf6Swillf 	return 0;
12354925bf6Swillf     }
12454925bf6Swillf     return KRB5_OBSOLETE_FN;
12554925bf6Swillf }
126