File: mtp3.h

package info (click to toggle)
libss7 2.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 708 kB
  • sloc: ansic: 9,561; makefile: 163; sh: 62
file content (215 lines) | stat: -rw-r--r-- 5,366 bytes parent folder | download | duplicates (2)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*
 * libss7: An implementation of Signalling System 7
 *
 * Written by Matthew Fredrickson <creslin@digium.com>
 *
 * scheduling routines taken from libpri by Mark Spencer <markster@digium.com>
 *
 * Copyright (C) 2006-2008, Digium, Inc
 * All Rights Reserved.
 */

/*
 * See http://www.asterisk.org for more information about
 * the Asterisk project. Please do not directly contact
 * any of the maintainers of this project for assistance;
 * the project provides a web site, mailing lists and IRC
 * channels for your use.
 *
 * This program is free software, distributed under the terms of
 * the GNU General Public License Version 2 as published by the
 * Free Software Foundation. See the LICENSE file included with
 * this program for more details.
 *
 * In addition, when this program is distributed with Asterisk in
 * any form that would qualify as a 'combined work' or as a
 * 'derivative work' (but not mere aggregation), you can redistribute
 * and/or modify the combination under the terms of the license
 * provided with that copy of Asterisk, instead of the license
 * terms granted here.
 */

#ifndef _MTP3_H
#define _MTP3_H

#include "ss7_internal.h"

/* Service Indicator bits for Service Information Octet */
/* Bits 4-1 */
#define SIG_NET_MNG		0x00
#define SIG_STD_TEST	0x01
#define SIG_SPEC_TEST	0x02
#define SIG_SCCP		0x03
#define SIG_ISUP		0x05
/* Bits 6-5 -- ANSI networks only */
#define PRIORITY_0		0x00
#define PRIORITY_1		0x01
#define PRIORITY_2		0x02
#define PRIORITY_3		0x03

#define SIO_SIZE	1

#define MTP2_LINKSTATE_DOWN		0
#define MTP2_LINKSTATE_INALARM	1
#define MTP2_LINKSTATE_ALIGNING	2
#define MTP2_LINKSTATE_UP		3

#define MTP3_DOWN		0
#define MTP3_UP			1

#define GOT		(1 << 0)
#define SENT	(1 << 1)

/* Prohibited, restricted states */
#define TFP				1
#define TFA				2
#define TFR_NON_ACTIVE	3
#define TFR_ACTIVE		4

/* Net mngs		  h0     h1 */
#define NET_MNG_COO	(0x01 | 0x10)
#define NET_MNG_COA	(0x01 | 0x20)
#define NET_MNG_CBD	(0x01 | 0x50)
#define NET_MNG_CBA	(0x01 | 0x60)

#define NET_MNG_ECO	(0x02 | 0x10)
#define NET_MNG_ECA	(0x02 | 0x20)

#define NET_MNG_RCT	(0x03 | 0x10)
#define NET_MNG_TFC	(0x03 | 0x20)

#define NET_MNG_TFP	(0x04 | 0x10)
#define NET_MNG_TFR	(0x04 | 0x30)
#define NET_MNG_TFA	(0x04 | 0x50)

#define NET_MNG_RST	(0x05 | 0x10)
#define NET_MNG_RSR	(0x05 | 0x20)

#define NET_MNG_LIN	(0x06 | 0x10)
#define NET_MNG_LUN	(0x06 | 0x20)
#define NET_MNG_LIA	(0x06 | 0x30)
#define NET_MNG_LUA	(0x06 | 0x40)
#define NET_MNG_LID	(0x06 | 0x50)
#define NET_MNG_LFU	(0x06 | 0x60)
#define NET_MNG_LLT	(0x06 | 0x70)
#define NET_MNG_LRT	(0x06 | 0x80)

#define NET_MNG_TRA	(0x07 | 0x10)

