sip.h 33.1 KB
Newer Older
Pekka Pessi's avatar
Pekka Pessi committed
1 2 3 4 5 6 7
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
8
 * This library is free software; you can redistribute it and/or
Pekka Pessi's avatar
Pekka Pessi committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

Pekka Pessi's avatar
Pekka Pessi committed
25 26
#ifndef SIP_H
/** Defined when <sofia-sip/sip.h> has been included. */
Pekka Pessi's avatar
Pekka Pessi committed
27
#define SIP_H
Pekka Pessi's avatar
Pekka Pessi committed
28

29
/**@file sofia-sip/sip.h 
Pekka Pessi's avatar
Pekka Pessi committed
30 31 32 33 34 35 36 37 38
 * 
 * SIP objects.
 *
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>.
 *
 * @date Created      : Thu Jun  8 19:28:55 2000 ppessi
 */

#ifndef MSG_TYPES_H
39
#include <sofia-sip/msg_types.h>
Pekka Pessi's avatar
Pekka Pessi committed
40 41
#endif
#ifndef MSG_MIME_H
42
#include <sofia-sip/msg_mime.h>
Pekka Pessi's avatar
Pekka Pessi committed
43 44
#endif

45 46
SOFIA_BEGIN_DECLS

Pekka Pessi's avatar
Pekka Pessi committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
/** IDs for well-known SIP methods. */
typedef enum {
  sip_method_invalid = -1,	/**< Invalid method name */
  sip_method_unknown = 0,	/**< Unknown method, use @c method_name */
  sip_method_invite,		/**< INVITE */
  sip_method_ack,		/**< ACK */
  sip_method_cancel,		/**< CANCEL */
  sip_method_bye,		/**< BYE */
  sip_method_options,		/**< OPTIONS */
  sip_method_register,		/**< REGISTER */
  sip_method_info,		/**< INFO */
  sip_method_prack,		/**< PRACK */
  sip_method_update,		/**< UPDATE */
  sip_method_message,		/**< MESSAGE */
  sip_method_subscribe,		/**< SUBSCRIBE */
  sip_method_notify,		/**< NOTIFY */
  sip_method_refer,		/**< REFER */
  sip_method_publish,		/**< PUBLISH */
} sip_method_t;

#define SIP_METHOD(s)         sip_method_unknown, #s
#define SIP_METHOD_ACK        sip_method_ack, "ACK"
#define SIP_METHOD_CANCEL     sip_method_cancel, "CANCEL"
#define SIP_METHOD_BYE        sip_method_bye, "BYE"
#define SIP_METHOD_INVITE     sip_method_invite, "INVITE"
#define SIP_METHOD_OPTIONS    sip_method_options, "OPTIONS"
#define SIP_METHOD_REGISTER   sip_method_register, "REGISTER"
#define SIP_METHOD_INFO       sip_method_info, "INFO"
#define SIP_METHOD_PRACK      sip_method_prack, "PRACK"
#define SIP_METHOD_UPDATE     sip_method_update, "UPDATE"
#define SIP_METHOD_MESSAGE    sip_method_message, "MESSAGE"
#define SIP_METHOD_SUBSCRIBE  sip_method_subscribe, "SUBSCRIBE"
#define SIP_METHOD_NOTIFY     sip_method_notify, "NOTIFY"
#define SIP_METHOD_REFER      sip_method_refer, "REFER"
#define SIP_METHOD_PUBLISH    sip_method_publish, "PUBLISH"

83
/** Magic pointer value - never valid for SIP headers. @HI */
Pekka Pessi's avatar
Pekka Pessi committed
84 85 86 87
#define SIP_NONE ((void const *)-1L)

/** SIP protocol identifier @HIDE */
#define SIP_PROTOCOL_TAG   ((void *)0x53495020)	/* 'SIP'20 */
Pekka Pessi's avatar
Pekka Pessi committed
88 89

enum {
Pekka Pessi's avatar
Pekka Pessi committed
90
  /** Default port for SIP as integer */
Pekka Pessi's avatar
Pekka Pessi committed
91
 SIP_DEFAULT_PORT = 5060,
Pekka Pessi's avatar
Pekka Pessi committed
92
#define SIP_DEFAULT_PORT SIP_DEFAULT_PORT
Pekka Pessi's avatar
Pekka Pessi committed
93

Pekka Pessi's avatar
Pekka Pessi committed
94
/** Default port for SIP as string */
Pekka Pessi's avatar
Pekka Pessi committed
95 96
#define SIP_DEFAULT_SERV "5060"

97 98 99 100 101 102 103
 /** Default port for SIPS as integer */
 SIPS_DEFAULT_PORT = 5061,
#define SIPS_DEFAULT_PORT SIPS_DEFAULT_PORT
 /** Default port for SIPS as string */
#define SIPS_DEFAULT_SERV "5061"
};

104
/** Time in seconds since Jan 01 1900.  */
Pekka Pessi's avatar
Pekka Pessi committed
105
typedef msg_time_t sip_time_t;
Pekka Pessi's avatar
Pekka Pessi committed
106

107
/** Latest time that can be expressed with #sip_time_t. @HIDE */
Pekka Pessi's avatar
Pekka Pessi committed
108
#define SIP_TIME_MAX ((sip_time_t)MSG_TIME_MAX)
Pekka Pessi's avatar
Pekka Pessi committed
109 110 111 112 113 114 115 116 117 118 119 120

/** SIP message object. */
typedef struct sip_s                sip_t;

/** Any SIP header - union of all possible SIP headers. */
typedef union sip_header_u          sip_header_t;

/** Type of a generic SIP header. */
typedef struct msg_generic_s        sip_generic_t;
#define g_value g_string

/** Common part of all the header structures. */
121
typedef msg_common_t                sip_common_t;
Pekka Pessi's avatar
Pekka Pessi committed
122 123 124 125

