Pau Espin Pedrol | 4669b61 | 2023-10-23 17:43:14 +0200 | [diff] [blame^] | 1 | module DIAMETER_ts29_273_Templates { |
| 2 | |
| 3 | /* (C) 2023 by sysmocom s.f.m.c. GmbH <info@sysmocom.de |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Released under the terms of GNU General Public License, Version 2 or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 10 | * |
| 11 | * Templates for AVPs and messages for TS 29.273 |
| 12 | */ |
| 13 | |
| 14 | import from General_Types all; |
| 15 | import from DIAMETER_Types all; |
| 16 | import from DIAMETER_Templates all; |
| 17 | import from Osmocom_Types all; |
| 18 | import from Misc_Helpers all; |
| 19 | |
| 20 | /* 3GPP TS 29.273 Section 8.2 */ |
| 21 | const uint32_t c_DIAMETER_3GPP_SWx_AID := 16777265; |
| 22 | /* 3GPP TS 29.273 Section 9 */ |
| 23 | const uint32_t c_DIAMETER_3GPP_S6b_AID := 16777272; |
| 24 | |
| 25 | /******************************* |
| 26 | * SWx 3GPP TS 29.273 section 8 |
| 27 | *******************************/ |
| 28 | |
| 29 | /* SIP-Auth-Data-Item , 3GPP TS 29.273 8.2.3.9 */ |
| 30 | template (present) GenericAVP tr_AVP_3GPP_SIPAuthDataItem(template (present) uint32_t num := ?) := { |
| 31 | avp := { |
| 32 | avp_header := tr_DIA_Hdr_3GPP(c_AVP_Code_CxDx_3GPP_SIP_Auth_Data_Item), |
| 33 | avp_data := { |
| 34 | avp_CxDx_3GPP_SIP_Auth_Data_Item := superset( |
| 35 | //tr_AVP_3GPP_SIPItemNumber(num), /* Optional */ |
| 36 | tr_AVP_3GPP_SIPAuthScheme(?)//, /* Optional */ |
| 37 | //tr_AVP_3GPP_SIPAuthenticate(?), /* Optional */ |
| 38 | //tr_AVP_3GPP_SIPAuthorization(?), /* Optional */ |
| 39 | //tr_AVP_3GPP_SIPAuthContext(?), /* Optional */ |
| 40 | //tr_AVP_3GPP_ConfidentialityKey(?), /* Optional */ |
| 41 | //tr_AVP_3GPP_IntegrityKey(?) /* Optional */ |
| 42 | /* TODO: |
| 43 | [ SIP-Digest-Authenticate ] |
| 44 | [ Framed-IP-Address ] |
| 45 | [ Framed-IPv6-Prefix ] |
| 46 | [ Framed-Interface-Id ] |
| 47 | [ Line-Identifier ] |
| 48 | *[AVP] |
| 49 | */ |
| 50 | ) |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | template (value) GenericAVP ts_AVP_3GPP_SIPAuthDataItem(uint32_t num, OCT16 rand, OCT16 ik, OCT16 ck, OCT16 autn, OCT14 auts) := { |
| 55 | avp := { |
| 56 | avp_header := ts_DIA_Hdr_3GPP(c_AVP_Code_CxDx_3GPP_SIP_Auth_Data_Item), |
| 57 | avp_data := { |
| 58 | avp_CxDx_3GPP_SIP_Auth_Data_Item := { |
| 59 | ts_AVP_3GPP_SIPItemNumber(num), |
| 60 | ts_AVP_3GPP_SIPAuthScheme(char2oct("Digest-AKAv1-MD5")), |
| 61 | ts_AVP_3GPP_SIPAuthenticate(rand & autn), |
| 62 | ts_AVP_3GPP_SIPAuthorization(rand & auts), |
| 63 | ts_AVP_3GPP_SIPAuthContext(char2oct("foobar")), |
| 64 | ts_AVP_3GPP_ConfidentialityKey(ck), |
| 65 | ts_AVP_3GPP_IntegrityKey(ik) |
| 66 | /* TODO: |
| 67 | [ SIP-Digest-Authenticate ] |
| 68 | [ Framed-IP-Address ] |
| 69 | [ Framed-IPv6-Prefix ] |
| 70 | [ Framed-Interface-Id ] |
| 71 | [ Line-Identifier ] |
| 72 | *[AVP] |
| 73 | */ |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | /* Multimedia-Auth-Request, 3GPP TS 29.273 8.2.2.1 Authentication Procedure */ |
| 80 | template (present) PDU_DIAMETER |
| 81 | tr_DIA_SWx_MAR(template (present) hexstring imsi := ?, |
| 82 | template (present) octetstring sess_id := ?, |
| 83 | template (present) charstring orig_host := ?, |
| 84 | template (present) charstring orig_realm := ?, |
| 85 | template (present) charstring dest_realm := ?, |
| 86 | template (present) UINT32 hbh_id := ?, |
| 87 | template (present) UINT32 ete_id := ?) := |
| 88 | tr_DIAMETER(flags := '1???????'B, |
| 89 | cmd_code := Multimedia_Auth, |
| 90 | app_id := int2oct(c_DIAMETER_3GPP_SWx_AID, 4), |
| 91 | hbh_id := hbh_id, ete_id := ete_id, |
| 92 | avps := superset( |
| 93 | tr_AVP_SessionId(sess_id), |
| 94 | tr_AVP_VendorSpecAppId(?, ?), |
| 95 | tr_AVP_AuthSessionState(NO_STATE_MAINTAINED), |
| 96 | tr_AVP_OriginHost(orig_host), |
| 97 | tr_AVP_OriginRealm(orig_realm), |
| 98 | tr_AVP_DestinationRealm(dest_realm), |
| 99 | tr_AVP_UserNameImsi(imsi), |
| 100 | tr_AVP_3GPP_SIPAuthDataItem(?), |
| 101 | tr_AVP_3GPP_SIPNumAuthDataItems(?) |
| 102 | )); |
| 103 | |
| 104 | /* Multimedia-Auth-Answer, 3GPP TS 29.273 8.2.2.1 Authentication Procedure */ |
| 105 | template (value) PDU_DIAMETER |
| 106 | ts_DIA_SWx_MAA(template (value) hexstring imsi, |
| 107 | template (value) GenericAVP sip_auth_data_item, |
| 108 | template (value) uint32_t vendor_app_id := c_DIAMETER_3GPP_SWx_AID, |
| 109 | template (value) octetstring sess_id := c_def_sess_id, |
| 110 | template (value) charstring orig_host := "hss.localdomain", |
| 111 | template (value) charstring orig_realm := "localdomain", |
| 112 | template (value) UINT32 hbh_id := '00000000'O, |
| 113 | template (value) UINT32 ete_id := '00000000'O) := |
| 114 | ts_DIAMETER(flags := '01000000'B, |
| 115 | cmd_code := Multimedia_Auth, |
| 116 | app_id := int2oct(c_DIAMETER_3GPP_SWx_AID, 4), |
| 117 | hbh_id := hbh_id, |
| 118 | ete_id := ete_id, |
| 119 | avps := { |
| 120 | ts_AVP_SessionId(sess_id), |
| 121 | ts_AVP_VendorSpecAppId(vendor_id_3GPP, valueof(vendor_app_id)), |
| 122 | ts_AVP_ResultCode(DIAMETER_SUCCESS), |
| 123 | ts_AVP_AuthSessionState(NO_STATE_MAINTAINED), |
| 124 | ts_AVP_OriginHost(orig_host), |
| 125 | ts_AVP_OriginRealm(orig_realm), |
| 126 | ts_AVP_UserNameImsi(valueof(imsi)), |
| 127 | sip_auth_data_item, |
| 128 | ts_AVP_3GPP_SIPNumAuthDataItems(1) |
| 129 | }); |
| 130 | |
| 131 | /* Server-Assignment-Request, |
| 132 | * 3GPP TS 29.273 8.1.2.2.2 UE/PDN Registration/DeRegistration Notification |
| 133 | * 3GPP TS 29.273 8.2.2.3 Non-3GPP IP Access Registration Procedure */ |
| 134 | template (present) PDU_DIAMETER |
| 135 | tr_DIA_SWx_SAR(template (present) hexstring imsi := ?, |
| 136 | template (present) octetstring sess_id := ?, |
| 137 | template (present) charstring orig_host := ?, |
| 138 | template (present) charstring orig_realm := ?, |
| 139 | template (present) charstring dest_realm := ?, |
| 140 | template (present) UINT32 hbh_id := ?, |
| 141 | template (present) UINT32 ete_id := ?, |
| 142 | template (present) CxDx_3GPP_Server_Assignment_Type server_ass_type := ?, |
| 143 | template (present) charstring service_selection := ?) := |
| 144 | tr_DIAMETER(flags := '1???????'B, |
| 145 | cmd_code := Server_Assignment, |
| 146 | app_id := int2oct(c_DIAMETER_3GPP_SWx_AID, 4), |
| 147 | hbh_id := hbh_id, ete_id := ete_id, |
| 148 | avps := superset( |
| 149 | tr_AVP_SessionId(sess_id), |
| 150 | tr_AVP_VendorSpecAppId(?, ?), |
| 151 | tr_AVP_AuthSessionState(NO_STATE_MAINTAINED), |
| 152 | tr_AVP_OriginHost(orig_host), |
| 153 | tr_AVP_OriginRealm(orig_realm), |
| 154 | tr_AVP_DestinationRealm(dest_realm), |
| 155 | tr_AVP_UserNameImsi(imsi), |
| 156 | tr_AVP_3GPP_ServerAssignmentType(server_ass_type), |
| 157 | tr_AVP_ServiceSelection(service_selection) |
| 158 | )); |
| 159 | |
| 160 | /* Server-Assignment-Answer, |
| 161 | * 3GPP TS 29.273 8.1.2.2.2 UE/PDN Registration/DeRegistration Notification |
| 162 | * 3GPP TS 29.273 8.2.2.3 Non-3GPP IP Access Registration Procedure */ |
| 163 | template (value) PDU_DIAMETER |
| 164 | ts_DIA_SWx_SAA(template (value) hexstring imsi, |
| 165 | template (value) uint32_t vendor_app_id := c_DIAMETER_3GPP_SWx_AID, |
| 166 | template (value) octetstring sess_id := c_def_sess_id, |
| 167 | template (value) charstring orig_host := "hss.localdomain", |
| 168 | template (value) charstring orig_realm := "localdomain", |
| 169 | template (value) UINT32 hbh_id := '00000000'O, |
| 170 | template (value) UINT32 ete_id := '00000000'O) := |
| 171 | ts_DIAMETER(flags := '01000000'B, |
| 172 | cmd_code := Server_Assignment, |
| 173 | app_id := int2oct(c_DIAMETER_3GPP_SWx_AID, 4), |
| 174 | hbh_id := hbh_id, |
| 175 | ete_id := ete_id, |
| 176 | avps := { |
| 177 | ts_AVP_SessionId(sess_id), |
| 178 | ts_AVP_VendorSpecAppId(vendor_id_3GPP, valueof(vendor_app_id)), |
| 179 | ts_AVP_ResultCode(DIAMETER_SUCCESS), |
| 180 | ts_AVP_AuthSessionState(NO_STATE_MAINTAINED), |
| 181 | ts_AVP_OriginHost(orig_host), |
| 182 | ts_AVP_OriginRealm(orig_realm), |
| 183 | ts_AVP_UserNameImsi(valueof(imsi)) |
| 184 | /* TODO: |
| 185 | * [ Non-3GPP-User-Data ] |
| 186 | * [ 3GPP-AAA-Server-Name ] |
| 187 | * [ OC-Supported-Features ] |
| 188 | * [ OC-OLR ] ] |
| 189 | * *[ Load ] |
| 190 | * *[ Supported-Features ] |
| 191 | */ |
| 192 | }); |
| 193 | |
| 194 | /******************************* |
| 195 | * S6b 3GPP TS 29.273 section 9 |
| 196 | *******************************/ |
| 197 | |
| 198 | /* TS 29.273 9.2.2.5.1 AA-Request (AAR) */ |
| 199 | template (value) PDU_DIAMETER |
| 200 | ts_DIA_S6b_AAR(template (value) hexstring imsi, |
| 201 | template (value) octetstring sess_id := c_def_sess_id, |
| 202 | template (value) charstring orig_host := "pgw.localdomain", |
| 203 | template (value) charstring orig_realm := "localdomain", |
| 204 | template (value) charstring dest_realm := "localdomain", |
| 205 | template (value) UINT32 hbh_id := '00000000'O, |
| 206 | template (value) UINT32 ete_id := '00000000'O) := |
| 207 | ts_DIAMETER(flags := '11000000'B, |
| 208 | cmd_code := Authorize_Authenticate, |
| 209 | app_id := int2oct(c_DIAMETER_3GPP_S6b_AID, 4), |
| 210 | hbh_id := hbh_id, |
| 211 | ete_id := ete_id, |
| 212 | avps := { |
| 213 | ts_AVP_SessionId(sess_id), |
| 214 | /* Optional: DRMP, */ |
| 215 | ts_AVP_AuthAppId(int2oct(c_DIAMETER_3GPP_S6b_AID, 4)), |
| 216 | ts_AVP_OriginHost(orig_host), |
| 217 | ts_AVP_OriginRealm(orig_realm), |
| 218 | ts_AVP_DestinationRealm(dest_realm), |
| 219 | ts_AVP_AuthRequestType(AUTHORIZE_ONLY), |
| 220 | ts_AVP_UserNameImsi(valueof(imsi)) |
| 221 | /* TODO: Lots other optional */ |
| 222 | }); |
| 223 | |
| 224 | /* TS 29.273 9.2.2.2.2 AA-Answer (AAA) */ |
| 225 | template (present) PDU_DIAMETER |
| 226 | tr_DIA_S6b_AAA(template (present) octetstring sess_id := ?, |
| 227 | template (present) charstring orig_host := ?, |
| 228 | template (present) charstring orig_realm := ?, |
| 229 | template (present) charstring dest_realm := ?, |
| 230 | template (present) UINT32 hbh_id := ?, |
| 231 | template (present) UINT32 ete_id := ?, |
| 232 | template (present) CxDx_3GPP_Server_Assignment_Type server_ass_type := ?, |
| 233 | template (present) charstring service_selection := ?) := |
| 234 | tr_DIAMETER(flags := '0???????'B, |
| 235 | cmd_code := Authorize_Authenticate, |
| 236 | app_id := int2oct(c_DIAMETER_3GPP_S6b_AID, 4), |
| 237 | hbh_id := hbh_id, ete_id := ete_id, |
| 238 | avps := superset( |
| 239 | tr_AVP_SessionId(sess_id), |
| 240 | /* Optional: DRMP, */ |
| 241 | tr_AVP_AuthAppId(int2oct(c_DIAMETER_3GPP_S6b_AID, 4)), |
| 242 | tr_AVP_AuthRequestType(AUTHORIZE_ONLY), |
| 243 | tr_AVP_ResultCode(DIAMETER_SUCCESS), |
| 244 | tr_AVP_OriginHost(orig_host), |
| 245 | tr_AVP_OriginRealm(orig_realm) |
| 246 | )); |
| 247 | |
| 248 | } |