jabberd2
2.2.17
Main Page
Data Structures
Files
File List
Globals
sm
mod_iq_ping.c
Go to the documentation of this file.
1
/*
2
* jabberd - Jabber Open Source Server
3
* Copyright (c) 2002 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
21
#include "
sm.h
"
22
30
static
int
ns_PING
= 0;
31
32
void
_iq_ping_reply
(
pkt_t
pkt) {
33
int
ns, elem;
34
35
ns =
nad_find_scoped_namespace
(pkt->
nad
,
urn_PING
, NULL);
36
elem =
nad_find_elem
(pkt->
nad
, 1, ns,
"ping"
, 1);
37
if
(elem>=0)
38
nad_drop_elem
(pkt->
nad
, elem);
39
40
nad_set_attr
(pkt->
nad
, 1, -1,
"type"
,
"result"
, 6);
41
42
return
;
43
}
44
45
static
mod_ret_t
_iq_ping_in_sess
(
mod_instance_t
mi,
sess_t
sess,
pkt_t
pkt) {
46
if
(pkt->
to
!= NULL || pkt->
type
!=
pkt_IQ
|| pkt->
ns
!=
ns_PING
)
47
return
mod_PASS
;
48
_iq_ping_reply
(pkt);
49
pkt_sess
(pkt, sess);
50
return
mod_HANDLED
;
51
}
52
53
static
mod_ret_t
_iq_ping_pkt_sm
(
mod_instance_t
mi,
pkt_t
pkt) {
54
if
(pkt->
type
!=
pkt_IQ
|| pkt->
ns
!=
ns_PING
)
55
return
mod_PASS
;
56
_iq_ping_reply
(pkt);
57
pkt_router
(
pkt_tofrom
(pkt));
58
return
mod_HANDLED
;
59
}
60
61
static
void
_iq_ping_free
(
module_t
mod) {
62
sm_unregister_ns
(mod->
mm
->
sm
,
urn_PING
);
63
feature_unregister
(mod->
mm
->
sm
,
urn_PING
);
64
}
65
66
DLLEXPORT
int
module_init
(
mod_instance_t
mi,
char
*arg) {
67
module_t
mod = mi->
mod
;
68
69
if
(mod->
init
)
return
0;
70
71
mod->
in_sess
=
_iq_ping_in_sess
;
72
mod->
pkt_sm
=
_iq_ping_pkt_sm
;
73
mod->
free
=
_iq_ping_free
;
74
75
ns_PING
=
sm_register_ns
(mod->
mm
->
sm
,
urn_PING
);
76
feature_register
(mod->
mm
->
sm
,
urn_PING
);
77
78
return
0;
79
}
Generated by
1.8.1.1