#include <stdarg.h>\r
#include <stdio.h>\r
+#include "CredentialsCache.h"\r
+#include "msg.h"\r
+#include "rpc_auth.h"\r
+\r
+/* This object module is platform dependent. */\r
\r
int main( int argc, char *argv[] )\r
{\r
+ cc_int32 code;\r
+ int running = 1;\r
+\r
/* we need a set of functions we want to support.\r
* so we can provide an abstract platform independent\r
* interface.\r
*/\r
\r
+ code = ccs_serv_initialize();\r
+ if (code) {\r
+ /* ok. we failed to initialize the ccs data structures.\r
+ * terminate service start. Log the result. \r
+ */\r
+ fprintf(stderr, "ccs_serv_initialize failure: %d\n", code);\r
+ return -1;\r
+ }\r
+\r
+ /* initialize the IPC mechanism for this platform */\r
+\r
+ /* implement a message loop that receives in-bound requests\r
+ * processes them, and sends back responses.\r
+ */\r
+ while ( running ) {\r
+ cc_msg_t * req_msg, *resp_msg;\r
+ cc_auth_info_t* auth_info;\r
+ cc_session_info_t* session_info;\r
+ char * data;\r
+ int len;\r
+\r
+ /* accept IPC request */\r
+\r
+ /* unflatten input stream to msg */\r
+ code = cci_msg_unflatten(data, len, &req_msg);\r
+\r
+ /* process request */\r
+ code = ccs_serv_process_msg(req_msg, auth_info, session_info, &resp_msg);\r
+\r
+ code = cci_msg_flatten(resp_msg, NULL); \r
+\r
+ /* send response (resp_msg->flat, resp_msg->flat_len) */\r
+\r
+ /* cleanup */\r
+ cci_msg_destroy(req_msg);\r
+ cci_msg_destroy(resp_msg);\r
+ }\r
+\r
+ /* de-register IPC mechanism */\r
+\r
+ /* cleanup ccs resources */\r
+ ccs_serv_cleanup();\r
+\r
+ /* exit */\r
return 0;\r
}\r
#include "rpc_auth.h"
cc_int32
-cci_rpc_is_authorized( cc_auth_info_t* msg_auth, cc_session_info_t* msg_session, cc_auth_info_t* stored_auth,
+ccs_rpc_is_authorized( cc_auth_info_t* msg_auth, cc_session_info_t* msg_session, cc_auth_info_t* stored_auth,
cc_session_info_t* stored_session, cc_uint32 * authorizedp)
{
- if (msg_auth == stored_auth && msg_session == stored_session)
+ if (msg_auth->len == stored_auth->len &&
+ !memcmp(msg_auth->info, stored_auth->info, msg_auth->len) &&
+ msg_session->len == stored_session->len &&
+ !memcmp(msg_session->info, stored_session->info, msg_session->len))
*authorizedp = 1;
else
*authorizedp = 0;
/* $Copyright:
*
- * Copyright 2004 by the Massachusetts Institute of Technology.
+ * Copyright 2004-2006 by the Massachusetts Institute of Technology.
*
* All rights reserved.
*
};
typedef struct cc_session_info_t cc_session_info_t;
-cc_int32 cci_rpc_is_authorized(cc_auth_info_t* msg_auth, cc_session_info_t* msg_session, cc_auth_info_t* stored_auth, cc_session_info_t* stored_session, cc_uint32 *authorizedp);
+cc_int32 ccs_rpc_is_authorized(cc_auth_info_t* msg_auth, cc_session_info_t* msg_session, cc_auth_info_t* stored_auth, cc_session_info_t* stored_session, cc_uint32 *authorizedp);
#endif /*__RPC_AUTH_H__*/
}
#if 0
+ /* These message types are only generated by the server in response
+ * to a request. They are never received.
+ */
TypeToOpMapping->operations[ccmsg_ACK] = ccop_ACK;
TypeToOpMapping->operations[ccmsg_NACK] = ccop_NACK;
#endif
return ccNoError;
};
+cc_int32
+ccs_serv_cleanup(void)
+{
+ return ccNoError;
+}
+
cc_int32
ccs_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg)
{
return code;
}
ctx = (cc_server_context_t *)ctx_node->data;
- code = cci_rpc_is_authorized(auth_info, session_info, ctx->auth_info, ctx->session_info, &authorized);
+ code = ccs_rpc_is_authorized(auth_info, session_info, ctx->auth_info, ctx->session_info, &authorized);
if (code != ccNoError) {
ccs_context_free_iterator(ctx_iterator);
return code;
return code;
}
- code = cci_rpc_is_authorized(auth, session, ctx->auth_info, ctx->session_info, &authorized);
+ code = ccs_rpc_is_authorized(auth, session, ctx->auth_info, ctx->session_info, &authorized);
if (code != ccNoError) {
ccs_context_free_iterator(ctx_iterator);
return code;
typedef struct type_to_op_mapping_t type_to_op_mapping_t;
cc_int32 ccs_serv_initialize(void);
+cc_int32 ccs_serv_cleanup(void);
cc_int32 ccs_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg);
cc_int32 ccs_serv_find_ctx(cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_server_context_t** contextp);
cc_int32 ccs_serv_find_ctx_by_handle(cc_handle ctx_handle, cc_auth_info_t *auth, cc_session_info_t* session, cc_server_context_t** contextp);