/** SIP parameter string. */
typedef msg_param_t                 sip_param_t;

126
/** @To or @From header. */
Pekka Pessi's avatar
Pekka Pessi committed
127 128
typedef struct sip_addr_s           sip_addr_t;

129
/** @Authorization, @ProxyAuthenticate, @WWWAuthenticate */
Pekka Pessi's avatar
Pekka Pessi committed
130 131 132 133 134 135 136 137 138 139 140 141
typedef msg_auth_t                  sip_auth_t;

typedef struct sip_request_s 	    sip_request_t;
typedef struct sip_status_s  	    sip_status_t;
typedef msg_error_t                 sip_error_t;
typedef msg_unknown_t               sip_unknown_t;
typedef msg_separator_t             sip_separator_t;
typedef msg_payload_t               sip_payload_t;

typedef struct sip_accept_s  	    sip_accept_t;
typedef msg_accept_any_t      	    sip_accept_encoding_t;
typedef msg_accept_any_t      	    sip_accept_language_t;
142
typedef struct sip_allow_s	    sip_allow_t;
143
typedef struct msg_auth_info_s      sip_authentication_info_t;
144
typedef struct msg_auth_s 	    sip_authorization_t;
Pekka Pessi's avatar
Pekka Pessi committed
145 146 147 148
typedef struct sip_call_id_s 	    sip_call_id_t;
typedef struct sip_call_info_s      sip_call_info_t;
typedef struct sip_contact_s 	    sip_contact_t;
typedef struct sip_cseq_s    	    sip_cseq_t;
149 150
typedef struct msg_generic_s        sip_etag_t;
typedef struct msg_generic_s        sip_if_match_t;
Pekka Pessi's avatar
Pekka Pessi committed
151
typedef msg_content_disposition_t   sip_content_disposition_t;
152
typedef msg_list_t	      	    sip_content_encoding_t;
Pekka Pessi's avatar
Pekka Pessi committed
153 154 155
typedef msg_list_t	      	    sip_content_language_t;
typedef struct sip_content_length_s sip_content_length_t;
typedef struct msg_content_type_s   sip_content_type_t;
156
typedef struct msg_generic_s        sip_mime_version_t;
Pekka Pessi's avatar
Pekka Pessi committed
157 158 159 160 161 162 163 164
typedef struct sip_date_s	    sip_date_t;
typedef struct sip_error_info_s     sip_error_info_t;
typedef struct sip_expires_s        sip_expires_t;
typedef struct sip_addr_s  	    sip_from_t;
typedef msg_list_t                  sip_in_reply_to_t;
typedef struct sip_max_forwards_s   sip_max_forwards_t;
typedef struct sip_min_expires_s    sip_min_expires_t;
typedef struct sip_min_se_s         sip_min_se_t;
165 166 167
typedef struct msg_generic_s        sip_organization_t;
typedef struct msg_generic_s        sip_priority_t;
typedef struct msg_auth_s 	    sip_proxy_authenticate_t;
168
typedef struct msg_auth_info_s      sip_proxy_authentication_info_t;
169
typedef struct msg_auth_s     	    sip_proxy_authorization_t;
Pekka Pessi's avatar
Pekka Pessi committed
170 171 172 173 174 175 176 177 178 179 180
typedef msg_list_t	     	    sip_proxy_require_t;
typedef struct sip_rack_s           sip_rack_t;
typedef struct sip_reason_s         sip_reason_t;
typedef struct sip_route_s     	    sip_record_route_t;

typedef struct sip_refer_to_s       sip_refer_to_t;
typedef struct sip_referred_by_s    sip_referred_by_t;
typedef struct sip_replaces_s       sip_replaces_t;

typedef struct sip_request_disposition_s sip_request_disposition_t;

181 182 183
typedef struct sip_caller_prefs_s   sip_caller_prefs_t;
typedef struct sip_caller_prefs_s   sip_accept_contact_t;
typedef struct sip_caller_prefs_s   sip_reject_contact_t;
Pekka Pessi's avatar
Pekka Pessi committed
184 185 186 187 188

typedef msg_list_t	     	    sip_require_t;
typedef struct sip_retry_after_s    sip_retry_after_t;
typedef struct sip_route_s     	    sip_route_t;
typedef struct sip_rseq_s           sip_rseq_t;     
189
typedef struct msg_generic_s        sip_server_t;
Pekka Pessi's avatar
Pekka Pessi committed
190 191
typedef struct sip_session_expires_s
                                    sip_session_expires_t;
192
typedef struct msg_generic_s        sip_subject_t;
Pekka Pessi's avatar
Pekka Pessi committed
193 194 195 196 197 198
typedef struct sip_subscription_state_s
                                    sip_subscription_state_t;
typedef msg_list_t	     	    sip_supported_t;
typedef struct sip_timestamp_s 	    sip_timestamp_t;
typedef struct sip_addr_s           sip_to_t;
typedef msg_list_t	     	    sip_unsupported_t;
199
typedef struct msg_generic_s        sip_user_agent_t;
Pekka Pessi's avatar
Pekka Pessi committed
200 201
typedef struct sip_via_s 	    sip_via_t;
typedef msg_warning_t	            sip_warning_t;
202
typedef struct msg_auth_s 	    sip_www_authenticate_t;
Pekka Pessi's avatar
Pekka Pessi committed
203 204 205 206

typedef struct sip_event_s          sip_event_t;
typedef msg_list_t                  sip_allow_events_t;

207
/* RFC 3323 - @Privacy */
Pekka Pessi's avatar
Pekka Pessi committed
208 209
typedef struct sip_privacy_s sip_privacy_t;

210
/* RFC 3327 - @Path */
Pekka Pessi's avatar
Pekka Pessi committed
211 212 213 214 215 216 217 218 219 220 221 222 223
typedef struct sip_route_s     	    sip_path_t;

