exec_hf.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2001-2003 FhG Fokus
  5. *
  6. * This file is part of Kamailio, a free SIP server.
  7. *
  8. * Kamailio is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * Kamailio is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef _EXEC_HF_H
  23. #define _EXEC_HF_H
  24. #include "../../parser/msg_parser.h"
  25. /* prefix prepended to header field name in env var name */
  26. #define SIP "SIP_"
  27. #define HF_PREFIX SIP "HF_"
  28. #define HF_PREFIX_LEN (sizeof(HF_PREFIX)-1)
  29. /* well known variable names */
  30. #define EV_SRCIP SIP "SRCIP"
  31. #define EV_RURI SIP "RURI"
  32. #define EV_ORURI SIP "ORUI"
  33. #define EV_USER SIP "USER"
  34. #define EV_OUSER SIP "OUSER"
  35. #define EV_TID SIP "TID"
  36. #define EV_DID SIP "DID"
  37. /* env var assignment operator */
  38. #define EV_ASSIGN '='
  39. /* header field separator */
  40. #define HF_SEPARATOR ','
  41. /* RFC3261 -- characters legal in header names; a really
  42. * _bloated_ thing
  43. */
  44. #define UNRESERVED_MARK "-_.!~*'()"
  45. #define HNV_UNRESERVED "[]/?:+$"
  46. #define ESCAPE '%'
  47. /* and this is what all such crazy symbols in header field
  48. * name will be replaced with in env vars */
  49. #define HFN_SYMBOL '_'
  50. #define VAR_VIA "VIA"
  51. #define VAR_VIA_LEN (sizeof(VAR_VIA)-1)
  52. #define VAR_CTYPE "CONTENT_TYPE"
  53. #define VAR_CTYPE_LEN (sizeof(VAR_CTYPE)-1)
  54. #define VAR_FROM "FROM"
  55. #define VAR_FROM_LEN (sizeof(VAR_FROM)-1)
  56. #define VAR_CALLID "CALLID"
  57. #define VAR_CALLID_LEN (sizeof(VAR_CALLID)-1)
  58. #define VAR_SUPPORTED "SUPPORTED"
  59. #define VAR_SUPPORTED_LEN (sizeof(VAR_SUPPORTED)-1)
  60. #define VAR_CLEN "CONTENT_LENGTH"
  61. #define VAR_CLEN_LEN (sizeof(VAR_CLEN)-1)
  62. #define VAR_CONTACT "CONTACT"
  63. #define VAR_CONTACT_LEN (sizeof(VAR_CONTACT)-1)
  64. #define VAR_TO "TO"
  65. #define VAR_TO_LEN (sizeof(VAR_TO)-1)
  66. #define VAR_EVENT "EVENT"
  67. #define VAR_EVENT_LEN (sizeof(VAR_EVENT)-1)
  68. #if 0
  69. /* _JUST_FOR_INFO_HERE */
  70. struct hdr_field {
  71. int type; /* Header field type */
  72. str name; /* Header field name */
  73. str body; /* Header field body */
  74. void* parsed; /* Parsed data structures */
  75. struct hdr_field* next; /* Next header field in the list */
  76. };
  77. #endif
  78. typedef struct env {
  79. char** env;
  80. int old_cnt;
  81. } environment_t;
  82. struct attrval {
  83. str attr;
  84. str val;
  85. };
  86. enum wrapper_type { W_HF=1, W_AV };
  87. struct hf_wrapper {
  88. enum wrapper_type var_type;
  89. union {
  90. struct hdr_field *hf;
  91. struct attrval av;
  92. } u;
  93. /* next header field of the same type */
  94. struct hf_wrapper *next_same;
  95. /* next header field of a different type */
  96. struct hf_wrapper *next_other;
  97. /* env var value (zero terminated) */
  98. char *envvar;
  99. /* variable name prefix (if any) */
  100. char *prefix;
  101. int prefix_len;
  102. };
  103. extern unsigned int setvars;
  104. extern char **environ;
  105. environment_t *set_env(struct sip_msg *msg);
  106. void unset_env(environment_t *backup_env);
  107. #endif