Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 1 | #ifndef _GPRS_NS_H |
| 2 | #define _GPRS_NS_H |
| 3 | |
Harald Welte | cb99163 | 2010-04-26 19:18:54 +0200 | [diff] [blame] | 4 | /* 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 Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 8 | struct 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 */ |
| 14 | enum 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 Welte | cb99163 | 2010-04-26 19:18:54 +0200 | [diff] [blame] | 25 | /* 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 Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | /* TS 08.16, Section 10.3, Table 12 */ |
| 37 | enum 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 Welte | cb99163 | 2010-04-26 19:18:54 +0200 | [diff] [blame] | 43 | /* 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 Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | /* TS 08.16, Section 10.3.2, Table 13 */ |
| 54 | enum 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 Welte | cb99163 | 2010-04-26 19:18:54 +0200 | [diff] [blame] | 66 | /* 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 Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 74 | }; |
| 75 | |
Harald Welte | cb99163 | 2010-04-26 19:18:54 +0200 | [diff] [blame] | 76 | struct gprs_nsvc; |
| 77 | struct gprs_ns_inst; |
| 78 | |
| 79 | enum gprs_ns_evt { |
| 80 | GPRS_NS_EVT_UNIT_DATA, |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 81 | }; |
| 82 | |
Harald Welte | cb99163 | 2010-04-26 19:18:54 +0200 | [diff] [blame] | 83 | typedef int gprs_ns_cb_t(enum gprs_ns_evt event, struct gprs_nsvc *nsvc, |
| 84 | struct msgb *msg, u_int16_t bvci); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 85 | |
Harald Welte | cb99163 | 2010-04-26 19:18:54 +0200 | [diff] [blame] | 86 | /* Create a new NS protocol instance */ |
| 87 | struct gprs_ns_inst *gprs_ns_instantiate(gprs_ns_cb_t *cb); |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 88 | |
Harald Welte | cb99163 | 2010-04-26 19:18:54 +0200 | [diff] [blame] | 89 | /* Destroy a NS protocol instance */ |
| 90 | void gprs_ns_destroy(struct gprs_ns_inst *nsi); |
| 91 | |
| 92 | /* Listen for incoming GPRS packets */ |
| 93 | int nsip_listen(struct gprs_ns_inst *nsi, uint16_t udp_port); |
| 94 | |
| 95 | struct sockaddr_in; |
| 96 | |
| 97 | /* main entry point, here incoming NS frames enter */ |
| 98 | int 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 Welte | 44f1c27 | 2010-04-30 19:54:29 +0200 | [diff] [blame^] | 102 | int gprs_ns_sendmsg(struct gprs_ns_inst *nsi, struct msgb *msg); |
Harald Welte | cb99163 | 2010-04-26 19:18:54 +0200 | [diff] [blame] | 103 | |
Harald Welte | 9b455bf | 2010-03-14 15:45:01 +0800 | [diff] [blame] | 104 | #endif |