FreeCalypso > hg > themwi-system-sw
view libsip/out_msg.c @ 165:9419fe55824f
themwi-sip-out complete to the point of compiling and linking
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 12 Oct 2022 17:05:45 -0800 |
parents | 915f0f397fb6 |
children |
line wrap: on
line source
/* * Functions for constructing outgoing SIP messages. */ #include <stdio.h> #include <string.h> #include <strings.h> #include "out_msg.h" start_request_out_msg(msg, method, uri) struct sip_msg_out *msg; char *method, *uri; { unsigned len; len = strlen(method) + strlen(uri) + (2 + 7 + 2); if (len + 2 > MAX_SIP_TX_PACKET) return(-1); sprintf(msg->buf, "%s %s SIP/2.0\r\n", method, uri); msg->msg_len = len; return(0); } start_request_out_msg_urilen(msg, method, uri, uri_len) struct sip_msg_out *msg; char *method, *uri; unsigned uri_len; { unsigned len; len = strlen(method) + uri_len + (2 + 7 + 2); if (len + 2 > MAX_SIP_TX_PACKET) return(-1); sprintf(msg->buf, "%s %.*s SIP/2.0\r\n", method, uri_len, uri); msg->msg_len = len; return(0); } start_response_out_msg(msg, status) struct sip_msg_out *msg; char *status; { unsigned len; len = strlen(status) + (8 + 2); if (len + 2 > MAX_SIP_TX_PACKET) return(-1); sprintf(msg->buf, "SIP/2.0 %s\r\n", status); msg->msg_len = len; return(0); } out_msg_add_header(msg, name, value) struct sip_msg_out *msg; char *name, *value; { unsigned len; len = strlen(name) + strlen(value) + 4; if (msg->msg_len + len + 2 > MAX_SIP_TX_PACKET) return(-1); sprintf(msg->buf + msg->msg_len, "%s: %s\r\n", name, value); msg->msg_len += len; return(0); } out_msg_finish(msg) struct sip_msg_out *msg; { msg->buf[msg->msg_len++] = '\r'; msg->buf[msg->msg_len++] = '\n'; return(0); } out_msg_finish_body(msg, body, bodylen) struct sip_msg_out *msg; char *body; unsigned bodylen; { msg->buf[msg->msg_len++] = '\r'; msg->buf[msg->msg_len++] = '\n'; if (msg->msg_len + bodylen > MAX_SIP_TX_PACKET) return(-1); bcopy(body, msg->buf + msg->msg_len, bodylen); msg->msg_len += bodylen; return(0); }