jabberd2  2.5.0
address.c
Go to the documentation of this file.
1 /*
2  * jabberd - Jabber Open Source Server
3  * Copyright (c) 2007 Tomasz Sterna
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; version 2 of the License
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
17  */
18 
19 /*
20  * this sx plugin implements My IP Address extension
21  * as described in http://delta.affinix.com/specs/xmppstream.html#myip
22  */
23 
24 #include "c2s.h"
25 
27 static void _address_features(sx_t s, sx_plugin_t p, nad_t nad) {
28  int ns;
29 
30  /* offer feature only when not authenticated yet */
31  if(s->state >= state_OPEN)
32  return;
33 
34  _sx_debug(ZONE, "adding address feature");
35 
36  ns = nad_add_namespace(nad, uri_ADDRESS_FEATURE, NULL);
37  nad_append_elem(nad, ns, "address", 1);
38  nad_append_cdata(nad, s->ip, strlen(s->ip), 2);
39 }
40 
42 int address_init(sx_env_t env, sx_plugin_t p, va_list args) {
43  log_debug(ZONE, "initialising address sx plugin");
44 
46 
47  return 0;
48 }
const char * ip
Definition: sx.h:262
int address_init(sx_env_t env, sx_plugin_t p, va_list args)
args: none
Definition: address.c:42
Definition: nad.h:93
_sx_state_t state
Definition: sx.h:319
void nad_append_cdata(nad_t nad, const char *cdata, int len, int depth)
append new cdata to the last elem
Definition: nad.c:753
void(* features)(sx_t s, sx_plugin_t p, nad_t nad)
Definition: sx.h:373
an environment
Definition: sx.h:382
a plugin
Definition: sx.h:347
int nad_add_namespace(nad_t nad, const char *uri, const char *prefix)
bring a new namespace into scope
Definition: nad.c:778
int nad_append_elem(nad_t nad, int ns, const char *name, int depth)
create a new elem on the list
Definition: nad.c:711
static void _address_features(sx_t s, sx_plugin_t p, nad_t nad)
sx features callback
Definition: address.c:27
#define uri_ADDRESS_FEATURE
Definition: uri.h:57
holds the state for a single stream
Definition: sx.h:253
#define log_debug(...)
Definition: log.h:65
#define _sx_debug
Definition: sx.h:408
#define ZONE
Definition: mio_impl.h:76
Definition: sx.h:74