#define NET_MNG_DLC	(0x08 | 0x10)
#define NET_MNG_CSS	(0x08 | 0x20)
#define NET_MNG_CNS	(0x08 | 0x30)
#define NET_MNG_CNP	(0x08 | 0x40)

#define NET_MNG_UPU	(0x0a | 0x10)

 /* INHIBIT states */
#define INHIBITED_REMOTELY	(1 << 0)
#define INHIBITED_LOCALLY	(1 << 1)

/* Got, Sent netmsgs */
#define SENT_LUN	(1 << 0)
#define SENT_LIN	(1 << 1)
#define SENT_COO	(1 << 2)
#define SENT_ECO	(1 << 3)
#define SENT_CBD	(1 << 4)
#define SENT_LFU	(1 << 5)

/* Chaneover states */
#define NO_CHANGEOVER			0
#define CHANGEOVER_INITIATED	1
#define CHANGEOVER_IN_PROGRESS	2
#define CHANGEOVER_COMPLETED	3
#define CHANGEBACK_INITIATED	4
#define CHANGEBACK				5

/* MTP3 timers */
#define MTP3_TIMER_T1	1
#define MTP3_TIMER_T2	2
#define MTP3_TIMER_T3	3
#define MTP3_TIMER_T4	4
#define MTP3_TIMER_T5	5
#define MTP3_TIMER_T6	6
#define MTP3_TIMER_T7	7
#define MTP3_TIMER_T8	8
#define MTP3_TIMER_T10	9
#define MTP3_TIMER_T12	10
#define MTP3_TIMER_T13	11
#define MTP3_TIMER_T14	12
#define MTP3_TIMER_T19	13
#define MTP3_TIMER_T21	14
#define MTP3_TIMER_T22	15
#define MTP3_TIMER_T23	16

#define MTP3_TIMER_Q707_T1	17
#define MTP3_TIMER_Q707_T2	18

#define AUTORL(rl, link)		\
	struct routing_label rl;	\
	rl.sls = link->net_mng_sls;	\
	rl.dpc = link->dpc;			\
	rl.opc = link->master->pc


struct net_mng_message {
	int h0;
	int h1;
	char *name;
};

struct mtp3_route {
	int state;
	unsigned int dpc;
	int t6;
	int t10;
	struct ss7_msg *q;
	struct adjacent_sp *owner;
	struct mtp3_route *next;
};

struct adjacent_sp {
	int state;
	unsigned int adjpc;
	struct mtp2 *links[SS7_MAX_LINKS];
	unsigned int numlinks;
	int timer_t19;
	int timer_t21;
	unsigned int tra;
	struct ss7 *master;
	struct mtp3_route *routes;
};

int net_mng_send(struct mtp2 *link, unsigned char h0h1, struct routing_label rl, unsigned int param);

/* Process any MTP2 events that occur */
ss7_event* mtp3_process_event(struct ss7 *ss7, ss7_event *e);

/* The main receive function for MTP3 */
int mtp3_receive(struct ss7 *ss7, struct mtp2 *link, void *msg, int len);

int mtp3_dump(struct ss7 *ss7, struct mtp2 *link, void *msg, int len);

/* Transmit */
int mtp3_transmit(struct ss7 *ss7, unsigned char userpart, struct routing_label rl, int priority, struct ss7_msg *m, struct mtp2 *link);

void mtp3_alarm(struct ss7 *ss7, int fd);

void mtp3_noalarm(struct ss7 *ss7, int fd);

void mtp3_start(struct ss7 *ss7);

unsigned char ansi_sls_next(struct ss7 *ss7);

int set_routinglabel(unsigned char *sif, struct routing_label *rl);

unsigned char sls_next(struct ss7 *ss7);

char * mtp3_timer2str(int mtp3_timer);

void mtp3_add_adj_sp(struct mtp2 *link);

void mtp3_free_co(struct mtp2 *link);

void mtp3_destroy_all_routes(struct adjacent_sp *adj_sp);

#endif /* _MTP3_H */