FreeCalypso > hg > sipout-test-utils
diff test-fsk/disc_cmd.c @ 2:26383ed8b79f
test-fsk: starting as a copy of test-voice
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 04 Mar 2024 21:03:19 -0800 |
parents | test-voice/disc_cmd.c@35c0d9f03c0a |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-fsk/disc_cmd.c Mon Mar 04 21:03:19 2024 -0800 @@ -0,0 +1,55 @@ +/* + * In this module we implement user-driven sending of CANCEL and BYE + * disconnection requests. + */ + +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include "../libsip/out_msg.h" + +extern struct sockaddr_in sip_dest_sin; +extern char to_uri[]; +extern int rtp_out_enable; + +send_cancel_req() +{ + struct sip_msg_out msg; + int rc; + + rtp_out_enable = 0; + rc = start_request_out_msg(&msg, "CANCEL", to_uri); + if (rc < 0) { +msg_size_err: fprintf(stderr, "composing CANCEL message: size error\n"); + return(-1); + } + rc = add_req_boilerplate(&msg, "1 CANCEL", 0); + if (rc < 0) + goto msg_size_err; + out_msg_finish(&msg); + sip_tx_packet(&msg, &sip_dest_sin); + return(0); +} + +send_bye_req() +{ + struct sip_msg_out msg; + int rc; + + rtp_out_enable = 0; + rc = start_request_out_msg(&msg, "BYE", to_uri); + if (rc < 0) { +msg_size_err: fprintf(stderr, "composing BYE message: size error\n"); + return(-1); + } + rc = add_req_boilerplate(&msg, "2 BYE", 1); + if (rc < 0) + goto msg_size_err; + out_msg_finish(&msg); + sip_tx_packet(&msg, &sip_dest_sin); + return(0); +}