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