/* RFC 3329 - Security Mechanism Agreement */
typedef struct sip_security_agree_s sip_security_client_t;
typedef struct sip_security_agree_s sip_security_server_t;
typedef struct sip_security_agree_s sip_security_verify_t;

/* RFC 3608 - Service Route */
typedef struct sip_route_s     	    sip_service_route_t;


/**SIP message object.
 *
224
 * This structure contains a parsed SIP message. The struct is usually
225 226
 * referred with typedef #sip_t. It is used to access the headers and
 * payload within the SIP message. The generic transport aspects of the
227
 * message, like network address, is accessed using the #msg_t object
Pekka Pessi's avatar
Pekka Pessi committed
228 229 230
 * directly.
 */
struct sip_s {
231 232
  msg_common_t               sip_common[1];     /**< For recursive inclusion */
  msg_pub_t                 *sip_next;          /**< Dummy link to msgfrag */
Pekka Pessi's avatar
Pekka Pessi committed
233
  void                      *sip_user;	        /**< Application data */
234 235
  unsigned                   sip_size;          /**< Size of structure */
  int                        sip_flags;	        /**< Parser flags */
Pekka Pessi's avatar
Pekka Pessi committed
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265

  sip_error_t               *sip_error;	        /**< Erroneous headers */

  /* Pseudoheaders */
  sip_request_t             *sip_request;       /**< Request line  */
  sip_status_t              *sip_status;        /**< Status line */

  /* === Headers start here */
  sip_via_t        	    *sip_via;		/**< Via (v) */
  sip_route_t               *sip_route;		/**< Route */
  sip_record_route_t        *sip_record_route;	/**< Record-Route */
  sip_max_forwards_t        *sip_max_forwards;	/**< Max-Forwards */
  sip_proxy_require_t       *sip_proxy_require;	/**< Proxy-Require */

  sip_from_t       	    *sip_from;		/**< From (f) */
  sip_to_t         	    *sip_to;		/**< To (t) */
  sip_call_id_t             *sip_call_id;	/**< Call-ID (i) */
  sip_cseq_t       	    *sip_cseq;		/**< CSeq */
  sip_contact_t             *sip_contact;	/**< Contact (m) */
  sip_rseq_t                *sip_rseq;          /**< RSeq */
  sip_rack_t                *sip_rack;          /**< RAck */

  /* Caller Preferences */
  sip_request_disposition_t *sip_request_disposition; 
                                                /**< Request-Disposition (d) */
  sip_accept_contact_t      *sip_accept_contact;/**< Accept-Contact (a) */
  sip_reject_contact_t      *sip_reject_contact;/**< Reject-Contact (j) */

  sip_expires_t             *sip_expires;	/**< Expires */
  sip_date_t                *sip_date;		/**< Date */
Pekka Pessi's avatar
Pekka Pessi committed
266
  sip_retry_after_t         *sip_retry_after;	/**< Retry-After */
Pekka Pessi's avatar
Pekka Pessi committed
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
  sip_timestamp_t           *sip_timestamp;	/**< Timestamp */
  sip_min_expires_t         *sip_min_expires;   /**< Min-Expires */

  sip_subject_t    	    *sip_subject;	/**< Subject (s) */
  sip_priority_t            *sip_priority;	/**< Priority */

  sip_call_info_t           *sip_call_info;	/**< Call-Info */
  sip_organization_t        *sip_organization;	/**< Organization */
  sip_server_t              *sip_server;	/**< Server */
  sip_user_agent_t          *sip_user_agent;	/**< User-Agent */
  sip_in_reply_to_t         *sip_in_reply_to;   /**< In-Reply-To */

  sip_accept_t              *sip_accept;	/**< Accept */
  sip_accept_encoding_t     *sip_accept_encoding; /**< Accept-Encoding */
  sip_accept_language_t     *sip_accept_language; /**< Accept-Language */

  sip_allow_t               *sip_allow;		/**< Allow */
  sip_require_t             *sip_require;	/**< Require */
  sip_supported_t           *sip_supported;	/**< Supported (k) */
  sip_unsupported_t         *sip_unsupported;	/**< Unsupported */

  /* RFC 3265 */
  sip_event_t               *sip_event;	        /**< Event (o) */
  sip_allow_events_t        *sip_allow_events;  /**< Allow-Events (u) */
  sip_subscription_state_t  *sip_subscription_state; 
				/**< Subscription-State */

  sip_proxy_authenticate_t  *sip_proxy_authenticate;
				/**< Proxy-Authenticate */
  sip_proxy_authentication_info_t *sip_proxy_authentication_info;
				/**< Proxy-Authentication-Info */
  sip_proxy_authorization_t *sip_proxy_authorization;
				/**< Proxy-Authorization */
  sip_authorization_t       *sip_authorization;       
				/**< Authorization */
  sip_www_authenticate_t    *sip_www_authenticate;
				/**< WWW-Authenticate */
  sip_authentication_info_t *sip_authentication_info;
                                /**< Authentication-Info */
  sip_error_info_t          *sip_error_info;    /**< Error-Info */
  sip_warning_t             *sip_warning;	/**< Warning */

  /* RFC 3515 */
  sip_refer_to_t            *sip_refer_to;      /**< Refer-To (r) */
  sip_referred_by_t         *sip_referred_by;   /**< Referred-By (b) */
  sip_replaces_t            *sip_replaces;      /**< Replaces */

  /* draft-ietf-sip-session-timer */
  sip_session_expires_t     *sip_session_expires;
				/**< Session-Expires (x) */
  sip_min_se_t              *sip_min_se;        /**< Min-SE */

  sip_path_t                *sip_path;        /**< Path */
  sip_service_route_t       *sip_service_route; /**< Service-Route */

  sip_reason_t              *sip_reason;        /**< Reason */

