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