jabberd2  2.2.16
sm/mod_validate.c
Go to the documentation of this file.
00001 /*
00002  * jabberd - Jabber Open Source Server
00003  * Copyright (c) 2002 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 
00021 #include "sm.h"
00022 
00030 static mod_ret_t _validate_in_sess(mod_instance_t mi, sess_t sess, pkt_t pkt)
00031 {
00032     /* only want message, presence and iq */
00033     if(!(pkt->type & pkt_MESSAGE || pkt->type & pkt_PRESENCE || pkt->type & pkt_IQ || pkt->type & pkt_S10N)) {
00034         log_debug(ZONE, "we only take message, presence and iq packets");
00035         return -stanza_err_BAD_REQUEST;
00036     }
00037 
00038     return mod_PASS;
00039 }
00040 
00041 static mod_ret_t _validate_in_router(mod_instance_t mi, pkt_t pkt)
00042 {
00043     return _validate_in_sess(mi, NULL, pkt);
00044 }
00045 
00046 DLLEXPORT int module_init(mod_instance_t mi, char *arg) {
00047     module_t mod = mi->mod;
00048 
00049     if(mod->init) return 0;
00050 
00051     mod->in_sess = _validate_in_sess;
00052     mod->in_router = _validate_in_router;
00053 
00054     return 0;
00055 }