aboutsummaryrefslogtreecommitdiffstats
path: root/src/cnetz/transaction.h
blob: ad770373846eb9e23a10332024fbb5f4439b0b0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
	/* login to the network */
#define	TRANS_EM	(1 << 0)	/* attach request received, sending reply */
	/* roaming to different base station/network */
#define	TRANS_UM	(1 << 1)	/* roaming request received, sending reply */
	/* check if phone is still on */
#define	TRANS_MA	(1 << 2)	/* periodic online check, waiting for time slot to send order */
#define	TRANS_MFT	(1 << 3)	/* periodic online check sent, waiting for reply */
	/* mobile originated call */
#define	TRANS_VWG	(1 << 4)	/* received dialing request, waiting for time slot to send dial order */
#define	TRANS_WAF	(1 << 5)	/* dial order sent, waiting for dialing */
#define	TRANS_WBP	(1 << 6)	/* dialing received, waiting for time slot to acknowledge call */
#define	TRANS_WBN	(1 << 7)	/* dialing received, waiting for time slot to reject call */
#define	TRANS_VAG	(1 << 8)	/* establishment of call sent, switching channel */
	/* mobile terminated call */
#define	TRANS_WSK	(1 << 9)	/* incoming call in queue */
#define	TRANS_VAK	(1 << 10)	/* establishment of call sent, switching channel */
	/* traffic channel */
#define	TRANS_BQ	(1 << 11)	/* accnowledge channel */
#define	TRANS_ZFZ	(1 << 12)	/* hold call and send and receive challenge request */
#define	TRANS_AP	(1 << 13)	/* hold call and send and receive challenge request */
#define	TRANS_VHQ_K	(1 << 14)	/* hold call until speech channel or challenge response is available */
#define	TRANS_VHQ_V	(1 << 15)	/* hold call while in conversation on distributed signalling */
#define	TRANS_RTA	(1 << 16)	/* hold call and make the phone ring */
#define	TRANS_DS	(1 << 17)	/* establish speech connection */
#define	TRANS_AHQ	(1 << 18)	/* establish speech connection after answer */
	/* release */
#define	TRANS_VA	(1 << 19)	/* release call in queue by base station (OgK) */
#define	TRANS_AF	(1 << 20)	/* release connection by base station (SpK) */
#define	TRANS_AT	(1 << 21)	/* release connection by mobile station */
#define	TRANS_ATQ	(1 << 22)	/* acknowledge release of MO call in queue */
	/* queue */
#define	TRANS_MO_QUEUE	(1 << 23)	/* MO queue */
#define	TRANS_MT_QUEUE	(1 << 24)	/* MT queue */
#define	TRANS_MO_DELAY	(1 << 25)	/* delay to be sure the channel is free again */
#define	TRANS_MT_DELAY	(1 << 26)

typedef struct transaction {
	struct transaction	*next;			/* pointer to next node in list */
	cnetz_t			*cnetz;			/* pointer to cnetz instance */
	int			callref;		/* callref for transaction */
	uint8_t			futln_nat;		/* current station ID (3 values) */
	uint8_t			futln_fuvst;
	uint16_t		futln_rest;
	int			futelg_bit;		/* chip card inside phone */
	int			extended;		/* extended frequency capability */
	char			dialing[18];		/* number dialed by the phone */
	int64_t			state;			/* state of transaction */
	int8_t			release_cause;		/* reason for release, (c-netz coding) */
	int			try;			/* counts resending messages */
	int			repeat;			/* counts repeating messages */
	struct timer		timer;			/* for varous timeouts */
	int			mo_call;		/* flags a moile originating call */
	int			mt_call;		/* flags a moile terminating call */
	int			page_failed;		/* failed to get a response from MS */
	double			call_start;		/* when did the call start? (used for metering) */
} transaction_t;

const char *transaction2rufnummer(transaction_t *trans);
transaction_t *create_transaction(cnetz_t *cnetz, uint64_t state, uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest, int futelg_bit, int extended);
void destroy_transaction(transaction_t *trans);
void link_transaction(transaction_t *trans, cnetz_t *cnetz);
void unlink_transaction(transaction_t *trans);
transaction_t *search_transaction(cnetz_t *cnetz, uint64_t state_mask);
transaction_t *search_transaction_number(cnetz_t *cnetz, uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest);
transaction_t *search_transaction_callref(cnetz_t *cnetz, int callref);
void trans_new_state(transaction_t *trans, uint64_t state);
void cnetz_flush_other_transactions(cnetz_t *cnetz, transaction_t *trans);
void transaction_timeout(struct timer *timer);
const char *trans_short_state_name(uint64_t state);