jabberd2  2.2.17
bind.c
Go to the documentation of this file.
1 /*
2  * jabberd - Jabber Open Source Server
3  * Copyright (c) 2002-2003 Jeremie Miller, Thomas Muldowney,
4  * Ryan Eatmon, Robert Norris
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
19  */
20 
28 #include "c2s.h"
29 
31 static void _bind_features(sx_t s, sx_plugin_t p, nad_t nad) {
32  int ns;
33 
34  if(s->auth_id == NULL) {
35  c2s_t c2s;
36  host_t host;
37 
38  log_debug(ZONE, "not auth'd, offering auth and register");
39 
40  ns = nad_add_namespace(nad, uri_IQAUTH, NULL);
41  nad_append_elem(nad, ns, "auth", 1);
42 
43  c2s = (c2s_t) p->private;
44  host = xhash_get(c2s->hosts, s->req_to);
45  if(! host) host = c2s->vhost;
46  if(host && host->ar_register_enable) {
47  ns = nad_add_namespace(nad, uri_IQREGISTER, NULL);
48  nad_append_elem(nad, ns, "register", 1);
49  }
50  } else {
51  log_debug(ZONE, "auth'd, offering resource bind and session");
52 
53  ns = nad_add_namespace(nad, uri_BIND, NULL);
54  nad_append_elem(nad, ns, "bind", 1);
55  nad_append_elem(nad, -1, "required", 2);
56  nad->scope = ns;
57  nad_append_elem(nad, ns, "unbind", 1);
58 #ifdef ENABLE_SUPERSEDED
59  ns = nad_add_namespace(nad, uri_XSESSION, NULL);
60  nad_append_elem(nad, ns, "session", 1);
61 #endif
62  ns = nad_add_namespace(nad, uri_ROSTERVER, NULL);
63  nad_append_elem(nad, ns, "ver", 1);
64  }
65 }
66 
69 int bind_init(sx_env_t env, sx_plugin_t p, va_list args) {
70  c2s_t c2s;
71 
72  log_debug(ZONE, "initialising resource bind sx plugin");
73 
74  c2s = va_arg(args, c2s_t);
75 
77  p->private = (void *) c2s;
78 
79  return 0;
80 }