  sip_security_client_t     *sip_security_client; /**< Security-Client */
  sip_security_server_t     *sip_security_server; /**< Security-Server */
  sip_security_verify_t     *sip_security_verify; /**< Security-Verify */

  sip_privacy_t             *sip_privacy; /**< Privacy */

  sip_etag_t                *sip_etag;          /**< SIP-ETag */
  sip_if_match_t            *sip_if_match;      /**< SIP-If-Match */

  /* Entity headers */
  sip_mime_version_t        *sip_mime_version;	/**< MIME-Version */
  sip_content_type_t        *sip_content_type;	/**< Content-Type (c) */
  sip_content_encoding_t    *sip_content_encoding; 
				/**< Content-Encoding (e) */
  sip_content_language_t    *sip_content_language; /**< Content-Language */
  sip_content_disposition_t *sip_content_disposition; 
				/**< Content-Disposition */
  sip_content_length_t      *sip_content_length;/**< Content-Length (l) */

  /* === Headers end here */

  sip_unknown_t             *sip_unknown;       /**< Unknown headers */
  sip_separator_t           *sip_separator;     
				/**< Separator between headers and payload */
  sip_payload_t             *sip_payload;	/**< Message payload */
  msg_multipart_t           *sip_multipart;     /**< Multipart MIME payload */
};


/** @ingroup sip_request
354
 * @brief Structure for @ref sip_request "SIP request line".
Pekka Pessi's avatar
Pekka Pessi committed
355 356 357 358 359 360 361 362 363 364 365 366
 */
struct sip_request_s
{
  sip_common_t     rq_common[1];   /**< Common fragment info */
  sip_error_t     *rq_next;	   /**< Link to next (dummy) */
  sip_method_t     rq_method;	   /**< Method enum */
  char const      *rq_method_name; /**< Method name */
  url_t            rq_url[1];	   /**< RequestURI */
  char const      *rq_version;     /**< Protocol version */
};

/**@ingroup sip_status
367
 * @brief Structure for @ref sip_status "SIP status line".
Pekka Pessi's avatar
Pekka Pessi committed
368 369 370 371 372 373 374 375 376 377 378
 */
struct sip_status_s
{
  sip_common_t   st_common[1];	/**< Common fragment info */
  sip_error_t   *st_next;	/**< Link to next (dummy) */
  char const    *st_version;	/**< Protocol version */
  int            st_status;	/**< Status code */
  char const    *st_phrase;	/**< Status phrase */
};

/**@ingroup sip_from
379
 * @brief Structure for @From and @To headers.
Pekka Pessi's avatar
Pekka Pessi committed
380 381 382 383 384 385 386
 */
struct sip_addr_s
{
  sip_common_t       a_common[1];   /**< Common fragment info */
  sip_error_t       *a_next;
  char const        *a_display;	    /**< Display name */
  url_t              a_url[1];	    /**< URL */
387
  msg_param_t const *a_params;	    /**< Parameter table  */
Pekka Pessi's avatar
Pekka Pessi committed
388 389 390 391 392 393 394 395 396
  char const        *a_comment;	    /**< Comment */
 
  char const        *a_tag;	    /**< Tag parameter */
};

#define a_user a_url->url_user
#define a_host a_url->url_host

/**@ingroup sip_accept
397
 * @brief Structure for @Accept header field.
Pekka Pessi's avatar
Pekka Pessi committed
398 399 400 401
 */
struct sip_accept_s
{
  sip_common_t        ac_common[1]; /**< Common fragment info */
402
  sip_accept_t       *ac_next;	    /**< Pointer to next @Accept value */
Pekka Pessi's avatar
Pekka Pessi committed
403 404
  char const         *ac_type;	    /**< Pointer to type/subtype */
  char const         *ac_subtype;   /**< Points after first slash in type */
405 406
  msg_param_t const  *ac_params;    /**< List of parameters */
  char const         *ac_q;	    /**< Value of q parameter */
Pekka Pessi's avatar
Pekka Pessi committed
407 408
};

409 410 411 412 413 414 415 416 417 418 419 420 421 422
/**@ingroup sip_allow
 * @brief Structure for @Allow header field.
 *
 * @NEW_1_12_5 (before used struct msg_list_s with @Allow).
 */
struct sip_allow_s
{
  msg_common_t       k_common[1];   /**< Common fragment info */
  msg_list_t        *k_next;	    /**< Link to next */
  msg_param_t       *k_items;	    /**< List of allowed items */
  uint32_t           k_bitmap;	    /**< Bitmap of allowed methods. 
				       @NEW_1_12_5 */
};

Pekka Pessi's avatar
Pekka Pessi committed
423
/**@ingroup sip_authentication_info
424
 * @brief Structure for @AuthenticationInfo header.
425 426
 *
 * @deprecated Use struct msg_auth_info_s instead.
Pekka Pessi's avatar
Pekka Pessi committed
427 428 429 430 431
 */
struct sip_authentication_info_s
{
  sip_common_t        ai_common[1]; /**< Common fragment info */
  sip_error_t        *ai_next;	    /**< Dummy link to next */
432
  msg_param_t const  *ai_params;    /**< List of authentication info */
Pekka Pessi's avatar
Pekka Pessi committed
433 434 435
};

/**@ingroup sip_call_id 
436
 * @brief Structure for @CallID (and @InReplyTo) header fields.
Pekka Pessi's avatar
Pekka Pessi committed
437 438 439 440 441
 */
struct sip_call_id_s {		
  sip_common_t   i_common[1];	    /**< Common fragment info */
  sip_call_id_t *i_next;	    /**< Link to next (In-Reply-To) */
  char const    *i_id;		    /**< ID value */
Pekka Pessi's avatar
Pekka Pessi committed
442
  uint32_t       i_hash;	    /**< Hash value (always nonzero) */
Pekka Pessi's avatar
Pekka Pessi committed
443 444 445
};

