exec_hf.h 3.5 KB

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