本文整理汇总了C++中sl_api_t::freply方法的典型用法代码示例。如果您正苦于以下问题:C++ sl_api_t::freply方法的具体用法?C++ sl_api_t::freply怎么用?C++ sl_api_t::freply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sl_api_t
的用法示例。
在下文中一共展示了sl_api_t::freply方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xcaps_send_reply
static int xcaps_send_reply(sip_msg_t *msg, int code, str *reason,
str *hdrs, str *ctype, str *body)
{
str tbuf;
if(hdrs && hdrs->len>0)
{
if (add_lump_rpl(msg, hdrs->s, hdrs->len, LUMP_RPL_HDR) == 0)
{
LM_ERR("failed to insert extra-headers lump\n");
return -1;
}
}
if(ctype && ctype->len>0)
{
/* add content-type */
tbuf.len=sizeof("Content-Type: ") - 1 + ctype->len + CRLF_LEN;
tbuf.s=pkg_malloc(sizeof(char)*(tbuf.len));
if (tbuf.len==0)
{
LM_ERR("out of pkg memory\n");
return -1;
}
memcpy(tbuf.s, "Content-Type: ", sizeof("Content-Type: ") - 1);
memcpy(tbuf.s+sizeof("Content-Type: ") - 1, ctype->s, ctype->len);
memcpy(tbuf.s+sizeof("Content-Type: ") - 1 + ctype->len,
CRLF, CRLF_LEN);
if (add_lump_rpl(msg, tbuf.s, tbuf.len, LUMP_RPL_HDR) == 0)
{
LM_ERR("failed to insert content-type lump\n");
pkg_free(tbuf.s);
return -1;
}
pkg_free(tbuf.s);
}
if(body && body->len>0)
{
if (add_lump_rpl(msg, body->s, body->len, LUMP_RPL_BODY) < 0)
{
LM_ERR("Error while adding reply lump\n");
return -1;
}
}
if (slb.freply(msg, code, reason) < 0)
{
LM_ERR("Error while sending reply\n");
return -1;
}
return 0;
}
示例2: auth_send_reply
static int auth_send_reply(struct sip_msg *msg, int code, char *reason,
char *hdr, int hdr_len)
{
str reason_str;
/* Add new headers if there are any */
if ((hdr!=NULL) && (hdr_len>0)) {
if (add_lump_rpl(msg, hdr, hdr_len, LUMP_RPL_HDR)==0) {
LM_ERR("failed to append hdr to reply\n");
return -1;
}
}
reason_str.s = reason;
reason_str.len = strlen(reason);
return force_stateless_reply ?
slb.sreply(msg, code, &reason_str) :
slb.freply(msg, code, &reason_str);
}
示例3: send_response
/**
* Send a reply (response) to the passed in SIP request messsage with
* the code and reason. If the header is not NULL (and header_len !=
* 0) the add the header to the reply message.
*
* @param request The SIP request message to build the reply from.
* @param code The response code. i.e 200
* @param reason The response reason. i.e. "OK"
* @param header the header block to add to the reply.
* @param header_len The length of the header block. (header)
*
* @return 0 on success, none-zero on an error.
*/
static int send_response(struct sip_msg *request, int code, str *reason,
char *header, int header_len)
{
if (slb.freply != 0) {
/* Add new headers if not null or zero length */
if ((header) && (header_len)) {
if (add_lump_rpl(request, header, header_len, LUMP_RPL_HDR) == 0) {
/* An error with adding the lump */
LM_ERR("unable to append header.\n");
return -1;
}
}
/* Now using the sl function, send the reply/response */
if (slb.freply(request, code, reason) < 0) {
LM_ERR("Unable to sent reply.\n");
return -1;
}
}
else {
return -1;
}
return(0);
}