/**@ingroup sip_call_info
446
 * @brief Structure for @CallInfo header.
Pekka Pessi's avatar
Pekka Pessi committed
447 448 449 450
 */
struct sip_call_info_s
{
  sip_common_t        ci_common[1]; /**< Common fragment info */
451
  sip_call_info_t    *ci_next;	    /**< Link to next @CallInfo */
Pekka Pessi's avatar
Pekka Pessi committed
452
  url_t               ci_url[1];    /**< URI to call info  */
453 454
  msg_param_t const  *ci_params;    /**< List of parameters */
  char const         *ci_purpose;   /**< Value of @b purpose parameter */
Pekka Pessi's avatar
Pekka Pessi committed
455 456 457
};

/**@ingroup sip_cseq
458
 * @brief Structure for @CSeq header.
Pekka Pessi's avatar
Pekka Pessi committed
459 460 461 462 463
 */
struct sip_cseq_s
{
  sip_common_t   cs_common[1];	    /**< Common fragment info */
  sip_error_t   *cs_next;	    /**< Link to next (dummy) */
Pekka Pessi's avatar
Pekka Pessi committed
464
  uint32_t       cs_seq;	    /**< Sequence number */
Pekka Pessi's avatar
Pekka Pessi committed
465 466 467 468 469
  sip_method_t   cs_method;	    /**< Method enum */
  char const    *cs_method_name;    /**< Method name */
};

/**@ingroup sip_contact
470
 * @brief Structure for @Contact header field.
Pekka Pessi's avatar
Pekka Pessi committed
471 472 473 474
 */
struct sip_contact_s
{
  sip_common_t        m_common[1];  /**< Common fragment info */
475
  sip_contact_t      *m_next;	    /**< Link to next @Contact header */
Pekka Pessi's avatar
Pekka Pessi committed
476 477
  char const         *m_display;    /**< Display name */
  url_t               m_url[1];	    /**< SIP URL */
478
  msg_param_t const  *m_params;	    /**< List of contact-params */
Pekka Pessi's avatar
Pekka Pessi committed
479 480
  char const         *m_comment;    /**< Comment */

481
  char const         *m_q;	    /**< @Priority */
482
  char const         *m_expires;    /**< Expiration time */
Pekka Pessi's avatar
Pekka Pessi committed
483 484 485
};

/**@ingroup sip_content_length
486
 * @brief Structure for @ContentLength header.
Pekka Pessi's avatar
Pekka Pessi committed
487 488 489 490 491
 */
struct sip_content_length_s
{
  sip_common_t   l_common[1];	    /**< Common fragment info */
  sip_error_t   *l_next;	    /**< Link to next (dummy) */
492
  uint32_t       l_length;	    /**< Length in bytes */
Pekka Pessi's avatar
Pekka Pessi committed
493 494 495 496 497
};

#if DOCUMENTATION_ONLY
/**@ingroup sip_content_type
 *
498
 * @brief Structure for @ContentType header.
Pekka Pessi's avatar
Pekka Pessi committed
499 500 501 502 503 504 505
 */
struct sip_content_type_s
{
  sip_common_t        c_common[1];  /**< Common fragment info */
  sip_error_t        *c_next;	    /**< Dummy link to next */
  char const         *c_type;	    /**< Pointer to type/subtype */
  char const         *c_subtype;    /**< Points after first slash in type */
506
  msg_param_t const  *c_params;	    /**< List of parameters */
Pekka Pessi's avatar
Pekka Pessi committed
507 508 509 510
};
#endif

/**@ingroup sip_date
511
 * @brief Structure for @Date header.
Pekka Pessi's avatar
Pekka Pessi committed
512 513 514 515 516 517 518 519 520
 */
struct sip_date_s
{
  sip_common_t   d_common[1];	    /**< Common fragment info */
  sip_date_t    *d_next;	    /**< Link to next (dummy) */
  sip_time_t     d_time;	    /**< Seconds since Jan 1, 1900 */
};

/**@ingroup sip_error_info
521
 * @brief Structure for @ErrorInfo header.
Pekka Pessi's avatar
Pekka Pessi committed
522 523 524 525
 */
struct sip_error_info_s
{
  sip_common_t        ei_common[1]; /**< Common fragment info */
526
  sip_call_info_t    *ei_next;	    /**< Link to next @ErrorInfo */
Pekka Pessi's avatar
Pekka Pessi committed
527
  url_t               ei_url[1];    /**< URI to error description */
528
  msg_param_t const  *ei_params;    /**< List of parameters */
Pekka Pessi's avatar
Pekka Pessi committed
529 530 531
};

/**@ingroup sip_event
532
 * @brief Structure for @Event header.
Pekka Pessi's avatar
Pekka Pessi committed
533 534 535
 */
struct sip_event_s 
{
536
  sip_common_t        o_common[1];  /**< Common fragment info */
Pekka Pessi's avatar
Pekka Pessi committed
537
  sip_error_t        *o_next;	    /**< Link to next (dummy) */
538
  char const *        o_type;	    /**< @Event type */
539
  msg_param_t const  *o_params;	    /**< List of parameters */
540
  char const         *o_id;	    /**< @Event ID */
Pekka Pessi's avatar
Pekka Pessi committed
541 542 543
};

/**@ingroup sip_expires
544
 * @brief Structure for @Expires header.
Pekka Pessi's avatar
Pekka Pessi committed
545 546 547 548 549 550 551
 */
struct sip_expires_s
{
  sip_common_t        ex_common[1]; /**< Common fragment info */
  sip_error_t        *ex_next;	    /**< Link to next (dummy) */
  sip_time_t          ex_date;	    /**< Seconds since Jan 1, 1900 */
# define ex_time ex_date
552
  sip_time_t          ex_delta;	    /**< Delta seconds */
Pekka Pessi's avatar
Pekka Pessi committed
553 554 555
};

