jabberd2  2.2.16
sx/address.c
Go to the documentation of this file.
00001 /*
00002  * jabberd - Jabber Open Source Server
00003  * Copyright (c) 2007 Tomasz Sterna
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; version 2 of the License
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
00017  */
00018 
00019 /*
00020  * this sx plugin implements My IP Address extension
00021  * as described in http://delta.affinix.com/specs/xmppstream.html#myip
00022  */
00023 
00024 #include "sx.h"
00025 
00027 static void _sx_address_features(sx_t s, sx_plugin_t p, nad_t nad) {
00028     int ns;
00029 
00030     /* offer feature only when not authenticated yet */
00031     if(s->state >= state_OPEN)
00032         return;
00033 
00034     _sx_debug(ZONE, "adding address feature");
00035 
00036     ns = nad_add_namespace(nad, uri_ADDRESS_FEATURE, NULL);
00037     nad_append_elem(nad, ns, "address", 1);
00038     nad_append_cdata(nad, s->ip, strlen(s->ip), 2);
00039 }
00040 
00042 int sx_address_init(sx_env_t env, sx_plugin_t p, va_list args) {
00043     log_debug(ZONE, "initialising address sx plugin");
00044 
00045     p->features = _sx_address_features;
00046 
00047     return 0;
00048 }