jabberd2
2.2.16
|
00001 /* 00002 * jabberd - Jabber Open Source Server 00003 * Copyright (c) 2002-2003 Jeremie Miller, Thomas Muldowney, 00004 * Ryan Eatmon, Robert Norris 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA 00019 */ 00020 00028 #include "c2s.h" 00029 00031 static void _bind_features(sx_t s, sx_plugin_t p, nad_t nad) { 00032 int ns; 00033 00034 if(s->auth_id == NULL) { 00035 c2s_t c2s; 00036 host_t host; 00037 00038 log_debug(ZONE, "not auth'd, offering auth and register"); 00039 00040 ns = nad_add_namespace(nad, uri_IQAUTH, NULL); 00041 nad_append_elem(nad, ns, "auth", 1); 00042 00043 c2s = (c2s_t) p->private; 00044 host = xhash_get(c2s->hosts, s->req_to); 00045 if(! host) host = c2s->vhost; 00046 if(host && host->ar_register_enable) { 00047 ns = nad_add_namespace(nad, uri_IQREGISTER, NULL); 00048 nad_append_elem(nad, ns, "register", 1); 00049 } 00050 } else { 00051 log_debug(ZONE, "auth'd, offering resource bind and session"); 00052 00053 ns = nad_add_namespace(nad, uri_BIND, NULL); 00054 nad_append_elem(nad, ns, "bind", 1); 00055 nad_append_elem(nad, -1, "required", 2); 00056 nad->scope = ns; 00057 nad_append_elem(nad, ns, "unbind", 1); 00058 #ifdef ENABLE_SUPERSEDED 00059 ns = nad_add_namespace(nad, uri_XSESSION, NULL); 00060 nad_append_elem(nad, ns, "session", 1); 00061 #endif 00062 ns = nad_add_namespace(nad, uri_ROSTERVER, NULL); 00063 nad_append_elem(nad, ns, "ver", 1); 00064 } 00065 } 00066 00069 int bind_init(sx_env_t env, sx_plugin_t p, va_list args) { 00070 c2s_t c2s; 00071 00072 log_debug(ZONE, "initialising resource bind sx plugin"); 00073 00074 c2s = va_arg(args, c2s_t); 00075 00076 p->features = _bind_features; 00077 p->private = (void *) c2s; 00078 00079 return 0; 00080 }