blob: 34a3e581f4d1208473bbb27681bd19f54306475a [file] [log] [blame]
Harald Welte9b455bf2010-03-14 15:45:01 +08001#ifndef _GPRS_NS_H
2#define _GPRS_NS_H
3
Harald Weltecb991632010-04-26 19:18:54 +02004/* GPRS Networks Service (NS) messages on the Gb interface
5 * 3GPP TS 08.16 version 8.0.1 Release 1999 / ETSI TS 101 299 V8.0.1 (2002-05)
6 * 3GPP TS 48.016 version 6.5.0 Release 6 / ETSI TS 148 016 V6.5.0 (2005-11) */
7
Harald Welte9b455bf2010-03-14 15:45:01 +08008struct gprs_ns_hdr {
9 u_int8_t pdu_type;
10 u_int8_t data[0];
11} __attribute__((packed));
12
13/* TS 08.16, Section 10.3.7, Table 14 */
14enum ns_pdu_type {
15 NS_PDUT_UNITDATA = 0x00,
16 NS_PDUT_RESET = 0x02,
17 NS_PDUT_RESET_ACK = 0x03,
18 NS_PDUT_BLOCK = 0x04,
19 NS_PDUT_BLOCK_ACK = 0x05,
20 NS_PDUT_UNBLOCK = 0x06,
21 NS_PDUT_UNBLOCK_ACK = 0x07,
22 NS_PDUT_STATUS = 0x08,
23 NS_PDUT_ALIVE = 0x0a,
24 NS_PDUT_ALIVE_ACK = 0x0b,
Harald Weltecb991632010-04-26 19:18:54 +020025 /* TS 48.016 Section 10.3.7, Table 10.3.7.1 */
26 SNS_PDUT_ACK = 0x0c,
27 SNS_PDUT_ADD = 0x0d,
28 SNS_PDUT_CHANGE_WEIGHT = 0x0e,
29 SNS_PDUT_CONFIG = 0x0f,
30 SNS_PDUT_CONFIG_ACK = 0x10,
31 SNS_PDUT_DELETE = 0x11,
32 SNS_PDUT_SIZE = 0x12,
33 SNS_PDUT_SIZE_ACK = 0x13,
Harald Welte9b455bf2010-03-14 15:45:01 +080034};
35
36/* TS 08.16, Section 10.3, Table 12 */
37enum ns_ctrl_ie {
38 NS_IE_CAUSE = 0x00,
39 NS_IE_VCI = 0x01,
40 NS_IE_PDU = 0x02,
41 NS_IE_BVCI = 0x03,
42 NS_IE_NSEI = 0x04,
Harald Weltecb991632010-04-26 19:18:54 +020043 /* TS 48.016 Section 10.3, Table 10.3.1 */
44 NS_IE_IPv4_LIST = 0x05,
45 NS_IE_IPv6_LIST = 0x06,
46 NS_IE_MAX_NR_NSVC = 0x07,
47 NS_IE_IPv4_EP_NR = 0x08,
48 NS_IE_IPv6_EP_NR = 0x09,
49 NS_IE_RESET_FLAG = 0x0a,
50 NS_IE_IP_ADDR = 0x0b,
Harald Welte9b455bf2010-03-14 15:45:01 +080051};
52
53/* TS 08.16, Section 10.3.2, Table 13 */
54enum ns_cause {
55 NS_CAUSE_TRANSIT_FAIL = 0x00,
56 NS_CAUSE_OM_INTERVENTION = 0x01,
57 NS_CAUSE_EQUIP_FAIL = 0x02,
58 NS_CAUSE_NSVC_BLOCKED = 0x03,
59 NS_CAUSE_NSVC_UNKNOWN = 0x04,
60 NS_CAUSE_BVCI_UNKNOWN = 0x05,
61 NS_CAUSE_SEM_INCORR_PDU = 0x08,
62 NS_CAUSE_PDU_INCOMP_PSTATE = 0x0a,
63 NS_CAUSE_PROTO_ERR_UNSPEC = 0x0b,
64 NS_CAUSE_INVAL_ESSENT_IE = 0x0c,
65 NS_CAUSE_MISSING_ESSENT_IE = 0x0d,
Harald Weltecb991632010-04-26 19:18:54 +020066 /* TS 48.016 Section 10.3.2, Table 10.3.2.1 */
67 NS_CAUSE_INVAL_NR_IPv4_EP = 0x0e,
68 NS_CAUSE_INVAL_NR_IPv6_EP = 0x0f,
69 NS_CAUSE_INVAL_NR_NS_VC = 0x10,
70 NS_CAUSE_INVAL_WEIGH = 0x11,
71 NS_CAUSE_UNKN_IP_EP = 0x12,
72 NS_CAUSE_UNKN_IP_ADDR = 0x13,
73 NS_CAUSE_UNKN_IP_TEST_FAILED = 0x14,
Harald Welte9b455bf2010-03-14 15:45:01 +080074};
75
Harald Weltecb991632010-04-26 19:18:54 +020076struct gprs_nsvc;
77struct gprs_ns_inst;
78
79enum gprs_ns_evt {
80 GPRS_NS_EVT_UNIT_DATA,
Harald Welte9b455bf2010-03-14 15:45:01 +080081};
82
Harald Weltecb991632010-04-26 19:18:54 +020083typedef int gprs_ns_cb_t(enum gprs_ns_evt event, struct gprs_nsvc *nsvc,
84 struct msgb *msg, u_int16_t bvci);
Harald Welte9b455bf2010-03-14 15:45:01 +080085
Harald Weltecb991632010-04-26 19:18:54 +020086/* Create a new NS protocol instance */
87struct gprs_ns_inst *gprs_ns_instantiate(gprs_ns_cb_t *cb);
Harald Welte9b455bf2010-03-14 15:45:01 +080088
Harald Weltecb991632010-04-26 19:18:54 +020089/* Destroy a NS protocol instance */
90void gprs_ns_destroy(struct gprs_ns_inst *nsi);
91
92/* Listen for incoming GPRS packets */
93int nsip_listen(struct gprs_ns_inst *nsi, uint16_t udp_port);
94
95struct sockaddr_in;
96
97/* main entry point, here incoming NS frames enter */
98int gprs_ns_rcvmsg(struct gprs_ns_inst *nsi, struct msgb *msg,
99 struct sockaddr_in *saddr);
100
101/* main function for higher layers (BSSGP) to send NS messages */
Harald Welte44f1c272010-04-30 19:54:29 +0200102int gprs_ns_sendmsg(struct gprs_ns_inst *nsi, struct msgb *msg);
Harald Weltecb991632010-04-26 19:18:54 +0200103
Harald Welte9b455bf2010-03-14 15:45:01 +0800104#endif