Logo Search packages:      
Sourcecode: sofia-sip version File versions  Download package

msg_types.h

Go to the documentation of this file.
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
 * This library is free software; you can redistribute it and/or
 * 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
 *
 */

#ifndef MSG_TYPES_H
/** Defined when <sofia-sip/msg_types.h> has been included. */
#define MSG_TYPES_H

/**@file sofia-sip/msg_types.h
 * @brief Types for messages and common headers
 * 
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
 * 
 * @date Created: Thu Jan 23 15:43:17 2003 ppessi
 *
 */

#ifndef SU_TYPES_H
#include <sofia-sip/su_types.h>
#endif

SOFIA_BEGIN_DECLS

/** Message class. */
00045 typedef struct msg_mclass_s       msg_mclass_t;

/** Header class. */
00048 typedef struct msg_hclass_s const msg_hclass_t;

/** Header reference. */
00051 typedef struct msg_href_s         msg_href_t;

/** Message object. */
00054 typedef struct msg_s              msg_t;

#ifndef MSG_TIME_T_DEFINED
#define MSG_TIME_T_DEFINED
/** Time in seconds since epoch (1900-Jan-01 00:00:00). */
00059 typedef unsigned long msg_time_t;
#endif

#ifndef MSG_TIME_MAX
/** Latest time that can be expressed with msg_time_t. @HIDE */
00064 #define MSG_TIME_MAX ((msg_time_t)ULONG_MAX)
#endif

#ifndef MSG_PUB_T
#ifdef MSG_OBJ_T 
#define MSG_PUB_T MSG_OBJ_T
#else
#define MSG_PUB_T struct msg_pub_s
#endif
#endif

/**Public protocol-specific message structure for accessing the message. 
 * 
 * This type can be either #sip_t, #http_t, or #msg_multipart_t, depending
 * on the message. The base structure used by msg module is defined in
 * struct #msg_pub_s.
 */
00081 typedef MSG_PUB_T msg_pub_t;

#ifndef MSG_HDR_T
#define MSG_HDR_T union msg_header_u
#endif
/** Any protocol-specific header object */
00087 typedef MSG_HDR_T msg_header_t;

typedef struct msg_common_s         msg_common_t;

00091 typedef struct msg_separator_s      msg_separator_t;
00092 typedef struct msg_payload_s        msg_payload_t;
00093 typedef struct msg_unknown_s        msg_unknown_t;
00094 typedef struct msg_error_s          msg_error_t;

typedef msg_common_t msg_frg_t;

typedef char const                     *msg_param_t;
typedef struct msg_numeric_s            msg_numeric_t;
typedef struct msg_generic_s            msg_generic_t;
typedef struct msg_list_s               msg_list_t;
typedef struct msg_auth_s               msg_auth_t;

#define MSG_HEADER_N 16377

/** Common part of the header objects (or message fragments). 
 *
 * This structure is also known as #msg_common_t or #sip_common_t.
 */
00110 struct msg_common_s {
00111   msg_header_t       *h_succ; /**< Pointer to succeeding fragment. */
00112   msg_header_t      **h_prev; /**< Pointer to preceeding fragment. */
00113   msg_hclass_t       *h_class;      /**< Header class. */
00114   void const         *h_data; /**< Fragment data */
00115   usize_t             h_len;    /**< Fragment length (including CRLF) */
};


/** Message object, common view */
00120 struct msg_pub_s {
00121   msg_common_t        msg_common[1]; /**< Recursive */
  msg_pub_t          *msg_next;
  void               *msg_user;
  unsigned            msg_size;
  unsigned            msg_flags;
  msg_error_t        *msg_error;
  msg_header_t       *msg_request;
  msg_header_t       *msg_status;
  msg_header_t       *msg_headers[MSG_HEADER_N];
};

#define msg_ident msg_common->h_class

/** Numeric header. 
 *
 * A numeric header has a 32-bit integer as its value.
 */
00138 struct msg_numeric_s {
00139   msg_common_t   x_common[1];     /**< Common fragment info */
00140   msg_numeric_t *x_next;          /**< Link to next header */
00141   unsigned long  x_value;         /**< Numeric header value */
};

/** Generic header. 
 *
 * A generic header does not have any internal structure. Its value is
 * represented as a string.
 */
00149 struct msg_generic_s {
00150   msg_common_t   g_common[1];     /**< Common fragment info */
00151   msg_generic_t *g_next;          /**< Link to next header */
00152   char const    *g_string;        /**< Header value */
};

/** List header. 
 * 
 * A list header consists of comma-separated list of tokens.
 */
00159 struct msg_list_s {
00160   msg_common_t       k_common[1];   /**< Common fragment info */
00161   msg_list_t        *k_next;      /**< Link to next header */
00162   msg_param_t       *k_items;     /**< List of items */
};

