src/modules/exec/exec_hf.h
31ccf6a2
 /*
  * Copyright (C) 2001-2003 FhG Fokus
  *
27642a08
  * This file is part of Kamailio, a free SIP server.
31ccf6a2
  *
27642a08
  * Kamailio is free software; you can redistribute it and/or modify
31ccf6a2
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version
  *
27642a08
  * Kamailio is distributed in the hope that it will be useful,
31ccf6a2
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
34ec1fc3
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
9e1ff448
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
31ccf6a2
  */
 
ffc671a1
 /*!
  * \file
  * \brief Exec module:: Header Field handling
34ec1fc3
  * \ingroup exec
ffc671a1
  * Module: \ref exec
  */
 
31ccf6a2
 #ifndef _EXEC_HF_H
 #define _EXEC_HF_H
 
cf83221d
 #include "../../core/parser/msg_parser.h"
31ccf6a2
 
 /* prefix prepended to header field name in env var name */
 #define SIP "SIP_"
 #define HF_PREFIX SIP "HF_"
34ec1fc3
 #define HF_PREFIX_LEN (sizeof(HF_PREFIX) - 1)
31ccf6a2
 /* well known variable names */
 #define EV_SRCIP SIP "SRCIP"
 #define EV_RURI SIP "RURI"
 #define EV_ORURI SIP "ORUI"
 #define EV_USER SIP "USER"
 #define EV_OUSER SIP "OUSER"
 #define EV_TID SIP "TID"
 #define EV_DID SIP "DID"
 /* env var assignment operator */
 #define EV_ASSIGN '='
 /* header field separator */
 #define HF_SEPARATOR ','
 /* RFC3261 -- characters legal in header names; a really
  * _bloated_ thing
  */
34ec1fc3
 #define UNRESERVED_MARK "-_.!~*'()"
 #define HNV_UNRESERVED "[]/?:+$"
31ccf6a2
 #define ESCAPE '%'
 /* and this is what all such crazy symbols in header field
  * name will be replaced with in env vars */
 #define HFN_SYMBOL '_'
 
 #define VAR_VIA "VIA"
34ec1fc3
 #define VAR_VIA_LEN (sizeof(VAR_VIA) - 1)
31ccf6a2
 #define VAR_CTYPE "CONTENT_TYPE"
34ec1fc3
 #define VAR_CTYPE_LEN (sizeof(VAR_CTYPE) - 1)
31ccf6a2
 #define VAR_FROM "FROM"
34ec1fc3
 #define VAR_FROM_LEN (sizeof(VAR_FROM) - 1)
31ccf6a2
 #define VAR_CALLID "CALLID"
34ec1fc3
 #define VAR_CALLID_LEN (sizeof(VAR_CALLID) - 1)
31ccf6a2
 #define VAR_SUPPORTED "SUPPORTED"
34ec1fc3
 #define VAR_SUPPORTED_LEN (sizeof(VAR_SUPPORTED) - 1)
31ccf6a2
 #define VAR_CLEN "CONTENT_LENGTH"
34ec1fc3
 #define VAR_CLEN_LEN (sizeof(VAR_CLEN) - 1)
31ccf6a2
 #define VAR_CONTACT "CONTACT"
34ec1fc3
 #define VAR_CONTACT_LEN (sizeof(VAR_CONTACT) - 1)
31ccf6a2
 #define VAR_TO "TO"
34ec1fc3
 #define VAR_TO_LEN (sizeof(VAR_TO) - 1)
31ccf6a2
 #define VAR_EVENT "EVENT"
34ec1fc3
 #define VAR_EVENT_LEN (sizeof(VAR_EVENT) - 1)
31ccf6a2
 
 
 #if 0
 /* _JUST_FOR_INFO_HERE */
 struct hdr_field {
         int type;                /* Header field type */
         str name;                /* Header field name */
         str body;                /* Header field body */
         void* parsed;            /* Parsed data structures */
         struct hdr_field* next;  /* Next header field in the list */
 };
 #endif
 
34ec1fc3
 typedef struct env
 {
 	char **env;
31ccf6a2
 	int old_cnt;
 } environment_t;
 
34ec1fc3
 struct attrval
 {
31ccf6a2
 	str attr;
 	str val;
 };
 
34ec1fc3
 enum wrapper_type
 {
 	W_HF = 1,
 	W_AV
 };
31ccf6a2
 
34ec1fc3
 struct hf_wrapper
 {
31ccf6a2
 	enum wrapper_type var_type;
34ec1fc3
 	union
 	{
31ccf6a2
 		struct hdr_field *hf;
 		struct attrval av;
 	} u;
 	/* next header field of the same type */
 	struct hf_wrapper *next_same;
 	/* next header field of a different type */
 	struct hf_wrapper *next_other;
 	/* env var value (zero terminated) */
 	char *envvar;
 	/* variable name prefix (if any) */
 	char *prefix;
 	int prefix_len;
 };
 
 extern unsigned int setvars;
 extern char **environ;
 
 environment_t *set_env(struct sip_msg *msg);
 void unset_env(environment_t *backup_env);
 
 #endif