From 4e824737afa8bb05db07d92a04855149c2fba5d8 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Fri, 19 May 2006 09:18:37 +0000 Subject: Updates of portable CCAPI sources. All code compiles git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18022 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/client/cacheapi.c | 42 ++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) (limited to 'src/lib/ccapi/client/cacheapi.c') diff --git a/src/lib/ccapi/client/cacheapi.c b/src/lib/ccapi/client/cacheapi.c index 2c874bec0f..704925dfd7 100644 --- a/src/lib/ccapi/client/cacheapi.c +++ b/src/lib/ccapi/client/cacheapi.c @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -47,10 +47,17 @@ #include "ccache.h" #include "ccache_iterator.h" #include "context.h" +#include "cc_rpc.h" #include "msg.h" #include "msg_headers.h" -cc_int32 +/*! \fn cc_initialize + * \brief A function that initializes a ccapi context for the caller. + * \param[out] outContext a cc_context_t pointer to which is assigned the newly created context upon success. + * \param[in] inVersion a cc_int32 that specifies the + */ + +CCACHE_API cc_int32 cc_initialize ( cc_context_t* outContext, cc_int32 inVersion, cc_int32* outSupportedVersion, @@ -60,16 +67,18 @@ cc_initialize ( cc_context_t* outContext, cc_msg_t *request; ccmsg_init_t *request_header; cc_msg_t *response; + cc_uint32 type; ccmsg_init_resp_t *response_header; cc_int32 code; if ((inVersion != ccapi_version_2) && (inVersion != ccapi_version_3) && (inVersion != ccapi_version_4) && - (inVersion != ccapi_version_5)) { + (inVersion != ccapi_version_5) && + (inVersion != ccapi_version_6)) { if (outSupportedVersion != NULL) { - *outSupportedVersion = ccapi_version_5; + *outSupportedVersion = ccapi_version_6; } return ccErrBadAPIVersion; } @@ -78,7 +87,17 @@ cc_initialize ( cc_context_t* outContext, if (request_header == NULL) return ccErrNoMem; - request_header->in_version = inVersion; + /* If the version number is 2, the caller will be passing + * the structure into the v2 compatibility functions which + * in turn will call the v6 functions. Set the version to + * ccapi_version_max since that is what the compatibility + * functions will be expecting. + */ + if (inVersion == ccapi_version_2) + inVersion = ccapi_version_max; + + /* Construct the request */ + request_header->in_version = htonl(inVersion); code = cci_msg_new(ccmsg_INIT, &request); if (code != ccNoError) { @@ -90,17 +109,18 @@ cc_initialize ( cc_context_t* outContext, code = cci_perform_rpc(request, &response); - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_init_resp_t *)response->header; - *outSupportedVersion = response_header->out_version; - code = cc_context_int_new(outContext, response_header->out_ctx, response_header->out_version); + *outSupportedVersion = ntohl(response_header->out_version); + code = cc_int_context_new(outContext, ntohl(response_header->out_ctx), ntohl(response_header->out_version)); if (!vendor[0]) { char * string; - code = cci_msg_retrieve_blob(response, response_header->vendor_offset, response_header->vendor_length, &string); + code = cci_msg_retrieve_blob(response, ntohl(response_header->vendor_offset), ntohl(response_header->vendor_length), &string); strncpy(vendor, string, sizeof(vendor)-1); vendor[sizeof(vendor)-1] = '\0'; free(string); -- cgit From 46feb62dc0a36171dd14d33a9aab8b9af42fc595 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 22 May 2006 17:17:07 +0000 Subject: Move msg.c and marshall.c to common library Add dllmain.c which contains the Windows DllMain() entry point. This must be moved later to a Windows specific directory. Cleanup type usage and function name references. All that is missing now from the client DLL is a definition of cci_perform_rpc() which is the entry point to the IPC routine. git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18028 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/client/cacheapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/ccapi/client/cacheapi.c') diff --git a/src/lib/ccapi/client/cacheapi.c b/src/lib/ccapi/client/cacheapi.c index 704925dfd7..14a1eb4762 100644 --- a/src/lib/ccapi/client/cacheapi.c +++ b/src/lib/ccapi/client/cacheapi.c @@ -116,7 +116,7 @@ cc_initialize ( cc_context_t* outContext, } else if (type == ccmsg_ACK) { response_header = (ccmsg_init_resp_t *)response->header; *outSupportedVersion = ntohl(response_header->out_version); - code = cc_int_context_new(outContext, ntohl(response_header->out_ctx), ntohl(response_header->out_version)); + code = cc_int_context_new(outContext, ntohll(response_header->out_ctx), ntohl(response_header->out_version)); if (!vendor[0]) { char * string; -- cgit From f42fa33b985c230736ad5d9080055916de33be8c Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 5 Jun 2006 17:49:34 +0000 Subject: improved error handling git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18083 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/client/cacheapi.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/lib/ccapi/client/cacheapi.c') diff --git a/src/lib/ccapi/client/cacheapi.c b/src/lib/ccapi/client/cacheapi.c index 14a1eb4762..c76ebe4570 100644 --- a/src/lib/ccapi/client/cacheapi.c +++ b/src/lib/ccapi/client/cacheapi.c @@ -64,9 +64,9 @@ cc_initialize ( cc_context_t* outContext, char const** outVendor) { static char vendor[128] = ""; - cc_msg_t *request; + cc_msg_t *request = NULL; ccmsg_init_t *request_header; - cc_msg_t *response; + cc_msg_t *response = NULL; cc_uint32 type; ccmsg_init_resp_t *response_header; cc_int32 code; @@ -100,14 +100,17 @@ cc_initialize ( cc_context_t* outContext, request_header->in_version = htonl(inVersion); code = cci_msg_new(ccmsg_INIT, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_init_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; type = ntohl(response->type); if (type == ccmsg_NACK) { @@ -131,8 +134,15 @@ cc_initialize ( cc_context_t* outContext, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } -- cgit From 350cfced455d45368065095201bc2f674093cf41 Mon Sep 17 00:00:00 2001 From: Alexandra Ellwood Date: Fri, 9 Jun 2006 21:57:20 +0000 Subject: Include string.h to get memcpy, strlen, etc on BSD OSes git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18098 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/ccapi/client/cacheapi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/lib/ccapi/client/cacheapi.c') diff --git a/src/lib/ccapi/client/cacheapi.c b/src/lib/ccapi/client/cacheapi.c index c76ebe4570..89c5e63d1b 100644 --- a/src/lib/ccapi/client/cacheapi.c +++ b/src/lib/ccapi/client/cacheapi.c @@ -43,6 +43,7 @@ #include #include +#include #include #include "ccache.h" #include "ccache_iterator.h" -- cgit