/**@ingroup sip_max_forwards
556
 * @brief Structure for @MaxForwards header.
Pekka Pessi's avatar
Pekka Pessi committed
557 558 559 560 561 562 563 564 565
 */
struct sip_max_forwards_s
{
  sip_common_t        mf_common[1]; /**< Common fragment info */
  sip_error_t        *mf_next;	    /**< Link to next (dummy) */
  unsigned long       mf_count;	    /**< Forwarding count */
};

/**@ingroup sip_min_expires
566
 * @brief Structure for @MinExpires header.
Pekka Pessi's avatar
Pekka Pessi committed
567 568 569 570 571 572 573 574 575 576 577 578 579
 */
struct sip_min_expires_s
{
  sip_common_t        me_common[1]; /**< Common fragment info */
  sip_error_t        *me_next;	    /**< Link to next (dummy) */
  unsigned long       me_delta;	    /**< Seconds */
};

/**@ingroup sip_rack
 * @brief Structure for @b Rack header.
 */
struct sip_rack_s
{
580 581 582 583 584 585
  sip_common_t        ra_common;        /**< Common fragment info */
  sip_error_t        *ra_next;		/**< Dummy link to next */
  uint32_t            ra_response;	/**< Sequence number of response */
  uint32_t            ra_cseq;		/**< Sequence number of request  */
  sip_method_t        ra_method;	/**< Original request method */
  char const         *ra_method_name;	/**< Original request method name */
Pekka Pessi's avatar
Pekka Pessi committed
586 587 588
};

/**@ingroup sip_refer_to
589
 * @brief Structure for @ReferTo header.
Pekka Pessi's avatar
Pekka Pessi committed
590 591 592 593 594 595 596
 */
struct sip_refer_to_s
{
  sip_common_t        r_common[1];  /**< Common fragment info */
  sip_error_t        *r_next;	    /**< Link to next (dummy) */
  char const         *r_display;
  url_t               r_url[1];	    /**< URI to reference */
597
  msg_param_t const  *r_params;	    /**< List of parameters */
Pekka Pessi's avatar
Pekka Pessi committed
598 599 600
};

/**@ingroup sip_referred_by
601
 * @brief Structure for @ReferredBy header.
Pekka Pessi's avatar
Pekka Pessi committed
602 603 604 605 606 607 608
 */
struct sip_referred_by_s
{
  sip_common_t        b_common[1];  /**< Common fragment info */
  sip_error_t        *b_next;	    /**< Link to next (dummy) */
  char const         *b_display;
  url_t               b_url[1];	    /**< Referrer-URI */
609 610
  msg_param_t const  *b_params;	    /**< List of parameters */
  char const         *b_cid;	    /**< The cid parameter */
Pekka Pessi's avatar
Pekka Pessi committed
611 612 613 614
};


/**@ingroup sip_replaces
615
 * @brief Structure for @Replaces header.
Pekka Pessi's avatar
Pekka Pessi committed
616 617 618 619 620
 */
struct sip_replaces_s
{
  sip_common_t        rp_common[1];   /**< Common fragment info */
  sip_error_t        *rp_next;	      /**< Link to next (dummy) */
621
  char const         *rp_call_id;     /**< @CallID of dialog to replace */
622
  msg_param_t const  *rp_params;      /**< List of parameters */
623 624
  char const         *rp_to_tag;      /**< Value of "to-tag" parameter */
  char const         *rp_from_tag;    /**< Value of "from-tag" parameter */
Pekka Pessi's avatar
Pekka Pessi committed
625 626 627 628 629
  unsigned            rp_early_only;  /**< early-only parameter */
};


/**@ingroup sip_retry_after
630
 * @brief Structure for @RetryAfter header.
Pekka Pessi's avatar
Pekka Pessi committed
631 632 633 634 635
 */
struct sip_retry_after_s {
  sip_common_t        af_common[1]; /**< Common fragment info */
  sip_error_t        *af_next;	    /**< Link to next (dummy) */
  sip_time_t          af_delta;	    /**< Seconds to before retry */
636 637
  char const         *af_comment;   /**< Comment string */
  msg_param_t const  *af_params;    /**< List of parameters */
638
  char const         *af_duration;  /**< Value of "duration" parameter */
Pekka Pessi's avatar
Pekka Pessi committed
639 640 641
};

/**@ingroup sip_request_disposition
642
 * @brief Structure for @RequestDisposition header.
Pekka Pessi's avatar
Pekka Pessi committed
643 644 645 646
 */
struct sip_request_disposition_s
{
  sip_common_t        rd_common[1]; /**< Common fragment info */
647 648
  sip_error_t        *rd_next;	    /**< Link to next (dummy) */
  msg_param_t        *rd_items;     /**< List of directives */
Pekka Pessi's avatar
Pekka Pessi committed
649 650 651
};

/**@ingroup sip_caller_preferences
652
 * @brief Structure for @AcceptContact and @RejectContact header fields.
Pekka Pessi's avatar
Pekka Pessi committed
653 654 655 656 657
 */
struct sip_caller_prefs_s
{
  sip_common_t        cp_common[1];   /**< Common fragment info */
  sip_caller_prefs_t *cp_next;	      /**< Link to next (dummy) */
658 659 660 661
  msg_param_t const  *cp_params;      /**< List of parameters */
  char const         *cp_q;           /**< @Priority */
  unsigned            cp_require :1;  /**< Value of "require" parameter */
  unsigned            cp_explicit :1; /**< Value of "explicit" parameter */
Pekka Pessi's avatar
Pekka Pessi committed
662 663
};

Pekka Pessi's avatar
Pekka Pessi committed
664
/**@ingroup sip_reason
665
 * @brief Structure for @Reason header field.
Pekka Pessi's avatar
Pekka Pessi committed
666 667 668 669 670 671
 */
