modules_s/exec/exec_hf.h

00001 /*
00002  *
00003  * $Id$
00004  *
00005  *
00006  * Copyright (C) 2001-2003 FhG Fokus
00007  *
00008  * This file is part of ser, a free SIP server.
00009  *
00010  * ser is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * For a license to use the ser software under conditions
00016  * other than those described here, or to purchase support for this
00017  * software, please contact iptel.org by e-mail at the following addresses:
00018  *    info@iptel.org
00019  *
00020  * ser is distributed in the hope that it will be useful,
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  * GNU General Public License for more details.
00024  *
00025  * You should have received a copy of the GNU General Public License 
00026  * along with this program; if not, write to the Free Software 
00027  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028  */
00029 
00030 #ifndef _EXEC_HF_H
00031 #define _EXEC_HF_H
00032 
00033 #include "../../parser/msg_parser.h"
00034 
00035 /* prefix prepended to header field name in env var name */
00036 #define SIP "SIP_"
00037 #define HF_PREFIX SIP "HF_"
00038 #define HF_PREFIX_LEN (sizeof(HF_PREFIX)-1)
00039 /* well known variable names */
00040 #define EV_SRCIP SIP "SRCIP"
00041 #define EV_RURI SIP "RURI"
00042 #define EV_ORURI SIP "ORUI"
00043 #define EV_USER SIP "USER"
00044 #define EV_OUSER SIP "OUSER"
00045 #define EV_TID SIP "TID"
00046 #define EV_DID SIP "DID"
00047 /* env var assignment operator */
00048 #define EV_ASSIGN '='
00049 /* header field separator */
00050 #define HF_SEPARATOR ','
00051 /* RFC3261 -- characters legal in header names; a really
00052  * _bloated_ thing
00053  */
00054 #define UNRESERVED_MARK "-_.!~*'()"
00055 #define HNV_UNRESERVED  "[]/?:+$"
00056 #define ESCAPE '%'
00057 /* and this is what all such crazy symbols in header field
00058  * name will be replaced with in env vars */
00059 #define HFN_SYMBOL '_'
00060 
00061 #define VAR_VIA "VIA"
00062 #define VAR_VIA_LEN (sizeof(VAR_VIA)-1)
00063 #define VAR_CTYPE "CONTENT_TYPE"
00064 #define VAR_CTYPE_LEN (sizeof(VAR_CTYPE)-1)
00065 #define VAR_FROM "FROM"
00066 #define VAR_FROM_LEN (sizeof(VAR_FROM)-1)
00067 #define VAR_CALLID "CALLID"
00068 #define VAR_CALLID_LEN (sizeof(VAR_CALLID)-1)
00069 #define VAR_SUPPORTED "SUPPORTED"
00070 #define VAR_SUPPORTED_LEN (sizeof(VAR_SUPPORTED)-1)
00071 #define VAR_CLEN "CONTENT_LENGTH"
00072 #define VAR_CLEN_LEN (sizeof(VAR_CLEN)-1)
00073 #define VAR_CONTACT "CONTACT"
00074 #define VAR_CONTACT_LEN (sizeof(VAR_CONTACT)-1)
00075 #define VAR_TO "TO"
00076 #define VAR_TO_LEN (sizeof(VAR_TO)-1)
00077 #define VAR_EVENT "EVENT"
00078 #define VAR_EVENT_LEN (sizeof(VAR_EVENT)-1)
00079 
00080 
00081 
00082 #if 0
00083 /* _JUST_FOR_INFO_HERE */
00084 struct hdr_field {
00085         int type;                /* Header field type */
00086         str name;                /* Header field name */
00087         str body;                /* Header field body */
00088         void* parsed;            /* Parsed data structures */
00089         struct hdr_field* next;  /* Next header field in the list */
00090 };
00091 #endif
00092 
00093 typedef struct env {
00094         char** env;
00095         int old_cnt;
00096 } environment_t;
00097 
00098 struct attrval {
00099         str attr;
00100         str val;
00101 };
00102 
00103 enum wrapper_type { W_HF=1, W_AV };
00104 
00105 struct hf_wrapper {
00106         enum wrapper_type var_type;
00107         union {
00108                 struct hdr_field *hf;
00109                 struct attrval av;
00110         } u;
00111         /* next header field of the same type */
00112         struct hf_wrapper *next_same;
00113         /* next header field of a different type */
00114         struct hf_wrapper *next_other;
00115         /* env var value (zero terminated) */
00116         char *envvar;
00117         /* variable name prefix (if any) */
00118         char *prefix;
00119         int prefix_len;
00120 };
00121 
00122 extern unsigned int setvars;
00123 extern char **environ;
00124 
00125 environment_t *set_env(struct sip_msg *msg);
00126 void unset_env(environment_t *backup_env);
00127 
00128 #endif