Просмотр исходного кода

(Logical change 1.130)

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@468 fd59a12c-fef9-0310-b244-a6a79926bd2f
Mark Haverkamp 21 лет назад
Родитель
Сommit
887e2b62c0
2 измененных файлов с 576 добавлено и 0 удалено
  1. 337 0
      include/ipc_evt.h
  2. 239 0
      include/saEvt.h

+ 337 - 0
include/ipc_evt.h

@@ -0,0 +1,337 @@
+/*
+ * Copyright (c) 2004-2005 Mark Haverkamp
+ * Copyright (c) 2004-2005 Open Source Development Lab
+ *
+ * All rights reserved.
+ *
+ * This software licensed under BSD license, the text of which follows:
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * - Neither the name of the Open Source Developement Lab nor the names of its
+ *   contributors may be used to endorse or promote products derived from this
+ *   software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IPC_EVT_H_DEFINED
+#define IPC_EVT_H_DEFINED
+
+#include <netinet/in.h>
+#include "ais_types.h"
+#include "saEvt.h"
+#include "saClm.h"
+#include "ipc_gen.h"
+
+enum req_evt_types {
+	MESSAGE_REQ_EVT_OPEN_CHANNEL = 1,
+	MESSAGE_REQ_EVT_CLOSE_CHANNEL,
+	MESSAGE_REQ_EVT_SUBSCRIBE,
+	MESSAGE_REQ_EVT_UNSUBSCRIBE,
+	MESSAGE_REQ_EVT_PUBLISH,
+	MESSAGE_REQ_EVT_CLEAR_RETENTIONTIME,
+	MESSAGE_REQ_EVT_EVENT_DATA
+};
+
+enum res_evt_types {
+	MESSAGE_RES_EVT_OPEN_CHANNEL = 1,
+	MESSAGE_RES_EVT_CLOSE_CHANNEL,
+	MESSAGE_RES_EVT_SUBSCRIBE,
+	MESSAGE_RES_EVT_UNSUBSCRIBE,
+	MESSAGE_RES_EVT_PUBLISH,
+	MESSAGE_RES_EVT_CLEAR_RETENTIONTIME,
+	MESSAGE_RES_EVT_CHAN_OPEN_CALLBACK,
+	MESSAGE_RES_EVT_EVENT_DATA,
+	MESSAGE_RES_EVT_AVAILABLE
+};
+
+/* 
+ * MESSAGE_REQ_EVT_OPEN_CHANNEL
+ *
+ * ico_head				Request head
+ * ico_open_flag:		Channel open flags
+ * ico_channel_name:	Name of channel to open
+ * ico_c_handle:		Local lib channel handle (used in returned event data)
+ * ico_timeout:			Used only by open
+ * ico_invocation:		Used only by async open
+ *
+ */
+struct req_evt_channel_open {
+
+	struct req_header		ico_head;
+	SaUint8T				ico_open_flag;
+	SaNameT					ico_channel_name;
+	SaEvtChannelHandleT		ico_c_handle;	/* client chan handle */
+	SaTimeT					ico_timeout;    /* open only */
+	SaInvocationT			ico_invocation; /* open async only */
+};
+
+/*
+ * MESSAGE_RES_EVT_OPEN_CHANNEL
+ * 
+ *
+ * ico_head:			Results head
+ * ico_error:			Request results
+ * ico_channel_handle:	Server side channel handle (used in channel ops)
+ *
+ */
+struct res_evt_channel_open {
+
+	struct res_header	ico_head;
+	uint32_t			ico_channel_handle;/* svr chan handle */
+
+};
+
+/*
+ * MESSAGE_RES_EVT_CHAN_OPEN_CALLBACK
+ *
+ * TODO: Define this
+ */
+struct res_evt_open_chan_async {
+	struct res_header	ico_head;
+};
+
+
+/*
+ * MESSAGE_REQ_EVT_CLOSE_CHANNEL
+ *
+ * icc_head:			Request head
+ * icc_channel_handle:	Server handle of channel to close
+ *
+ */
+struct req_evt_channel_close {
+
+	struct req_header		icc_head;
+	uint32_t				icc_channel_handle;
+};
+
+/*
+ * MESSAGE_RES_EVT_CLOSE_CHANNEL
+ *
+ * icc_head:		Results head
+ * icc_error:		Request result
+ *
+ */
+struct res_evt_channel_close {
+	struct res_header	icc_head;
+};
+
+/* 
+ * MESSAGE_REQ_EVT_SUBSCRIBE
+ *
+ * ics_head:			Request head
+ * ics_channel_handle:	Server handle of channel
+ * ics_sub_id:			Subscription ID
+ * ics_filter_size:		Size of supplied filter data
+ * ics_filter_count:	Number of filters supplied
+ * ics_filter_data:		Filter data
+ *
+ */
+struct req_evt_event_subscribe {
+
+	struct req_header		ics_head;
+	uint32_t				ics_channel_handle;
+	SaEvtSubscriptionIdT	ics_sub_id;
+	uint32_t				ics_filter_size;
+	uint32_t				ics_filter_count;
+	uint8_t					ics_filter_data[0];
+
+};
+
+/*
+ * MESSAGE_RES_EVT_SUBSCRIBE
+ *
+ * ics_head:		Result head
+ * ics_error:		Request results
+ *
+ */
+struct res_evt_event_subscribe {
+	struct res_header	ics_head;
+};
+
+/*
+ * MESSAGE_REQ_EVT_UNSUBSCRIBE
+ *
+ * icu_head:			Request head
+ * icu_channel_handle:	Server handle of channel
+ * icu_sub_id:			Subscription ID
+ *
+ */
+struct req_evt_event_unsubscribe {
+
+	struct req_header		icu_head;
+	uint32_t				icu_channel_handle;
+	SaEvtSubscriptionIdT	icu_sub_id;
+};
+
+
+/*
+ * MESSAGE_RES_EVT_UNSUBSCRIBE
+ *
+ * icu_head:		Results head
+ * icu_error:		request result
+ *
+ */
+struct res_evt_event_unsubscribe {
+	struct res_header	icu_head;
+
+};
+
+/*
+ * MESSAGE_REQ_EVT_EVENT_DATA
+ * MESSAGE_RES_EVT_AVAILABLE
+ *
+ * evd_head:		Request Head
+ */
+struct res_evt_event_data {
+		struct res_header	evd_head;
+};
+
+/*
+ * MESSAGE_REQ_EVT_PUBLISH			(1)
+ * MESSAGE_RES_EVT_EVENT_DATA		(2)
+ * MESSAGE_REQ_EXEC_EVT_EVENTDATA	(3)
+ * MESSAGE_REQ_EXEC_EVT_RECOVERY_EVENTDATA	(4)
+ *
+ * led_head:				Request/Results head
+ * led_in_addr:				address of node (4 only)
+ * led_receive_time:		Time that the message was received (4 only)
+ * led_svr_channel_handle:	Server channel handle (1 only)
+ * led_lib_channel_handle:	Lib channel handle (2 only)
+ * led_chan_name:			Channel name (3 and 4 only)
+ * led_event_id:			Event ID (2, 3 and 4 only)
+ * led_sub_id:				Subscription ID (2 only)
+ * led_publisher_node_id:	Node ID of event publisher
+ * led_publisher_name:		Node name of event publisher
+ * led_retention_time:		Event retention time
+ * led_publish_time:		Publication time of the event
+ * led_priority:			Event priority
+ * led_user_data_offset:	Offset to user data
+ * led_user_data_size:		Size of user data
+ * led_patterns_number:		Number of patterns in the event
+ * led_body:				Pattern and user data
+ */
+struct lib_event_data {
+	struct res_header		led_head;
+	struct in_addr			led_in_addr;
+	SaTimeT					led_receive_time;
+	uint32_t				led_svr_channel_handle;
+	SaEvtChannelHandleT		led_lib_channel_handle;
+	SaNameT					led_chan_name;
+	SaEvtEventIdT			led_event_id;
+	SaEvtSubscriptionIdT	led_sub_id;
+	SaClmNodeIdT			led_publisher_node_id;
+	SaNameT					led_publisher_name;
+	SaTimeT					led_retention_time;
+	SaTimeT					led_publish_time;
+	SaEvtEventPriorityT		led_priority;
+	uint32_t				led_user_data_offset;
+	uint32_t				led_user_data_size;
+	uint32_t				led_patterns_number;
+	uint8_t					led_body[0];
+};
+
+/*
+ * MESSAGE_RES_EVT_PUBLISH
+ *
+ * iep_head:		Result head
+ * iep_error:		Request results
+ * iep_event_id:	Event ID of published message
+ *
+ */
+struct res_evt_event_publish {
+
+	struct res_header	iep_head;
+	SaEvtEventIdT		iep_event_id;
+};
+
+/*
+ * MESSAGE_REQ_EVT_CLEAR_RETENTIONTIME
+ *
+ * Request message:
+ *
+ * iec_head:			Request head
+ * iec_event_id:		ID of event to clear
+ * iec_channel_handle:	Server handle of associate channel
+ *
+ */
+struct req_evt_event_clear_retentiontime {
+
+	struct req_header	iec_head;
+	SaEvtEventIdT		iec_event_id;
+	uint32_t			iec_channel_handle;
+
+};
+
+/*
+ * MESSAGE_RES_EVT_CLEAR_RETENTIONTIME
+ *
+ * iec_head:		Results head
+ * iec_error:		Request result
+ *
+ */
+struct res_evt_event_clear_retentiontime {
+	struct res_header	iec_head;
+};
+
+
+/*
+ * MESSAGE_REQ_EXEC_EVT_CHANCMD
+ *
+ * chc_header:	Request head
+ * chc_chan:	Channel Name
+ * chc_op:		Channel operation (open, close, clear retentiontime)
+ */
+
+enum evt_chan_ops {
+	EVT_OPEN_CHAN_OP,		/* chc_chan */
+	EVT_CLOSE_CHAN_OP,  	/* chc_chan */
+	EVT_CLEAR_RET_OP,		/* chc_event_id */
+	EVT_SET_ID_OP,			/* chc_set_id */
+	EVT_CONF_DONE,			/* no data used */
+	EVT_OPEN_COUNT,			/* chc_set_opens */
+	EVT_OPEN_COUNT_DONE		/* no data used */
+};
+	
+struct evt_set_id {
+	struct in_addr	chc_addr;
+	SaEvtEventIdT	chc_last_id;
+};
+
+struct evt_set_opens {
+	SaNameT		chc_chan_name;
+	uint32_t	chc_open_count;
+};
+
+struct req_evt_chan_command {
+	struct req_header 	chc_head;
+	int 				chc_op;
+	union {
+		SaNameT				chc_chan;
+		SaEvtEventIdT		chc_event_id;
+		struct evt_set_id	chc_set_id;
+		struct evt_set_opens chc_set_opens;
+	} u;
+};
+
+#endif  /* AIS_EVT_H_DEFINED */
+/*
+ *	vi: set autoindent tabstop=4 shiftwidth=4 :
+ */

