annotate mtctest/disconnect.c @ 8:a902ccbf6bbc

mtctest: introduce general user command structure
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 09 Jun 2024 02:48:55 +0000
parents e7b192a5dee5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement the sending of MNCC_DISC_REQ,
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * signaling a caller-requested disconnect aka hang-up.
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * It is the graceful way of signaling disconnect,
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * as opposed to simply killing the test call process with ^C
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * and letting themwi-mncc handle the broken socket.
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 */
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <sys/types.h>
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <sys/socket.h>
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <stdio.h>
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <stdint.h>
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <stdlib.h>
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include <string.h>
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include <strings.h>
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #include "../include/mncc.h"
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 #include "../include/gsm48_const.h"
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 int disconnect_mode;
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
8
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
21 void
5
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 send_disconnect_req()
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 struct gsm_mncc msg;
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 printf("Sending disconnect request\n");
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 bzero(&msg, sizeof(struct gsm_mncc));
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 msg.msg_type = MNCC_DISC_REQ;
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 msg.callref = 1;
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 mncc_set_cause(&msg, GSM48_CAUSE_LOC_USER,
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 GSM48_CC_CAUSE_NORM_CALL_CLEAR);
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 send_mncc_to_gsm(&msg, sizeof(struct gsm_mncc));
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 disconnect_mode = 1;
e7b192a5dee5 mtctest: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 }
8
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
35
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
36 void
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
37 disconnect_command()
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
38 {
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
39 if (disconnect_mode) {
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
40 printf("Already in disconnect mode, command ignored\n");
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
41 return;
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
42 }
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
43 send_disconnect_req();
a902ccbf6bbc mtctest: introduce general user command structure
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
44 }