/** Authentication header. 
 *
 * An authentication header has authentication scheme name and
 * comma-separated list of parameters as its value.
 */
00170 struct msg_auth_s {
00171   msg_common_t       au_common[1];  /**< Common fragment info */
00172   msg_auth_t        *au_next;     /**< Link to next header */
00173   char const        *au_scheme;         /**< Auth-scheme like Basic or Digest */
00174   msg_param_t const *au_params;         /**< Comma-separated parameters */
};

/** Unknown header. */
00178 struct msg_unknown_s {
00179   msg_common_t    un_common[1];  /**< Common fragment info */
00180   msg_unknown_t  *un_next;     /**< Link to next unknown header */
00181   char const     *un_name;     /**< Header name */
00182   char const     *un_value;    /**< Header field value */
};

/** Erroneus header. */
00186 struct msg_error_s {
00187   msg_common_t    er_common[1];  /**< Common fragment info */
00188   msg_error_t    *er_next;     /**< Link to next header */
00189   char const     *er_name;       /**< Name of bad header (if any). */
};


/** Separator. */
00194 struct msg_separator_s {
00195   msg_common_t    sep_common[1]; /**< Common fragment info */
00196   msg_error_t    *sep_next;    /**< Dummy link to next header */
00197   char            sep_data[4];       /**< NUL-terminated separator */
};

/** Message payload. */
00201 struct msg_payload_s {
00202   msg_common_t    pl_common[1];         /**< Common fragment info */
00203   msg_payload_t  *pl_next;        /**< Next payload chunk */
00204   char           *pl_data;        /**< Data - may contain NUL */
00205   usize_t         pl_len;         /**< Length of message payload */
};

/** Any header. */
00209 union msg_header_u {
00210   msg_common_t    sh_common[1];         /**< Common fragment info */
  struct {
    msg_common_t  shn_common;
    msg_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

  msg_generic_t   sh_generic[1];
  msg_numeric_t   sh_numeric[1];
  msg_list_t      sh_list[1];
  msg_auth_t      sh_auth[1];
  msg_separator_t sh_separator[1];
  msg_payload_t   sh_payload[1];
  msg_unknown_t   sh_unknown[1];
  msg_error_t     sh_error[1];
};

/* ====================================================================== */

/**Define how to handle existing headers 
 * when a new header is added to a message. 
 */
00237 typedef enum {
00238   msg_kind_single,            /**< Only one header is allowed */
00239   msg_kind_append,            /**< New header is appended */
00240   msg_kind_list,        /**< A token list header, 
                         * new header is combined with old one. */
00242   msg_kind_apndlist,          /**< A complex list header. */
00243   msg_kind_prepend            /**< New header is prepended */
} msg_header_kind_t;

struct su_home_s;

typedef issize_t msg_parse_f(struct su_home_s *, msg_header_t *, char *, isize_t);
typedef issize_t msg_print_f(char buf[], isize_t bufsiz, 
                       msg_header_t const *, int flags);
typedef char *msg_dup_f(msg_header_t *dst, msg_header_t const *src, 
                  char *buf, isize_t bufsiz);
typedef isize_t msg_xtra_f(msg_header_t const *h, isize_t offset);

typedef int msg_update_f(msg_common_t *, char const *name, isize_t namelen,
                   char const *value);

/** Factory object for a header. 
 * 
 * The #msg_hclass_t object, "header class", defines how a header is
 * handled. It has parsing and printing functions, functions used to copy
 * header objects, header name and other information used when parsing,
 * printing, removing, adding and replacing headers within a message.
 */
00265 struct msg_hclass_s
{
  /* XXX size of header class missing. Someone has saved bits in wrong place. */
00268   int               hc_hash;  /**< Header name hash or ID */
00269   msg_parse_f      *hc_parse; /**< Parse header. */
00270   msg_print_f      *hc_print; /**< Print header. */
00271   msg_xtra_f       *hc_dxtra; /**< Calculate extra size for dup */
00272   msg_dup_f        *hc_dup_one;     /**< Duplicate one header. */
00273   msg_update_f     *hc_update;      /**< Update parameter(s) */
00274   char const         *hc_name;      /**< Full name. */
00275   short             hc_len;   /**< Length of hc_name. */
00276   char              hc_short[2];/**< Short name, if any. */
00277   unsigned char     hc_size;  /**< Size of header structure. */
00278   unsigned char     hc_params;      /**< Offset of parameter list */
00279   unsigned          hc_kind:3;      /**< Kind of header (#msg_header_kind_t):
                         * single, append, list, apndlist, prepend. */
00281   unsigned          hc_critical:1; /**< True if header is critical */
  unsigned          /*pad*/:0;
};

#define HC_LEN_MAX SHRT_MAX

SOFIA_END_DECLS

#endif /* !defined MSG_TYPES_H */

Generated by  Doxygen 1.6.0   Back to index