1/* 2 * Copyright (C) 2025-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { Callback } from './@ohos.base'; 17/** 18 * Provides interfaces to manage ethernet. 19 * @namespace eap 20 * @syscap SystemCapability.Communication.NetManager.Eap 21 * @since 20 22 */ 23declare namespace eap { 24 /** 25 * Customize eap packets by callback 26 * @permission ohos.permission.MANAGE_ENTERPRISE_WIFI_CONNECTION 27 * @param { number } netType Indicates net type need to customize. 28 * @param { number } eapCode Indicates eap code need to customize. 29 * @param { number } eapType Indicates eap type need to customize. 30 * @param { Callback<EapData> } callback - the callback of eap packet customization. 31 * @throws { BusinessError } 201 - Permission denied. 32 * @throws { BusinessError } 33200006 - Invalid net type 33 * @throws { BusinessError } 33200007 - Invalid eap code 34 * @throws { BusinessError } 33200008 - Invalid eap type 35 * @throws { BusinessError } 33200009 - netmanager stop 36 * @throws { BusinessError } 33200099 - internal error 37 * @syscap SystemCapability.Communication.NetManager.Eap 38 * @since 20 39 */ 40 function regCustomEapHandler(netType: number, eapCode: number, eapType: number, callback: Callback<EapData>): void; 41 42 /** 43 * unreg the callback of eap packet customization. 44 * @permission ohos.permission.MANAGE_ENTERPRISE_WIFI_CONNECTION 45 * @param { number } netType Indicates net type need to customize. 46 * @param { number } eapCode Indicates eap code need to customize. 47 * @param { number } eapType Indicates eap type need to customize. 48 * @param { Callback<EapData> } callback - the callback of eap packet customization. 49 * @throws { BusinessError } 201 - Permission denied. 50 * @throws { BusinessError } 33200006 - Invalid net type 51 * @throws { BusinessError } 33200007 - Invalid eap code 52 * @throws { BusinessError } 33200008 - Invalid eap type 53 * @throws { BusinessError } 33200009 - netmanager stop 54 * @throws { BusinessError } 33200099 - internal error 55 * @syscap SystemCapability.Communication.NetManager.Eap 56 * @since 20 57 */ 58 function unregCustomEapHandler(netType:number, eapCode: number, eapType: number, callback: Callback<EapData>): void; 59 60 /** 61 * send Customized eap packets to system 62 * @permission ohos.permission.MANAGE_ENTERPRISE_WIFI_CONNECTION 63 * @param { number } result Indicates the result of custom authentication. 64 * @param { EapData } data Indicates eap packet data after customization. 65 * @throws { BusinessError } 201 - Permission denied. 66 * @throws { BusinessError } 33200004 - Invalid result 67 * @throws { BusinessError } 33200005 - Invalid size of eap data 68 * @throws { BusinessError } 33200009 - netmanager stop 69 * @throws { BusinessError } 33200099 - internal error 70 * @syscap SystemCapability.Communication.NetManager.Eap 71 * @since 20 72 */ 73 function replyCustomEapData(result: CustomResult, data: EapData): void; 74 75 76 /** 77 * Set the specified network interface parameters. 78 * @permission ohos.permission.MANAGE_ENTERPRISE_WIFI_CONNECTION 79 * @param { number } netId Indicates the eth network id to start EAP authentication. 80 * @param { EthEapProfile } profile Indicates the eap profile. 81 * @throws { BusinessError } 201 - Permission denied. 82 * @throws { BusinessError } 33200001 - Invalid netId 83 * @throws { BusinessError } 33200003 - Invalid profile 84 * @throws { BusinessError } 33200009 - netmanager stop 85 * @throws { BusinessError } 33200010 - invalid eth state 86 * @throws { BusinessError } 33200099 - internal error 87 * @syscap SystemCapability.Communication.NetManager.Eap 88 * @since 20 89 */ 90 function startEthEap(netId: number, profile: EthEapProfile): void; 91 92 /** 93 * Check whether the specified network is active. 94 * @permission ohos.permission.MANAGE_ENTERPRISE_WIFI_CONNECTION 95 * @param { number } netId Indicates the eth network id to log off EAP authentication. 96 * @throws { BusinessError } 201 - Permission denied. 97 * @throws { BusinessError } 33200001 - Invalid netId 98 * @throws { BusinessError } 33200002 - Log off fail 99 * @throws { BusinessError } 33200009 - netmanager stop 100 * @throws { BusinessError } 33200010 - invalid eth state 101 * @throws { BusinessError } 33200099 - internal error 102 * @syscap SystemCapability.Communication.NetManager.Eap 103 * @since 20 104 */ 105 function logOffEthEap(netId: number): void; 106 107 /** 108 * Describes the EAP information. 109 * 110 * @typedef EapData 111 * @syscap SystemCapability.Communication.NetManager.Eap 112 * @since 20 113 */ 114 interface EapData { 115 /** 116 * EAP message ID. 117 * 118 * @type { number } 119 * @syscap SystemCapability.Communication.NetManager.Eap 120 * @since 20 121 */ 122 msgId: number; 123 /** 124 * EAP packet buffer. 125 * 126 * @type { Uint8Array } 127 * @syscap SystemCapability.Communication.NetManager.Eap 128 * @since 20 129 */ 130 eapBuffer: Uint8Array; 131 /** 132 * EAP packet length. 133 * 134 * @type { number } 135 * @syscap SystemCapability.Communication.NetManager.Eap 136 * @since 20 137 */ 138 bufferLen: number; 139 } 140 141 /** 142 * custom 802.1x result. 143 * 144 * @enum { number } 145 * @syscap SystemCapability.Communication.NetManager.Eap 146 * @since 20 147 */ 148 enum CustomResult { 149 /** 150 * custom authentication finished and fail 151 * 152 * @syscap SystemCapability.Communication.NetManager.Eap 153 * @since 20 154 */ 155 RESULT_FAIL, 156 157 /** 158 * custom authentication success for current step, go to next step 159 * 160 * @syscap SystemCapability.Communication.NetManager.Eap 161 * @since 20 162 */ 163 RESULT_NEXT, 164 165 /** 166 * custom authentication finished and success 167 * 168 * @syscap SystemCapability.Communication.NetManager.Eap 169 * @since 20 170 */ 171 RESULT_FINISH, 172 } 173 174/** 175 * 802.1x EAP method. 176 * 177 * @enum { number } 178 * @syscap SystemCapability.Communication.NetManager.Eap 179 * @since 20 180 */ 181 enum EapMethod { 182 /** 183 * Not specified 184 * 185 * @syscap SystemCapability.Communication.NetManager.Eap 186 * @since 20 187 */ 188 EAP_NONE, 189 190 /** 191 * Protected extensible authentication protocol 192 * 193 * @syscap SystemCapability.Communication.NetManager.Eap 194 * @since 20 195 */ 196 EAP_PEAP, 197 198 /** 199 * Transport layer security 200 * 201 * @syscap SystemCapability.Communication.NetManager.Eap 202 * @since 20 203 */ 204 EAP_TLS, 205 206 /** 207 * Tunneled transport layer security 208 * 209 * @syscap SystemCapability.Communication.NetManager.Eap 210 * @since 20 211 */ 212 EAP_TTLS, 213 214 /** 215 * Password 216 * 217 * @syscap SystemCapability.Communication.NetManager.Eap 218 * @since 20 219 */ 220 EAP_PWD, 221 222 /** 223 * Subscriber identity module 224 * 225 * @syscap SystemCapability.Communication.NetManager.Eap 226 * @since 20 227 */ 228 EAP_SIM, 229 230 /** 231 * Authentication and key agreement 232 * 233 * @syscap SystemCapability.Communication.NetManager.Eap 234 * @since 20 235 */ 236 EAP_AKA, 237 238 /** 239 * AKA prime 240 * 241 * @syscap SystemCapability.Communication.NetManager.Eap 242 * @since 20 243 */ 244 EAP_AKA_PRIME, 245 246 /** 247 * Unauth TLS 248 * 249 * @syscap SystemCapability.Communication.NetManager.Eap 250 * @since 20 251 */ 252 EAP_UNAUTH_TLS 253 } 254 255 /** 256 * 802.1x phase 2 method. 257 * 258 * @enum { number } 259 * @syscap SystemCapability.Communication.NetManager.Eap 260 * @since 20 261 */ 262 enum Phase2Method { 263 /** 264 * Not specified 265 * 266 * @syscap SystemCapability.Communication.NetManager.Eap 267 * @since 20 268 */ 269 PHASE2_NONE, 270 271 /** 272 * Password authentication protocol 273 * 274 * @syscap SystemCapability.Communication.NetManager.Eap 275 * @since 20 276 */ 277 PHASE2_PAP, 278 279 /** 280 * Microsoft challenge handshake authentication protocol 281 * 282 * @syscap SystemCapability.Communication.NetManager.Eap 283 * @since 20 284 */ 285 PHASE2_MSCHAP, 286 287 /** 288 * Microsoft challenge handshake authentication protocol version 2 289 * 290 * @syscap SystemCapability.Communication.NetManager.Eap 291 * @since 20 292 */ 293 PHASE2_MSCHAPV2, 294 295 /** 296 * Generic token card 297 * 298 * @syscap SystemCapability.Communication.NetManager.Eap 299 * @since 20 300 */ 301 PHASE2_GTC, 302 303 /** 304 * Subscriber identity module 305 * 306 * @syscap SystemCapability.Communication.NetManager.Eap 307 * @since 20 308 */ 309 PHASE2_SIM, 310 311 /** 312 * Authentication and key agreement 313 * 314 * @syscap SystemCapability.Communication.NetManager.Eap 315 * @since 20 316 */ 317 PHASE2_AKA, 318 319 /** 320 * AKA Prime 321 * 322 * @syscap SystemCapability.Communication.NetManager.Eap 323 * @since 20 324 */ 325 PHASE2_AKA_PRIME 326 } 327 328 /** 329 * Eth EAP profile. 330 * 331 * @typedef EthEapProfile 332 * @syscap SystemCapability.Communication.NetManager.Eap 333 * @since 20 334 */ 335 interface EthEapProfile { 336 /** 337 * EAP authentication method 338 * 339 * @type { EapMethod } 340 * @syscap SystemCapability.Communication.NetManager.Eap 341 * @since 20 342 */ 343 eapMethod: EapMethod; 344 345 /** 346 * Phase 2 authentication method 347 * 348 * @type { Phase2Method } 349 * @syscap SystemCapability.Communication.NetManager.Eap 350 * @since 20 351 */ 352 phase2Method: Phase2Method; 353 354 /** 355 * The identity 356 * 357 * @type { string } 358 * @syscap SystemCapability.Communication.NetManager.Eap 359 * @since 20 360 */ 361 identity: string; 362 363 /** 364 * Anonymous identity 365 * 366 * @type { string } 367 * @syscap SystemCapability.Communication.NetManager.Eap 368 * @since 20 369 */ 370 anonymousIdentity: string; 371 372 /** 373 * Password 374 * 375 * @type { string } 376 * @syscap SystemCapability.Communication.NetManager.Eap 377 * @since 20 378 */ 379 password: string; 380 381 /** 382 * CA certificate alias 383 * 384 * @type { string } 385 * @syscap SystemCapability.Communication.NetManager.Eap 386 * @since 20 387 */ 388 caCertAliases: string; 389 390 /** 391 * CA certificate path 392 * 393 * @type { string } 394 * @syscap SystemCapability.Communication.NetManager.Eap 395 * @since 20 396 */ 397 caPath: string; 398 399 /** 400 * Client certificate alias 401 * 402 * @type { string } 403 * @syscap SystemCapability.Communication.NetManager.Eap 404 * @since 20 405 */ 406 clientCertAliases: string; 407 408 /** 409 * content of user's certificate 410 * 411 * @type { Uint8Array } 412 * @syscap SystemCapability.Communication.NetManager.Eap 413 * @since 20 414 */ 415 certEntry: Uint8Array; 416 417 /** 418 * Password of user's certificate 419 * 420 * @type { string } 421 * @syscap SystemCapability.Communication.NetManager.Eap 422 * @since 20 423 */ 424 certPassword: string; 425 426 /** 427 * Alternate subject match 428 * 429 * @type { string } 430 * @syscap SystemCapability.Communication.NetManager.Eap 431 * @since 20 432 */ 433 altSubjectMatch: string; 434 435 /** 436 * Domain suffix match 437 * 438 * @type { string } 439 * @syscap SystemCapability.Communication.NetManager.Eap 440 * @since 20 441 */ 442 domainSuffixMatch: string; 443 444 /** 445 * Realm for Passpoint credential 446 * 447 * @type { string } 448 * @syscap SystemCapability.Communication.NetManager.Eap 449 * @since 20 450 */ 451 realm: string; 452 453 /** 454 * Public Land Mobile Network of the provider of Passpoint credential 455 * 456 * @type { string } 457 * @syscap SystemCapability.Communication.NetManager.Eap 458 * @since 20 459 */ 460 plmn: string; 461 462 /** 463 * Sub ID of the SIM card 464 * 465 * @type { number } 466 * @syscap SystemCapability.Communication.NetManager.Eap 467 * @since 20 468 */ 469 eapSubId: number; 470 } 471 472} 473 474export default eap;