+ 239 - 0
include/saEvt.h

@@ -0,0 +1,239 @@
+/*
+ * Copyright (c) 2004-2005 Mark Haverkamp
+ * Copyright (c) 2004-2005 Open Source Development Lab
+ *
+ * All rights reserved.
+ *
+ * This software licensed under BSD license, the text of which follows:
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * - Neither the name of the Open Source Developement Lab nor the names of its
+ *   contributors may be used to endorse or promote products derived from this
+ *   software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "ais_types.h"
+
+#ifndef AIS_EVT_H_DEFINED
+#define AIS_EVT_H_DEFINED
+
+typedef SaUint64T SaEvtHandleT;
+typedef SaUint64T SaEvtEventHandleT;
+typedef SaUint64T SaEvtChannelHandleT;
+typedef SaUint32T SaEvtSubscriptionIdT;
+
+
+typedef void
+(*SaEvtEventDeliverCallbackT)(
+	SaEvtSubscriptionIdT subscriptionId,
+	const SaEvtEventHandleT eventHandle,
+	const SaSizeT eventDataSize
+);
+
+typedef void 
+(*SaEvtChannelOpenCallbackT)(
+	SaInvocationT invocation,
+	SaEvtChannelHandleT channelHandle,
+	SaAisErrorT error
+);
+
+typedef struct{
+    const SaEvtChannelOpenCallbackT saEvtChannelOpenCallback;
+    const SaEvtEventDeliverCallbackT saEvtEventDeliverCallback; 
+} SaEvtCallbacksT;
+
+#define SA_EVT_CHANNEL_PUBLISHER  0X1
+#define SA_EVT_CHANNEL_SUBSCRIBER 0X2
+#define SA_EVT_CHANNEL_CREATE     0X4
+typedef SaUint8T SaEvtChannelOpenFlagsT;
+
+typedef struct {
+    SaUint8T *pattern;
+    SaSizeT patternSize;
+} SaEvtEventPatternT;
+
+
+#define SA_EVT_HIGHEST_PRIORITY 0
+#define SA_EVT_LOWEST_PRIORITY  3
+
+/*
+ * Event ID values from 0 to 1000 are have special meanings
+ * and aren't used for regular events.
+ */
+
+/*
+ * Event ID for an allocated but not yet published event.
+ */
+#define SA_EVT_EVENTID_NONE	0
+
+/*
+ * Event ID for a "lost event".
+ */
+#define SA_EVT_EVENTID_LOST	1
+
+/*
+ * Pattern to indicate a "lost event" message.
+ */
+#define SA_EVT_LOST_EVENT "SA_EVT_LOST_EVENT_PATTERN"
+
+/*
+ * Size of the biggest data attachment to an event.
+ */
+#define SA_EVT_DATA_MAX_LEN (64 * 1024)
+
+typedef struct {
+    SaEvtEventPatternT *patterns;
+    SaSizeT patternsNumber;
+} SaEvtEventPatternArrayT;
+
+typedef SaUint8T SaEvtEventPriorityT;
+typedef SaUint64T SaEvtEventIdT;
+
+typedef enum {
+    SA_EVT_PREFIX_FILTER = 1,
+    SA_EVT_SUFFIX_FILTER = 2,
+    SA_EVT_EXACT_FILTER = 3,
+    SA_EVT_PASS_ALL_FILTER = 4
+} SaEvtEventFilterTypeT;
+
+typedef struct {
+    SaEvtEventFilterTypeT filterType;
+    SaEvtEventPatternT filter;
+} SaEvtEventFilterT;
+
+typedef struct {
+    SaEvtEventFilterT *filters;
+    SaSizeT filtersNumber;
+} SaEvtEventFilterArrayT;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SaAisErrorT
+saEvtInitialize(
+	SaEvtHandleT *evtHandle, 
+	const SaEvtCallbacksT *callbacks,
+        SaVersionT *version);
+
+SaAisErrorT
+saEvtSelectionObjectGet(
+	SaEvtHandleT evtHandle,
+        SaSelectionObjectT *selectionObject);
+
+SaAisErrorT
+saEvtDispatch(
+	SaEvtHandleT evtHandle, 
+	SaDispatchFlagsT dispatchFlags);
+
+SaAisErrorT
+saEvtFinalize(
+	SaEvtHandleT evtHandle);
+
+SaAisErrorT
+saEvtChannelOpen(
+	SaEvtHandleT evtHandle, 
+	const SaNameT *channelName,
+	SaEvtChannelOpenFlagsT channelOpenFlags,
+        SaTimeT timeout,
+        SaEvtChannelHandleT *channelHandle);
+
+SaAisErrorT
+saEvtChannelOpenAsync(
+	SaEvtHandleT evtHandle,
+	SaInvocationT invocation,
+	const SaNameT *channelName,
+	SaEvtChannelOpenFlagsT channelOpenFlags);
+
+SaAisErrorT
+saEvtChannelClose(
+	SaEvtChannelHandleT channelHandle);
+
+SaAisErrorT
+saEvtChannelUnlink(
+	SaEvtHandleT evtHandle, 
+	const SaNameT *channelName);
+
+SaAisErrorT
+saEvtEventAllocate(
+	SaEvtChannelHandleT channelHandle,
+	SaEvtEventHandleT *eventHandle);
+
+SaAisErrorT
+saEvtEventFree(
+	SaEvtEventHandleT eventHandle);
+
+SaAisErrorT
+saEvtEventAttributesSet(
+	SaEvtEventHandleT eventHandle,
+	const SaEvtEventPatternArrayT *patternArray,
+	SaEvtEventPriorityT priority,
+	SaTimeT retentionTime,
+	const SaNameT *publisherName);
+
+SaAisErrorT
+saEvtEventAttributesGet(
+	SaEvtEventHandleT eventHandle,
+	SaEvtEventPatternArrayT *patternArray,
+	SaEvtEventPriorityT *priority,
+	SaTimeT *retentionTime,
+	SaNameT *publisherName,
+	SaTimeT *publishTime,
+	SaEvtEventIdT *eventId);
+
+SaAisErrorT
+saEvtEventDataGet(
+	SaEvtEventHandleT eventHandle,
+	void *eventData,
+	SaSizeT *eventDataSize);
+
+SaAisErrorT
+saEvtEventPublish(
+	SaEvtEventHandleT eventHandle,
+	const void *eventData,
+	SaSizeT eventDataSize,
+	SaEvtEventIdT *eventId);
+
+SaAisErrorT
+saEvtEventSubscribe(
+	SaEvtChannelHandleT channelHandle,
+	const SaEvtEventFilterArrayT *filters,
+	SaEvtSubscriptionIdT subscriptionId);
+
+SaAisErrorT
+saEvtEventUnsubscribe(
+	SaEvtChannelHandleT channelHandle,
+	SaEvtSubscriptionIdT subscriptionId);
+
+SaAisErrorT
+saEvtEventRetentionTimeClear(
+	SaEvtChannelHandleT channelHandle,
+	SaEvtEventIdT eventId);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* AIS_EVT_H_DEFINED */
+/*
+ *	vi: set autoindent tabstop=4 shiftwidth=4 :
+ */