sl.h

Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Copyright (C) 2001-2006 FhG FOKUS
00005  *
00006  * This file is part of ser, a free SIP server.
00007  *
00008  * ser is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * For a license to use the ser software under conditions
00014  * other than those described here, or to purchase support for this
00015  * software, please contact iptel.org by e-mail at the following addresses:
00016  *    info@iptel.org
00017  *
00018  * ser is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License 
00024  * along with this program; if not, write to the Free Software 
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  */
00027 
00034 #ifndef _SL_H_
00035 #define _SL_H_
00036 
00037 #include "../../sr_module.h"
00038 #include "../../parser/msg_parser.h"
00039 
00040 /* callback for SL events */
00041 #define SLCB_REPLY_READY       (1<<0)  /* stateless reply ready to be sent */
00042 #define SLCB_ACK_FILTERED      (1<<1)  /* stateless ACK filtered */
00043 
00047 typedef struct sl_cbp {
00048         unsigned int type;     /* type of callback */
00049         sip_msg_t *req;        /* SIP request to reply to, or filtered ACK */
00050         int  code;             /* reply status code */
00051         str  *reason;          /* reply reason phrase */
00052         str  *reply;           /* raw content of the reply to be sent */
00053         struct dest_info *dst; /* info about destination address */
00054         void *cbp;             /* parameter from callback registration */
00055 } sl_cbp_t;
00056 
00060 typedef void (*sl_cbf_f)(sl_cbp_t *slcbp);
00061 
00065 typedef struct sl_cbelem {
00066         unsigned int type;         /* type of callback - can be a mask of types */
00067         sl_cbf_f cbf;              /* pointer to callback function */
00068         void *cbp;                 /* param to callback function */
00069         struct sl_cbelem* next;    /* next sl_cbelem value */
00070 } sl_cbelem_t;
00071 
00072 void sl_destroy_callbacks_list(void);
00073 
00074 typedef int (*sl_register_cb_f)(sl_cbelem_t *cbe);
00075 int sl_register_callback(sl_cbelem_t *cbe);
00076 
00077 void sl_run_callbacks(unsigned int type, struct sip_msg *req,
00078                 int code, char *reason, str *reply, struct dest_info *dst);
00079 
00080 /* prototypes for SL API funtions */
00081 typedef int (*get_reply_totag_f)(struct sip_msg *msg, str *tag);
00082 typedef int (*send_reply_f)(struct sip_msg *msg, int code, str *reason);
00083 typedef int (*sl_send_reply_f)(struct sip_msg *msg, int code, char *reason);
00084 typedef int (*sl_send_sreply_f)(struct sip_msg *msg, int code, str *reason);
00085 typedef int (*sl_send_dreply_f)(struct sip_msg *msg, int code, str *reason,
00086                 str *tag);
00087 
00091 typedef struct sl_api {
00092         sl_send_reply_f  zreply; /* send sl reply, reason is charz */
00093         sl_send_sreply_f sreply; /* send sl reply, reason is str */
00094         sl_send_dreply_f dreply; /* send sl reply with tag, reason is str */
00095         send_reply_f     freply; /* send sl reply with tag, reason is str */
00096         get_reply_totag_f get_reply_totag;
00097         sl_register_cb_f  register_cb;
00098 } sl_api_t;
00099 
00100 typedef int (*bind_sl_f)(sl_api_t* api);
00101 
00105 static inline int sl_load_api(sl_api_t *slb)
00106 {
00107         bind_sl_f bindsl;
00108 
00109         bindsl = (bind_sl_f)find_export("bind_sl", 0, 0);
00110         if ( bindsl == 0) {
00111                 LM_ERR("cannot find bind_sl\n");
00112                 return -1;
00113         }
00114         if (bindsl(slb)==-1)
00115         {
00116                 LM_ERR("cannot bind sl api\n");
00117                 return -1;
00118         }
00119         return 0;
00120 }
00121 
00122 #endif /* _SL_H_ */