osip结构体
/**
* Structure for SIP Message (REQUEST and RESPONSE).
* @struct osip_message
*/
struct osip_message
{
char *sip_version; /**< SIP version (SIP request only) */
osip_uri_t *req_uri; /**< Request-Uri (SIP request only) */
char *sip_method; /**< METHOD (SIP request only) */
int status_code; /**< Status Code (SIP answer only) */
char *reason_phrase; /**< Reason Phrase (SIP answer only) */
#ifndef MINISIZE
osip_list_t accepts; /**< Accept headers */
osip_list_t accept_encodings; /**< Accept-Encoding headers */
osip_list_t accept_languages; /**< Accept-Language headers */
osip_list_t alert_infos; /**< Alert-Info headers */
osip_list_t allows; /**< Allows headers */
osip_list_t authentication_infos;/**< authentication_info headers */
#endif
osip_list_t authorizations; /**< Authorizations headers */
osip_call_id_t *call_id; /**< Call-ID header */
#ifndef MINISIZE
osip_list_t call_infos; /**< Call-Infos header */
#endif
osip_list_t contacts; /**< Contacts headers */
#ifndef MINISIZE
osip_list_t content_encodings; /**< Content-Encodings headers */
#endif
osip_content_length_t *content_length; /**< Content-Length header */
osip_content_type_t *content_type; /**< Content-Type header */
osip_cseq_t *cseq; /**< CSeq header */
#ifndef MINISIZE
osip_list_t error_infos; /**< Error-Info headers */
#endif
osip_from_t *from; /**< From header */
osip_mime_version_t *mime_version;/**< Mime-Version header */
osip_list_t proxy_authenticates; /**< Proxy-Authenticate headers */
#ifndef MINISIZE
osip_list_t proxy_authentication_infos; /**< P-Authentication-Info headers */
#endif
osip_list_t proxy_authorizations;/**< Proxy-authorization headers */
osip_list_t record_routes; /**< Record-Route headers */
osip_list_t routes; /**< Route headers */
osip_to_t *to; /**< To header */
osip_list_t vias; /**< Vias headers */
osip_list_t www_authenticates; /**< WWW-Authenticate headers */
osip_list_t headers; /**< Other headers */
osip_list_t bodies; /**< List of attachements */
/*
1: structure and buffer "message" are identical.
2: buffer "message" is not up to date with the structure info (call osip_message_to_str to update it).
*/
int message_property; /**@internal */
char *message; /**@internal */
size_t message_length; /**@internal */
void *application_data; /**can be used by upper layer*/
};
typedef struct osip_list osip_list_t;
struct osip_list
{
int nb_elt;
__node_t *node;
}
typedef struct __node __node_t;
struct __node
{
void *next; /*next __node_t containing element */
void *element; /*element in current node*/
}
int
osip_message_parse (osip_message_t * sip, const char *buf, size_t length)
{
return _osip_message_parse(sip, buf, length, 0);
}
static int
_osip_message_parse (osip_message_t *sip, const char *buf, size_t length,
int sipfrag)
{
int i;
const char *next_header_index;
char *tmp;
char *beg;
tmp = osip_malloc (length + 2);
if (tmp == NULL)
{
OSIP_TRACE (osip_trace
(__FILE__, __LINE__, OSIP_ERROR, NULL,
"Could not allocate memory. \n"));
return -1;
}
beg = tmp;
memcpy (tmp, buf, length);
tmp[length] = '\0';
osip_util_replace_all_lws (tmp);
//parse request or status line
i = __osip_message_startline_parse (sip, tmp, &next_header_inde);
if (i == -1 && !sipfrag)
{
osip_fee(beg);
return -1;
}
tmp = (char*) next_header_index;
//parse headers
i = msg_headers_parse (sip, tmp, &next_header_index);
if (i == -1)
{
OSIP_TRACE (osip_trace
(__FILE__, __LINE__, OSIP_ERROR, NULL,
"error in msg_header_parse()\n"));
osip_free (beg);
return -1;
}
tmp = (char *) next_header_index;
if (tmp[0] == '\0' || tmp[1] == '\0' || tmp[2] == '\0'}
{
if (sip->content_length == NULL)
osip_message_set_content_length (sip, "0");
osip_free (beg);
return 0;
}
i = msg_osip_body_parse (sip, tmp, &next_header_index, length - (tmp - beg));
osip_free (beg);
if (i == -1)
{
OSIP_TRACE (osip_trace
(__FILE__, __LINE__, OSIP_ERROR, NULL,
"error in msg_osip_body_parse()\n"));
return -1;
}
/* this is mandatory in the osip stack */
if (sip->content_length == NULL)
osip_message_set_content_length (sip, "0");
return 0;
}
osip结构体的更多相关文章
- Go结构体实现类似成员函数机制
Go语言结构体成员能否是函数,从而实现类似类的成员函数的机制呢?答案是肯定的. package main import "fmt" type stru struct { testf ...
- C#基础回顾(二)—页面值传递、重载与重写、类与结构体、装箱与拆箱
一.前言 -孤独的路上有梦想作伴,乘风破浪- 二.页面值传递 (1)C#各页面之间可以进行数据的交换和传递,页面之间可根据获取的数据,进行各自的操作(跳转.计算等操作).为了实现多种方式的数据传递,C ...
- go语言结构体
定义: 是一种聚合的数据类型,是由零个或多个任意类型的值聚合成的实体. 成员: 每个值称为结构体的成员. 示例: 用结构体的经典案例处理公司的员工信息,每个员工信息包含一个唯一的员工编号.员工的名字. ...
- C语言中的结构体
用户自己建立自己的结构体类型 1. 定义和使用结构体变量 (1).结构体的定义 C语言允许用户自己建立由不同类型数据组成的组合型的数据结构,它称为结构体. (2).声明一个结构体类型的一般形式为: ...
- C++_系列自学课程_第_12_课_结构体
#include <iostream> #include <string> using namespace std; struct CDAccount { double bal ...
- java socket传送一个结构体给用C++编写的服务器解析的问题
另一端是Java写客户端程序,两者之间需要通信.c++/c接收和发送的都是结构体,而Java是直接发送的字节流或者byte 数组.解决方法:c++/c socket 在发送结构体的时候其实发送的也是字 ...
- swift学习笔记3——类、结构体、枚举
之前学习swift时的个人笔记,根据github:the-swift-programming-language-in-chinese学习.总结,将重要的内容提取,加以理解后整理为学习笔记,方便以后查询 ...
- HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- C语言结构体对齐
1.结构体变量中的元素如何访问? (1)数组中元素的访问方式:表面上有2种方式(数组下标方式和指针方式):实质上都是指针方式访问.(2)结构体变量中的元素访问方式:只有一种,用.或者->的方式来 ...
随机推荐
- 转!mysql 查询 distinct多个字段 注意!!
前几天做项目时,mysql写了个sql, distinct id,col1,col2,... 结果出来了多条同个ID的记录,百度了下..... 下面先来看看例子: table id name ...
- python核心编程第六章练习6-12
6-12.字符串.(a)创建一个名字为findchr()的函数,函数声明如下.def findchr(string, char)findchr()要在字符串string中查找字符char,找到就返回该 ...
- linux笔记:文件系统管理-分区、文件系统以及文件系统常用命令
linux分区类型: linux文件系统: df(查看文件系统容量和占用): du(统计文件或目录大小): 查询和自动挂载: 挂载命令格式: 挂载光盘: 卸载光盘: 挂载U盘:
- Mybatis 批量insert
@Override public int insertHouseTypeScene(int htid, String name, String icon,int sort, List<House ...
- 0518 Scrum 项目 5.0
燃尽图: Sprint 1看板: 成员 团队贡献分 许佳仪 22 柯晓君 21 卓宇靖 18 赖文亮 19
- checkbox --jquery
<input type="checkbox" value="2" class="ace ace-checkbox-2" id='ass ...
- Android 图片圆角的设置
ImageView的scaleType的属性有好几种,分别是matrix(默认).center.centerCrop.centerInside.fitCenter.fitEnd.fitStart.fi ...
- Intellij快捷键
- iOS开发UI篇—无限轮播(功能完善)
iOS开发UI篇—无限轮播(功能完善) 一.自动滚动 添加并设置一个定时器,每个2.0秒,就跳转到下一条. 获取当前正在展示的位置. [self addNSTimer]; } -(void)addNS ...
- LeetCode 175 Combine Two Tables mysql,left join 难度:0
https://leetcode.com/problems/combine-two-tables/ Combine Two Tables Table: Person +-------------+-- ...