anjana_sreekumar@infosys.com | 991c206 | 2020-01-08 11:42:57 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd. |
| 3 | * Copyright (c) 2017 Intel Corporation |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | |
| 19 | #ifndef __GTPV2C_IE_H_ |
| 20 | #define __GTPV2C_IE_H_ |
| 21 | |
| 22 | |
| 23 | #include <inttypes.h> |
| 24 | #include <stdlib.h> |
| 25 | #include <netinet/in.h> |
| 26 | |
| 27 | #define IPV4_IE_LENGTH 4 |
| 28 | #define IPV6_IE_LENGTH 16 |
| 29 | |
| 30 | /* TODO: Check size */ |
| 31 | #define GTPV2C_MAX_LEN 4096 |
| 32 | |
| 33 | #define AMBR_UPLINK 100000000 |
| 34 | #define AMBR_DOWNLINK 50000000 |
| 35 | |
| 36 | #define MBR_UPLINK 245018193L//245018193976L |
| 37 | #define MBR_DOWNLINK 245018193L//245018193976L |
| 38 | |
| 39 | enum gtpv2c_ie_type { |
| 40 | IE_RESERVED = 0, |
| 41 | IE_IMSI = 1, |
| 42 | IE_APN = 71, |
| 43 | IE_AMBR = 72, |
| 44 | IE_EBI = 73, |
| 45 | IE_INDICATION = 77, |
| 46 | IE_MSISDN = 76, |
| 47 | IE_PAA = 79, |
| 48 | IE_BEARER_QOS = 80, |
| 49 | IE_RAT_TYPE = 82, |
| 50 | IE_SERVING_NETWORK = 83, |
| 51 | IE_ULI = 86, |
| 52 | IE_FTEID = 87, |
| 53 | IE_BEARER_CONTEXT = 93, |
| 54 | IE_PDN_TYPE = 99, |
| 55 | IE_APN_RESTRICTION = 127, |
| 56 | IE_SELECTION_MODE = 128, |
| 57 | }; |
| 58 | |
| 59 | enum cause_value { |
| 60 | GTPV2C_CAUSE_REQUEST_ACCEPTED = 16, |
| 61 | GTPV2C_CAUSE_REQUEST_ACCEPTED_PARTIALLY = 17, |
| 62 | GTPV2C_CAUSE_NEW_PDN_TYPE_NETWORK_PREFERENCE = 18, |
| 63 | GTPV2C_CAUSE_NEW_PDN_TYPE_SINGLE_ADDR_BEARER = 19, |
| 64 | GTPV2C_CAUSE_CONTEXT_NOT_FOUND = 64, |
| 65 | GTPV2C_CAUSE_INVALID_MESSAGE_FORMAT = 65, |
| 66 | GTPV2C_CAUSE_INVALID_LENGTH = 67, |
| 67 | GTPV2C_CAUSE_SERVICE_NOT_SUPPORTED = 68, |
| 68 | GTPV2C_CAUSE_MANDATORY_IE_INCORRECT = 69, |
| 69 | GTPV2C_CAUSE_MANDATORY_IE_MISSING = 70, |
| 70 | GTPV2C_CAUSE_SYSTEM_FAILURE = 72, |
| 71 | GTPV2C_CAUSE_NO_RESOURCES_AVAILABLE = 73, |
| 72 | GTPV2C_CAUSE_MISSING_UNKNOWN_APN = 78, |
| 73 | GTPV2C_CAUSE_PREFERRED_PDN_TYPE_UNSUPPORTED = 83, |
| 74 | GTPV2C_CAUSE_ALL_DYNAMIC_ADDRESSES_OCCUPIED = 84, |
| 75 | GTPV2C_CAUSE_REQUEST_REJECTED = 94, |
| 76 | GTPV2C_CAUSE_REMOTE_PEER_NOT_RESPONDING = 100, |
| 77 | GTPV2C_CAUSE_CONDITIONAL_IE_MISSING = 103, |
| 78 | }; |
| 79 | |
| 80 | #define PDN_IP_TYPE_IPV4 1 |
| 81 | #define PDN_IP_TYPE_IPV6 2 |
| 82 | #define PDN_IP_TYPE_IPV4V6 3 |
| 83 | |
| 84 | |
| 85 | enum gtpv2c_ie_instance { |
| 86 | INSTANCE_ZERO = 0, |
| 87 | INSTANCE_ONE = 1, |
| 88 | INSTANCE_TWO = 2, |
| 89 | }; |
| 90 | |
| 91 | #pragma pack(1) |
| 92 | |
| 93 | |
| 94 | typedef struct gtpv2c_ie_t { |
| 95 | uint8_t type; |
| 96 | uint16_t length; |
| 97 | uint8_t instance; |
| 98 | uint8_t value[GTPV2C_MAX_LEN]; |
| 99 | } gtpv2c_ie; |
| 100 | |
| 101 | |
| 102 | typedef struct fteid_ie_t { |
| 103 | uint8_t iface_type :6; |
| 104 | uint8_t ipv6 :1; |
| 105 | uint8_t ipv4 :1; |
| 106 | uint32_t teid; |
| 107 | union ip_t { |
| 108 | uint32_t ipv4; |
| 109 | uint8_t ipv6[INET6_ADDRSTRLEN]; |
| 110 | struct ipv4v6_t_x { |
| 111 | uint32_t ipv4; |
| 112 | uint8_t ipv6[INET6_ADDRSTRLEN]; |
| 113 | } ipv4v6; |
| 114 | } ipaddr; |
| 115 | } fteid_ie; |
| 116 | |
| 117 | |
| 118 | #pragma pack() |
| 119 | |
| 120 | #endif /* __GTPV2C_IE_H_ */ |