FreeCalypso > hg > themwi-system-sw
view libsip/out_msg.c @ 63:e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 18 Sep 2022 15:01:11 -0800 |
parents | 5427b26525cd |
children | 915f0f397fb6 |
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_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); }