1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 */
25
26/*
27 * ldom_xmpp_client.h	Extensible Messaging and Presence Protocol
28 */
29
30#ifndef	_LDOM_XMPP_CLIENT_H
31#define	_LDOM_XMPP_CLIENT_H
32
33#include <sys/fm/ldom.h>
34
35#include <pthread.h>
36#include <libxml/xmlstring.h>
37
38#ifdef	__cplusplus
39extern "C" {
40#endif
41
42#define	XMPP_DEFAULT_PORT	6482
43#define	XMPP_BUF_SIZE		1024
44#define	RAND_BUF_SIZE		1024
45#define	XMPP_SLEEP		3
46
47#define	STREAM_NODE		(xmlChar *)"stream:stream"
48#define	FEATURE_NODE		(xmlChar *)"stream:features"
49#define	STARTTLS_NODE		(xmlChar *)"starttls"
50#define	PROCEED_NODE		(xmlChar *)"proceed"
51#define	XML_LDM_INTERFACE	((xmlChar *)"LDM_interface")
52#define	XML_LDM_EVENT		((xmlChar *)"LDM_event")
53
54#define	XML_SUCCESS		((xmlChar *)"success")
55#define	XML_FAILURE		((xmlChar *)"failure")
56
57#define	XML_CMD			((xmlChar *)"cmd")
58#define	XML_ACTION		((xmlChar *)"action")
59#define	XML_RESPONSE		((xmlChar *)"response")
60#define	XML_STATUS		((xmlChar *)"status")
61#define	XML_DATA		((xmlChar *)"data")
62#define	XML_ENVELOPE		((xmlChar *)"Envelope")
63#define	XML_CONTENT		((xmlChar *)"Content")
64
65#define	XML_ATTR_ID		((xmlChar *)"id")
66
67#define	XML_REGISTER_ACTION	"reg-domain-events"
68
69#define	STREAM_START		"<?xml version='1.0'?><stream:stream " \
70				"xml:lang=\"en\" version=\"1.0\" id=\"xmpp\"" \
71				">"
72#define	START_TLS	"<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"
73
74#define	LDM_REG_DOMAIN_EVENTS	\
75			"<LDM_interface version=\"1.1\">" \
76			"   <cmd>" \
77			"      <action>reg-domain-events</action>" \
78			"      <data version=\"3.0\"> </data>" \
79			"   </cmd>" \
80			"</LDM_interface>"
81
82
83typedef struct ldom_event_info {
84	ldom_event_t id;
85	char *name;
86} ldom_event_info_t;
87
88
89typedef struct client_info {
90	ldom_hdl_t *lhp;
91	ldom_reg_cb_t cb;
92	ldom_cb_arg_t data;
93	struct client_info *next;
94	struct client_info *prev;
95} client_info_t;
96
97typedef struct client_list {
98	client_info_t *head;
99	client_info_t *tail;
100	pthread_mutex_t lock;
101} client_list_t;
102
103
104extern int xmpp_add_client(ldom_hdl_t *lhp, ldom_reg_cb_t cb,
105				ldom_cb_arg_t data);
106extern int xmpp_remove_client(ldom_hdl_t *lhp);
107extern void xmpp_start(void);
108extern void xmpp_stop(void);
109
110#ifdef	__cplusplus
111}
112#endif
113
114#endif	/* _LDOM_XMPP_CLIENT_H */
115