struct sip_reason_s
{
  sip_common_t        re_common[1]; /**< Common fragment info */
  sip_reason_t       *re_next;	    /**< Link to next */
  char const         *re_protocol;  /**< Protocol */
672
  msg_param_t const  *re_params;    /**< List of reason parameters */
673 674
  char const         *re_cause;	    /**< Value of cause parameter */
  char const         *re_text;	    /**< Value of text parameter */
Pekka Pessi's avatar
Pekka Pessi committed
675 676 677
};

/**@ingroup sip_route
678
 * @brief Structure for @Route and @RecordRoute header fields.
Pekka Pessi's avatar
Pekka Pessi committed
679 680 681 682 683 684
 */
struct sip_route_s
{
  sip_common_t        r_common[1];  /**< Common fragment info */
  sip_route_t        *r_next;	    /**< Link to next */
  char const         *r_display;    /**< Display name */
685
  url_t               r_url[1];	    /**< @Route URL */
686
  msg_param_t const  *r_params;	    /**< List of route parameters */
Pekka Pessi's avatar
Pekka Pessi committed
687 688 689
};

/**@ingroup sip_rseq 
690
 * @brief Structure for @RSeq header.
Pekka Pessi's avatar
Pekka Pessi committed
691 692 693
 */
struct sip_rseq_s
{
694 695 696
  sip_common_t        rs_common[1];	/**< Common fragment info */
  sip_error_t        *rs_next;		/**< Dummy link to next */
  unsigned long       rs_response;	/**< Sequence number of response */
Pekka Pessi's avatar
Pekka Pessi committed
697 698 699
};

/**@ingroup sip_session_expires 
700
 * @brief Structure for @SessionExpires header.
Pekka Pessi's avatar
Pekka Pessi committed
701 702 703
 */
struct sip_session_expires_s
{
704 705 706 707 708 709
  sip_common_t        x_common[1];	/**< Common fragment info */
  sip_error_t        *x_next;		/**< Dummy link to next */
  unsigned long       x_delta;		/**< Delta-seconds */
  msg_param_t const  *x_params;		/**< List of parameters */
  char const         *x_refresher;	/**< Value of "refresher"
					 * parameter: UAS or UAC */
Pekka Pessi's avatar
Pekka Pessi committed
710 711 712
};

/**@ingroup sip_min_se 
713
 * @brief Structure for @MinSE header.
Pekka Pessi's avatar
Pekka Pessi committed
714 715 716
 */
struct sip_min_se_s
{
717 718 719 720
  sip_common_t        min_common[1];	/**< Common fragment info */
  sip_error_t        *min_next;		/**< Dummy link to next */
  unsigned long       min_delta;	/**< Delta-seconds */
  msg_param_t const  *min_params;	/**< List of extension parameters */
Pekka Pessi's avatar
Pekka Pessi committed
721 722 723
};

/**@ingroup sip_subscription_state 
724
 * @brief Structure for @SubscriptionState header.
Pekka Pessi's avatar
Pekka Pessi committed
725 726 727
 */
struct sip_subscription_state_s
{
728 729 730
  sip_common_t        ss_common[1];   /**< Common fragment info */
  sip_error_t        *ss_next;	      /**< Dummy link to next */
  /** Subscription state: "pending", "active" or "terminated" */
731
  char const         *ss_substate; 
732 733 734
  msg_param_t const  *ss_params;      /**< List of parameters */
  char const         *ss_reason;      /**< Reason for termination  */
  char const         *ss_expires;     /**< Subscription lifetime */
735
  char const         *ss_retry_after; /**< Value of retry-after parameter */
Pekka Pessi's avatar
Pekka Pessi committed
736 737 738
};

/**@ingroup sip_timestamp
739
 * @brief Structure for @Timestamp header.
Pekka Pessi's avatar
Pekka Pessi committed
740 741 742 743
 */
struct sip_timestamp_s 
{
  sip_common_t        ts_common[1]; /**< Common fragment info */
744
  sip_error_t        *ts_next;	    /**< Dummy link to next */
Pekka Pessi's avatar
Pekka Pessi committed
745 746 747 748 749
  char const         *ts_stamp;	    /**< Original timestamp */
  char const         *ts_delay;	    /**< Delay at UAS */
};

/**@ingroup sip_via
750
 * @brief Structure for @Via header field.
Pekka Pessi's avatar
Pekka Pessi committed
751 752 753 754
 */
struct sip_via_s
{
  sip_common_t        v_common[1];  /**< Common fragment info */
755
  sip_via_t          *v_next;	    /**< Link to next @Via header */
Pekka Pessi's avatar
Pekka Pessi committed
756 757 758
  char const         *v_protocol;   /**< Application and transport protocol */
  char const         *v_host;	    /**< Hostname */
  char const         *v_port;	    /**< Port number */
759
  msg_param_t const  *v_params;	    /**< List of via-params */
Pekka Pessi's avatar
Pekka Pessi committed
760
  char const         *v_comment;    /**< Comment */
761 762 763 764 765 766
  char const         *v_ttl;	    /**< Value of "ttl" parameter */
  char const         *v_maddr;	    /**< Value of "maddr" parameter */
  char const         *v_received;   /**< Value of "received" parameter*/
  char const         *v_branch;	    /**< Value of "branch" parameter */
  char const         *v_rport;	    /**< Value of "rport" parameter */
  char const         *v_comp;	    /**< Value of "comp" parameter */
Pekka Pessi's avatar
Pekka Pessi committed
767 768 769
};

/**@ingroup sip_security_client
770 771
 * @brief Structure for @SecurityClient, @SecurityServer, and
 * @SecurityVerify headers.
Pekka Pessi's avatar
Pekka Pessi committed
772 773 774
 */
