⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sip_feature.c

📁 Sofia SIP is an open-source SIP User-Agent library, compliant with the IETF RFC3261 specification.
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * 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 * *//**@CFILE sip_feature.c  * * @brief Feature-related SIP header handling * * @author Pekka Pessi <Pekka.Pessi@nokia.com>. * * @date Created: Tue Jun 13 02:57:51 2000 ppessi */#include "config.h"/* Avoid casting sip_t to msg_pub_t and sip_header_t to msg_header_t */#define MSG_PUB_T       struct sip_s#define MSG_HDR_T       union sip_header_u#include "sofia-sip/sip_parser.h"#include <stdio.h>#include <stddef.h>#include <stdlib.h>#include <string.h>#include <assert.h>/* ====================================================================== *//**@SIP_HEADER sip_allow Allow Header * * The Allow header lists the set of methods supported by the user agent * generating the message.  Its syntax is defined in @RFC3261 as * follows: *  * @code *    Allow  =  "Allow" HCOLON [Method *(COMMA Method)] * @endcode * * The parsed Allow header is stored in #sip_allow_t structure. * * Note that SIP methods are case-sensitive: "INVITE" method is different from * "Invite". * * @sa msg_header_find_item(), msg_header_replace_item(), * msg_header_remove_item() *//**@ingroup sip_allow * @typedef struct msg_list_s sip_allow_t;  * * The structure #sip_allow_t contains representation of an @Allow header. * * The #sip_allow_t is defined as follows: * @code * typedef struct msg_allow_s * { *   msg_common_t       k_common[1];  // Common fragment info *   msg_list_t        *k_next;	      // Link to next header *   msg_param_t       *k_items;      // List of items *   uint32_t           k_bitmap;     // Bitmap of allowed methods * } sip_allow_t; * @endcode * * @note The field @a k_bitmap was added in @VERSION_1_12_5. */#define sip_allow_dup_xtra msg_list_dup_xtra#define sip_allow_dup_one  msg_list_dup_onestatic msg_update_f sip_allow_update;msg_hclass_t sip_allow_class[] = SIP_HEADER_CLASS(allow, "Allow", "", k_items, list, allow);issize_t sip_allow_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  sip_allow_t *k = (sip_allow_t *)h;  issize_t retval = msg_commalist_d(home, &s, &k->k_items, msg_token_scan);  msg_header_update_params(k->k_common, 0);  return retval;}issize_t sip_allow_e(char b[], isize_t bsiz, sip_header_t const *h, int f){  assert(sip_is_allow(h));  return msg_list_e(b, bsiz, h, f);}static int sip_allow_update(msg_common_t *h, 			  char const *name, isize_t namelen,			  char const *value){  sip_allow_t *k = (sip_allow_t *)h;  if (name == NULL) {    k->k_bitmap = 0;  }  else {    sip_method_t method = sip_method_code(name);    if (method >= 0 && method < 32)       k->k_bitmap |= 1 << method;  }  return 0;}/** Return true if the method is listed in @Allow header. */int sip_is_allowed(sip_allow_t const *allow,		   sip_method_t method,		   char const *name){  if (method < sip_method_unknown || !allow)    return 0;  if (sip_method_unknown < method && method < 32)    /* Well-known method */    return (allow->k_bitmap & (1 << method)) != 0;  if (method == sip_method_unknown &&      (allow->k_bitmap & (1 << sip_method_unknown)) == 0)    return 0;  return msg_header_find_item(allow->k_common, name) != NULL;}/* ====================================================================== *//**@SIP_HEADER sip_proxy_require Proxy-Require Header * * The Proxy-Require header is used to indicate proxy-sensitive features * that @b MUST be supported by the proxy.  Its syntax is defined in @RFC3261 * as follows: *  * @code *    Proxy-Require  =  "Proxy-Require" HCOLON option-tag *(COMMA option-tag) * @endcode * * * The parsed Proxy-Require header is stored in #sip_proxy_require_t structure. *//**@ingroup sip_proxy_require * @typedef struct msg_list_s sip_proxy_require_t;  * * The structure #sip_proxy_require_t contains representation of an  * @ProxyRequire header. * * The #sip_proxy_require_t is defined as follows: * @code * typedef struct msg_list_s * { *   msg_common_t       k_common[1];  // Common fragment info *   msg_list_t        *k_next;	      // Dummy link *   msg_param_t       *k_items;      // List of items * } sip_proxy_require_t; * @endcode */msg_hclass_t sip_proxy_require_class[] = SIP_HEADER_CLASS_LIST(proxy_require, "Proxy-Require", "", list);issize_t sip_proxy_require_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  sip_proxy_require_t *k = (sip_proxy_require_t *)h;  return msg_commalist_d(home, &s, &k->k_items, msg_token_scan);}issize_t sip_proxy_require_e(char b[], isize_t bsiz, sip_header_t const *h, int f){  assert(sip_is_proxy_require(h));  return msg_list_e(b, bsiz, h, f);}/* ====================================================================== *//**@SIP_HEADER sip_require Require Header * * The Require header is used by clients to tell user agent servers about * options that the client expects the server to support in order to * properly process the request.  Its syntax is defined in @RFC3261  * as follows: *  * @code *    Require       =  "Require" HCOLON option-tag *(COMMA option-tag) * @endcode * * The parsed Require header is stored in #sip_require_t structure. *//**@ingroup sip_require * @typedef struct msg_list_s sip_require_t;  * * The structure #sip_require_t contains representation of an  * @Require header. * * The #sip_require_t is defined as follows: * @code * typedef struct msg_list_s * { *   msg_common_t       k_common[1];  // Common fragment info *   msg_list_t        *k_next;	      // Link to next header *   msg_param_t       *k_items;      // List of items * } sip_require_t; * @endcode */msg_hclass_t sip_require_class[] = SIP_HEADER_CLASS_LIST(require, "Require", "", list);issize_t sip_require_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  sip_require_t *k = (sip_require_t *)h;  return msg_commalist_d(home, &s, &k->k_items, msg_token_scan);}issize_t sip_require_e(char b[], isize_t bsiz, sip_header_t const *h, int f){  assert(sip_is_require(h));  return msg_list_e(b, bsiz, h, f);}/* ====================================================================== *//**@SIP_HEADER sip_supported Supported Header * * The Supported header enumerates all the capabilities of the client or * server.  Its syntax is defined in @RFC3261 as follows: *  * @code *    Supported  =  ( "Supported" / "k" ) HCOLON *                  [option-tag *(COMMA option-tag)] * @endcode * * The parsed option-tags of Supported header * are stored in #sip_supported_t structure. *//**@ingroup sip_supported * @typedef struct msg_list_s sip_supported_t;  * * The structure #sip_supported_t contains representation of an  * @Supported header. * * The #sip_supported_t is defined as follows: * @code * typedef struct msg_list_s * { *   msg_common_t       k_common[1];  // Common fragment info *   msg_list_t        *k_next;	      // Link to next header *   msg_param_t       *k_items;      // List of items * } sip_supported_t; * @endcode */msg_hclass_t sip_supported_class[] = SIP_HEADER_CLASS_LIST(supported, "Supported", "k", list);issize_t sip_supported_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  sip_supported_t *k = (sip_supported_t *)h;  return msg_commalist_d(home, &s, &k->k_items, msg_token_scan);}issize_t sip_supported_e(char b[], isize_t bsiz, sip_header_t const *h, int f){  assert(sip_is_supported(h));  return msg_list_e(b, bsiz, h, f);}/* ====================================================================== *//**@SIP_HEADER sip_unsupported Unsupported Header * * The Unsupported header lists the features not supported by the server. * Its syntax is defined in @RFC3261 as follows: * 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -