changeset 120:c62d0f28da6f

sip-manual-out: make Max-Forwards configurable
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 29 Sep 2022 14:13:43 -0800
parents 056616f7e8ab
children 5dc0190a624e
files sip-manual-out/main.c sip-manual-out/uac.c
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sip-manual-out/main.c	Thu Sep 29 14:03:06 2022 -0800
+++ b/sip-manual-out/main.c	Thu Sep 29 14:13:43 2022 -0800
@@ -25,6 +25,7 @@
 struct sockaddr_in sip_dest_sin;
 char from_uri[128], to_uri[128], call_id[128];
 struct timeval cur_event_time;
+unsigned max_forwards = 70;
 
 send_invite_req()
 {
@@ -68,11 +69,14 @@
 	int opt, rc;
 
 	logfile = 0;
-	while ((opt = getopt(argc, argv, "l:")) != EOF) {
+	while ((opt = getopt(argc, argv, "l:m:")) != EOF) {
 		switch (opt) {
 		case 'l':
 			logfile = optarg;
 			continue;
+		case 'm':
+			max_forwards = atoi(optarg);
+			continue;
 		default:
 		usage:
 			fprintf(stderr,
--- a/sip-manual-out/uac.c	Thu Sep 29 14:03:06 2022 -0800
+++ b/sip-manual-out/uac.c	Thu Sep 29 14:13:43 2022 -0800
@@ -22,6 +22,7 @@
 extern struct in_addr sip_bind_ip;
 extern unsigned sip_bind_port;
 extern char call_id[], from_uri[], to_uri[];
+extern unsigned max_forwards;
 
 char to_tag[MAX_TO_TAG+1];
 
@@ -53,7 +54,8 @@
 	rc = out_msg_add_header(msg, "CSeq", cseq);
 	if (rc < 0)
 		return rc;
-	return out_msg_add_header(msg, "Max-Forwards", "70");
+	sprintf(strbuf, "%u", max_forwards);
+	return out_msg_add_header(msg, "Max-Forwards", strbuf);
 }
 
 add_contact_header(msg)