struct sip_security_agree_s
{
775
  sip_common_t        sa_common[1]; /**< Common fragment info */
Pekka Pessi's avatar
Pekka Pessi committed
776 777 778
  struct sip_security_agree_s 
                     *sa_next;	    /**< Link to next mechanism */
  char const         *sa_mec;	    /**< Security mechanism */
779
  msg_param_t const  *sa_params;    /**< List of mechanism parameters */
780 781 782 783
  char const         *sa_q;	    /**< Value of q (preference) parameter */
  char const         *sa_d_alg;	    /**< Value of d-alg parameter */
  char const         *sa_d_qop;	    /**< Value of d-qop parameter */
  char const         *sa_d_ver;	    /**< Value of d-ver parameter */
Pekka Pessi's avatar
Pekka Pessi committed
784 785 786
};

/**@ingroup sip_privacy
787
 * @brief Structure for @Privacy header.
Pekka Pessi's avatar
Pekka Pessi committed
788 789 790 791 792
 */
struct sip_privacy_s
{
  sip_common_t       priv_common[1];/**< Common fragment info */
  sip_error_t       *priv_next;	    /**< Dummy link */
793
  msg_param_t const *priv_values;   /**< @Privacy values */
Pekka Pessi's avatar
Pekka Pessi committed
794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916
};

/* union representing any SIP header
 * these are arrays of size 1 for easy casting
 */
union sip_header_u
{
  sip_common_t               sh_common[1]; 
  struct
  {
    sip_common_t             shn_common;
    sip_header_t            *shn_next;
  }                          sh_header_next[1];
#define sh_next              sh_header_next->shn_next
#define sh_class sh_common->h_class
#define sh_succ  sh_common->h_succ
#define sh_prev  sh_common->h_prev
#define sh_data  sh_common->h_data
#define sh_len   sh_common->h_len

  sip_addr_t                 sh_addr[1];
  sip_auth_t                 sh_auth[1];
  sip_generic_t              sh_generic[1];

  sip_request_t              sh_request[1];
  sip_status_t               sh_status[1];

  sip_error_t                sh_error[1];

  sip_via_t                  sh_via[1];
  sip_route_t                sh_route[1];
  sip_record_route_t         sh_record_route[1];
  sip_max_forwards_t         sh_max_forwards[1];

  sip_from_t                 sh_from[1];
  sip_to_t                   sh_to[1];
  sip_contact_t              sh_contact[1];
  sip_call_id_t              sh_call_id[1];
  sip_cseq_t                 sh_cseq[1];
  sip_rseq_t                 sh_rseq[1];
  sip_rack_t                 sh_rack[1];
                             
  sip_subject_t              sh_subject[1];
  sip_priority_t             sh_priority[1];

  sip_date_t                 sh_date[1];
  sip_retry_after_t          sh_retry_after[1];
  sip_timestamp_t            sh_timestamp[1];
  sip_expires_t              sh_expires[1];
  sip_min_expires_t          sh_min_expires[1];

  sip_call_info_t            sh_call_info[1];
  sip_organization_t         sh_organization[1];
  sip_server_t               sh_server[1];
  sip_user_agent_t           sh_user_agent[1];
  sip_in_reply_to_t          sh_in_reply_to[1];

  sip_accept_t               sh_accept[1];
  sip_accept_encoding_t      sh_accept_encoding[1];
  sip_accept_language_t      sh_accept_language[1];
                             
  sip_allow_t                sh_allow[1];
  sip_require_t              sh_require[1];
  sip_proxy_require_t        sh_proxy_require[1];
  sip_supported_t            sh_supported[1];
  sip_unsupported_t          sh_unsupported[1];

  sip_event_t                sh_event[1];
  sip_allow_events_t         sh_allow_events[1];
  sip_subscription_state_t   sh_subscription_state[1];

  sip_proxy_authenticate_t   sh_proxy_authenticate[1];
  sip_proxy_authentication_info_t sh_proxy_authentication_info[1];
  sip_proxy_authorization_t  sh_proxy_authorization[1]; 
                             
  sip_authorization_t        sh_authorization[1];
  sip_www_authenticate_t     sh_www_authenticate[1];
  sip_authentication_info_t  sh_authentication_info[1];

  sip_error_info_t           sh_error_info[1];
  sip_warning_t              sh_warning[1];

  sip_refer_to_t             sh_refer_to[1];
  sip_referred_by_t          sh_referred_by[1];
  sip_replaces_t             sh_replaces[1];

  /* Caller-Preferences */
  sip_caller_prefs_t         sh_caller_prefs[1];
  sip_request_disposition_t  sh_request_disposition[1];
  sip_accept_contact_t       sh_accept_contact[1];
  sip_reject_contact_t       sh_reject_contact[1];
   
  sip_session_expires_t      sh_session_expires[1];
  sip_min_se_t               sh_min_se[1];

  sip_path_t                 sh_path[1];
  sip_service_route_t        sh_service_route[1];

  sip_reason_t               sh_reason[1];

  sip_security_client_t      sh_security_client[1];
  sip_security_server_t      sh_security_server[1];
  sip_security_verify_t      sh_security_verify[1];

  sip_privacy_t              sh_privacy[1];

  sip_etag_t                 sh_etag[1];
  sip_if_match_t             sh_if_match[1];
    
  /* Entity headers */
  sip_mime_version_t         sh_mime_version[1];
  sip_content_type_t         sh_content_type[1];
  sip_content_encoding_t     sh_content_encoding[1];
  sip_content_language_t     sh_content_language[1];
  sip_content_length_t       sh_content_length[1];
  sip_content_disposition_t  sh_content_disposition[1];

  sip_unknown_t              sh_unknown[1];

  sip_separator_t            sh_separator[1];
  sip_payload_t              sh_payload[1];
};

917 918
SOFIA_END_DECLS

Pekka Pessi's avatar
Pekka Pessi committed
919
#endif /* !defined(SIP_H) */