Debian Codegraph @

src/security/core/tests/common/plugin_wrapper_msg_q.h

raw
1 /*
2 * Copyright(c) 2006 to 2020 ZettaScale Technology and others
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v. 2.0 which is available at
6 * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
7 * v. 1.0 which is available at
8 * http://www.eclipse.org/org/documents/edl-v10.php.
9 *
10 * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
11 */
12 #ifndef SECURITY_CORE_PLUGIN_WRAPPER_MSG_Q_H_
13 #define SECURITY_CORE_PLUGIN_WRAPPER_MSG_Q_H_
14
15 #include "dds/dds.h"
16 #include "dds/ddsrt/sync.h"
17
18 #include "dds/security/dds_security_api.h"
19
20 typedef enum {
21 MESSAGE_KIND_VALIDATE_LOCAL_IDENTITY,
22 MESSAGE_KIND_VALIDATE_REMOTE_IDENTITY,
23 MESSAGE_KIND_BEGIN_HANDSHAKE_REQUEST,
24 MESSAGE_KIND_BEGIN_HANDSHAKE_REPLY,
25 MESSAGE_KIND_PROCESS_HANDSHAKE
26 } message_kind_t;
27
28 struct message {
29 message_kind_t kind;
30 DDS_Security_IdentityHandle lidHandle;
31 DDS_Security_IdentityHandle ridHandle;
32 DDS_Security_IdentityHandle hsHandle;
33 DDS_Security_GUID_t lguid;
34 DDS_Security_GUID_t rguid;
35 DDS_Security_ValidationResult_t result;
36 char * err_msg;
37 DDS_Security_DataHolder token;
38 void *instance;
39 struct message *next;
40 };
41
42 struct message_queue {
43 ddsrt_mutex_t lock;
44 ddsrt_cond_t cond;
45 struct message *head;
46 struct message *tail;
47 };
48
49 enum take_message_result {
50 TAKE_MESSAGE_OK, /* message found */
51 TAKE_MESSAGE_TIMEOUT_EMPTY, /* no message found, queue is empty */
52 TAKE_MESSAGE_TIMEOUT_NONEMPTY /* no message found, queue is not empty */
53 };
54
55 struct dds_security_authentication_impl;
56
57 void insert_message(struct message_queue *queue, struct message *msg);
58 void add_message(struct message_queue *queue, message_kind_t kind, DDS_Security_IdentityHandle lidHandle, DDS_Security_IdentityHandle ridHandle, DDS_Security_IdentityHandle hsHandle,
59 const DDS_Security_GUID_t *lguid, const DDS_Security_GUID_t *rguid, DDS_Security_ValidationResult_t result, const char * err_msg,
60 const DDS_Security_DataHolder *token, void *instance);
61 void delete_message(struct message *msg);
62 void init_message_queue(struct message_queue *queue);
63 void deinit_message_queue(struct message_queue *queue);
64 int message_matched(struct message *msg, message_kind_t kind, DDS_Security_IdentityHandle lidHandle, DDS_Security_IdentityHandle ridHandle, DDS_Security_IdentityHandle hsHandle);
65 enum take_message_result take_message(struct message_queue *queue, message_kind_t kind, DDS_Security_IdentityHandle lidHandle, DDS_Security_IdentityHandle ridHandle, DDS_Security_IdentityHandle hsHandle, dds_time_t abstimeout, struct message **msg);
66
67
68 #endif /* SECURITY_CORE_PLUGIN_WRAPPER_MSG_Q_H_ */