FreeCalypso > hg > themwi-system-sw
annotate sip-manual-out/main.c @ 148:b51247739897
sip-manual-out: attempt to play along with re-INVITEs
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 08 Oct 2022 23:52:08 -0800 |
parents | a36b731bfef9 |
children | 258932879f8b |
rev | line source |
---|---|
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This is the main module for sip-manual-out test program. |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/time.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/socket.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <sys/errno.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <netinet/in.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <arpa/inet.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdio.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <stdlib.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <string.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <strings.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <unistd.h> |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "../libsip/out_msg.h" |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "../libsip/sdp.h" |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 extern int sip_socket; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 extern struct in_addr sip_bind_ip, sip_dest_ip; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 extern unsigned sip_bind_port, sip_dest_port; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 extern char sip_dest_domain[]; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 extern struct sockaddr_in dummy_rtp_endp; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 struct sockaddr_in sip_dest_sin; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 char from_uri[128], to_uri[128], call_id[128]; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 struct timeval cur_event_time; |
120
c62d0f28da6f
sip-manual-out: make Max-Forwards configurable
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
28 unsigned max_forwards = 70; |
121
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
29 int declare_100rel_supp; |
122
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
30 int pcma_codec_pref, pcma_codec_force; |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 send_invite_req() |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 struct sip_msg_out msg; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 struct sdp_gen sdp; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 int rc; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 rc = start_request_out_msg(&msg, "INVITE", to_uri); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 if (rc < 0) { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 msg_size_err: fprintf(stderr, "composing INVITE req: msg size error\n"); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 exit(1); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 } |
123
a36b731bfef9
sip-manual-out: implement sending BYE and CANCEL
Mychaela Falconia <falcon@freecalypso.org>
parents:
122
diff
changeset
|
43 rc = add_req_boilerplate(&msg, "1 INVITE", 0); |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 if (rc < 0) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 goto msg_size_err; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 rc = add_contact_header(&msg); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 if (rc < 0) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 goto msg_size_err; |
121
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
49 if (declare_100rel_supp) { |
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
50 rc = out_msg_add_header(&msg, "Supported", "100rel"); |
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
51 if (rc < 0) |
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
52 goto msg_size_err; |
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
53 } |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 rc = out_msg_add_header(&msg, "Content-Type", "application/sdp"); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 if (rc < 0) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 goto msg_size_err; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 bzero(&sdp, sizeof sdp); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 sdp.conn_ip = dummy_rtp_endp.sin_addr; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 sdp.conn_port = ntohs(dummy_rtp_endp.sin_port); |
122
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
60 if (pcma_codec_force) |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
61 sdp.codec_mask = SDP_CODEC_MASK_PCMA; |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
62 else { |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
63 sdp.codec_mask = SDP_CODEC_MASK_BOTH; |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
64 if (pcma_codec_pref) |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
65 sdp.codec_mask |= SDP_CODEC_MASK_PCMA_PREF; |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
66 } |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 sdp.session_id = sdp.conn_port << 16; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 sdp.owner_ip = sip_bind_ip; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 rc = out_msg_finish_sdp(&msg, &sdp); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 if (rc < 0) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 goto msg_size_err; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 sip_tx_packet(&msg, &sip_dest_sin); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 } |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 |
119
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
75 static void |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
76 preliminary_proc(argc, argv) |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
77 char **argv; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
78 { |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
79 extern int optind; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
80 extern char *optarg; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
81 char *logfile; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
82 int opt, rc; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
83 |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
84 logfile = 0; |
122
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
85 while ((opt = getopt(argc, argv, "aAl:m:r")) != EOF) { |
119
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
86 switch (opt) { |
122
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
87 case 'a': |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
88 pcma_codec_pref = 1; |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
89 continue; |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
90 case 'A': |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
91 pcma_codec_force = 1; |
07e4cc5f824c
sip-manual-out: add options to test PCMA codec
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
92 continue; |
119
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
93 case 'l': |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
94 logfile = optarg; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
95 continue; |
120
c62d0f28da6f
sip-manual-out: make Max-Forwards configurable
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
96 case 'm': |
c62d0f28da6f
sip-manual-out: make Max-Forwards configurable
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
97 max_forwards = atoi(optarg); |
c62d0f28da6f
sip-manual-out: make Max-Forwards configurable
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
98 continue; |
121
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
99 case 'r': |
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
100 declare_100rel_supp = 1; |
5dc0190a624e
sip-manual-out: add -r option for testing 100rel
Mychaela Falconia <falcon@freecalypso.org>
parents:
120
diff
changeset
|
101 continue; |
119
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
102 default: |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
103 usage: |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
104 fprintf(stderr, |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
105 "usage: %s [options] dest-conf from-num to-num\n", |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
106 argv[0]); |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
107 exit(1); |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
108 } |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
109 } |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
110 if (argc != optind + 3) |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
111 goto usage; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
112 read_config_file(argv[optind]); |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
113 open_sip_udp_socket(); |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
114 obtain_dummy_rtp(); |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
115 sip_dest_sin.sin_family = AF_INET; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
116 sip_dest_sin.sin_addr = sip_dest_ip; |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
117 sip_dest_sin.sin_port = htons(sip_dest_port); |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
118 sprintf(from_uri, "<sip:%s@%s>;tag=out%u", argv[optind+1], |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
119 inet_ntoa(sip_bind_ip), ntohs(dummy_rtp_endp.sin_port)); |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
120 sprintf(to_uri, "sip:%s@%s", argv[optind+2], sip_dest_domain); |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
121 if (logfile) { |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
122 rc = open_sip_log_file(logfile); |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
123 if (rc < 0) |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
124 exit(1); /* error msg already printed */ |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
125 } |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
126 } |
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
127 |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 main(argc, argv) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 char **argv; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 fd_set fds; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 int rc; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 |
119
056616f7e8ab
sip-manual-out: convert command line to getopt style
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
134 preliminary_proc(argc, argv); |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 gettimeofday(&cur_event_time, 0); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 sprintf(call_id, "%08u_%u@%s", |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 (unsigned)(cur_event_time.tv_sec % 100000000), |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 ntohs(dummy_rtp_endp.sin_port), inet_ntoa(sip_bind_ip)); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 send_invite_req(); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 /* main select loop */ |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 for (;;) { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 FD_ZERO(&fds); |
123
a36b731bfef9
sip-manual-out: implement sending BYE and CANCEL
Mychaela Falconia <falcon@freecalypso.org>
parents:
122
diff
changeset
|
143 FD_SET(0, &fds); |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 FD_SET(sip_socket, &fds); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 rc = select(sip_socket+1, &fds, 0, 0, 0); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 if (rc < 0) { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 if (errno == EINTR) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 continue; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 perror("select"); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 exit(1); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 } |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 gettimeofday(&cur_event_time, 0); |
123
a36b731bfef9
sip-manual-out: implement sending BYE and CANCEL
Mychaela Falconia <falcon@freecalypso.org>
parents:
122
diff
changeset
|
153 if (FD_ISSET(0, &fds)) |
a36b731bfef9
sip-manual-out: implement sending BYE and CANCEL
Mychaela Falconia <falcon@freecalypso.org>
parents:
122
diff
changeset
|
154 select_stdin(); |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 if (FD_ISSET(sip_socket, &fds)) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 sip_socket_select(); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 } |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 } |