summaryrefslogtreecommitdiffstats
path: root/dom/system/gonk/nsINetworkService.idl
blob: 50a468494598f479e42273ca58a37ed756590407 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

[scriptable, function, uuid(91824160-fb25-11e1-a21f-0800200c9a66)]
interface nsIWifiTetheringCallback : nsISupports
{
  /**
   * Callback function used to report status to WifiManager.
   *
   * @param error
   *        An error message if the operation wasn't successful,
   *        or `null` if it was.
   */
  void wifiTetheringEnabledChange(in jsval error);
};

[scriptable, function, uuid(9c128e68-5e4b-4626-bb88-84ec54cce5d8)]
interface nsINetworkStatsCallback : nsISupports
{
  void networkStatsAvailable(in boolean success,
                             in unsigned long rxBytes,
                             in unsigned long txBytes,
                             in unsigned long long timestamp);
};

[scriptable, function, uuid(0706bfa2-ac2d-11e2-9a8d-7b6d988d4767)]
interface nsINetworkUsageAlarmCallback : nsISupports
{
  void networkUsageAlarmResult(in jsval error);
};

[scriptable, function, uuid(9ede8720-f8bc-11e2-b778-0800200c9a66)]
interface nsIWifiOperationModeCallback : nsISupports
{
  /**
   * Callback function used to report result to WifiManager.
   *
   * @param error
   *        An error message if the operation wasn't successful,
   *        or `null` if it was.
   */
  void wifiOperationModeResult(in jsval error);
};

[scriptable, function, uuid(097878b0-19fc-11e3-8ffd-0800200c9a66)]
interface nsISetDhcpServerCallback : nsISupports
{
  /**
   * Callback function used to report the DHCP server set result
   *
   * @param error
   *        An error message if the operation wasn't successful,
   *        or `null` if it was.
   */
  void dhcpServerResult(in jsval error);
};

[scriptable, function, uuid(32407c50-46c7-11e3-8f96-0800200c9a66)]
interface nsIUsbTetheringCallback : nsISupports
{
  /**
   * Callback function used to report status of enabling usb tethering.
   *
   * @param error
   *        An error message if the operation wasn't successful,
   *        or `null` if it was.
   */
  void usbTetheringEnabledChange(in jsval error);
};

[scriptable, function, uuid(055fd560-46ad-11e3-8f96-0800200c9a66)]
interface nsIEnableUsbRndisCallback : nsISupports
{
  /**
   * Callback function used to report the status of enabling/disabling usb rndis.
   *
   * @param success
   *        Boolean to indicate the operation is successful or not.
   * @param enable
   *        Boolean to indicate if we are enabling or disabling usb rndis.
   */
  void enableUsbRndisResult(in boolean success, in boolean enable);
};

[scriptable, function, uuid(4f08cc30-46ad-11e3-8f96-0800200c9a66)]
interface nsIUpdateUpStreamCallback : nsISupports
{
  /**
   * Callback function used to report the result of updating upstream.
   *
   * @param success
   *        Boolean to indicate the operation is successful or not.
   * @param externalIfname
   *        The external interface name.
   */
  void updateUpStreamResult(in boolean success, in DOMString externalIfname);
};

[scriptable, function, uuid(eedca6c0-1310-11e4-9191-0800200c9a66)]
interface nsISetDnsCallback : nsISupports
{
  /**
   * Callback function used to report the result of setting DNS server.
   *
   * @param error
   *        An error message if the operation wasn't successful,
   *        or `null` if it was.
   */
  void setDnsResult(in jsval error);
};

[scriptable, function, uuid(5d0e1a60-1187-11e4-9191-0800200c9a66)]
interface nsINativeCommandCallback : nsISupports
{
  /**
   * Callback function used to report the result of a network native command.
   *
   * @param success
   *        Boolean to indicate the operation is successful or not.
   */
  void nativeCommandResult(in boolean success);
};

[scriptable, function, uuid(694abb80-1187-11e4-9191-0800200c9a66)]
interface nsIDhcpRequestCallback : nsISupports
{
  /**
   * Callback function used to report the result of DHCP client request.
   *
   * @param success
   *        Boolean to indicate the operation is successful or not.
   *
   * @param dhcpInfo
   *        An object to represent the successful DHCP request:
   *
   *          - gateway_str: string
   *          - dns1_str:    string
   *          - dns2_str:    string
   *          - mask_str:    string
   *          - server_str:  string
   *          - vendor_str:  string
   *          - lease:       long
   *          - mask:        long
   *          - ipaddr:      long
   *          - gateway:     long
   *          - dns1:        long
   *          - dns2:        long
   *          - server:      long
   */
  void dhcpRequestResult(in boolean success, in jsval dhcpInfo);
};

[scriptable, function, uuid(88e3ee22-f1b3-4fa0-8a5d-793fb827c42c)]
interface nsIGetInterfacesCallback : nsISupports
{
  /**
   * Callback function used to return the list of existing network interfaces.
   *
   * @param success
   *        Boolean to indicate the operation is successful or not.
   * @param interfaceList
   *        An array of interface name.
   */
  void getInterfacesResult(in boolean success, in jsval interfaceList);
};

[scriptable, function, uuid(064e02a3-d2c0-42c5-a293-1efa84056100)]
interface nsIGetInterfaceConfigCallback : nsISupports
{
  /**
   * Callback function used to return the network config of a given interface.
   *
   * @param success
   *        Boolean to indicate the operation is successful or not.
   * @param result
   *        .ip: Ip address.
   *        .prefix: mask length.
   *        .link: network link properties.
   *        .mac: mac address.
   */
  void getInterfaceConfigResult(in boolean success, in jsval result);
};

[scriptable, function, uuid(b370f360-6ba8-4517-a4f9-31e8f004ee91)]
interface nsISetInterfaceConfigCallback : nsISupports
{
  /**
   * Callback function used to set network config for a specified interface.
   *
   * @param success
   *        Boolean to indicate the operation is successful or not.
   */
  void setInterfaceConfigResult(in boolean success);
};

/**
 * Provide network services.
 */
[scriptable, uuid(e16fe98f-9f63-48fe-82ba-8d1a1b7c6a57)]
interface nsINetworkService : nsISupports
{
  const long MODIFY_ROUTE_ADD    = 0;
  const long MODIFY_ROUTE_REMOVE = 1;

  /**
   * Enable or disable Wifi Tethering
   *
   * @param enabled
   *        Boolean that indicates whether tethering should be enabled (true) or disabled (false).
   * @param config
   *        The Wifi Tethering configuration from settings db.
   * @param callback
   *        Callback function used to report status to WifiManager.
   */
  void setWifiTethering(in boolean enabled,
                        in jsval config,
                        in nsIWifiTetheringCallback callback);

  /**
   * Enable or disable DHCP server
   *
   * @param enabled
   *        Boolean that indicates enabling or disabling DHCP server.
   *
   * @param config
   *        Config used to enable the DHCP server. It contains
   *        .startIp    start of the ip lease range (string)
   *        .endIp      end of the ip lease range (string)
   *        .serverIp   ip of the DHCP server (string)
   *        .maskLength the length of the subnet mask
   *        .ifname     the interface name
   *
   *        As for disabling the DHCP server, put this value |null|.
   *
   * @param callback
   *        Callback function used to report status.
   */
  void setDhcpServer(in boolean enabled,
                     in jsval config,
                     in nsISetDhcpServerCallback callback);


  /**
   * Retrieve network interface stats.
   *
   * @param networkName
   *        Select the Network interface to request estats.
   *
   * @param callback
   *        Callback to notify result and provide stats, connectionType
   *        and the date when stats are retrieved
   */
  void getNetworkInterfaceStats(in DOMString networkName, in nsINetworkStatsCallback callback);

  /**
   * Set Alarm of usage per interface
   *
   * @param networkName
   *        Select the Network interface to set an alarm.
   *
   * @param threshold
   *        Amount of data that will trigger the alarm.
   *
   * @param callback
   *        Callback to notify the result.
   *
   * @return false if there is no interface registered for the networkType param.
   */
  boolean setNetworkInterfaceAlarm(in DOMString networkName,
                                   in long long threshold,
                                   in nsINetworkUsageAlarmCallback callback);

  /**
   * Reload Wifi firmware to specific operation mode.
   *
   * @param interfaceName
   *        Wifi Network interface name.
   *
   * @param mode
   *        AP  - Access pointer mode.
   *        P2P - Peer to peer connection mode.
   *        STA - Station mode.
   *
   * @param callback
   *        Callback to notify Wifi firmware reload result.
   */
  void setWifiOperationMode(in DOMString interfaceName,
                            in DOMString mode,
                            in nsIWifiOperationModeCallback callback);

  /**
   * Set USB tethering.
   *
   * @param enabled
   *        Boolean to indicate we are going to enable or disable usb tethering.
   * @param config
   *        The usb tethering configuration.
   * @param callback
   *        Callback function used to report the result enabling/disabling usb tethering.
   */
  void setUSBTethering(in boolean enabled,
                       in jsval config,
                       in nsIUsbTetheringCallback callback);

  /**
   * Reset routing table.
   *
   * @param interfaceName
   *        The name of the network interface we want to remove from the routing
   *        table.
   *
   * @param callback
   *        Callback to notify the result of resetting routing table.
   */
  void resetRoutingTable(in DOMString interfaceName,
                         in nsINativeCommandCallback callback);

  /**
   * Set DNS.
   *
   * @param interfaceName
   *        The network interface name of the DNS we want to set.
   * @param dnsesCount
   *        Number of elements in dnses.
   * @param dnses
   *        Dnses to set.
   * @param gatewaysCount
   *        Number of elements in gateways.
   * @param gateways
   *        Gateways for the dnses, the most suitable, usually the one with the
   *        same address family, will be selected for each dns.
   *
   * @param callback
   *        Callback to notify the result of setting DNS server.
   */
  void setDNS(in DOMString interfaceName,
              in unsigned long dnsesCount,
              [array, size_is(dnsesCount)] in wstring dnses,
              in unsigned long gatewaysCount,
              [array, size_is(gatewaysCount)] in wstring gateways,
              in nsISetDnsCallback callback);

  /**
   * Set default route.
   *
   * @param interfaceName
   *        The network interface name of the default route we want to set.
   * @param count
   *        Number of elements in gateways.
   * @param gateways
   *        Default gateways for setting default route.
   *
   * @param callback
   *        Callback to notify the result of setting default route.
   */
  void setDefaultRoute(in DOMString interfaceName,
                       in unsigned long count,
                       [array, size_is(count)] in wstring gateways,
                       in nsINativeCommandCallback callback);

  /**
   * Remove default route.
   *
   * @param interfaceName
   *        The network interface name of the default route we want to remove.
   * @param count
   *        Number of elements in gateways.
   * @param gatways
   *        Default gateways for removing default route.
   *
   * @param callback
   *        Callback to notify the result of removing default route.
   */
  void removeDefaultRoute(in DOMString interfaceName,
                          in unsigned long count,
                          [array, size_is(count)] in wstring gateways,
                          in nsINativeCommandCallback callback);

  /**
   * Modify route.
   *
   * @param action
   *        nsINetworkService.MODIFY_ROUTE_ADD to add route and
   *        nsINetworkService.MODIFY_ROUTE_REMOVE to remove.
   * @param interfaceName
   *        Network interface name for the output of the host route.
   * @param host
   *        Host ip we want to remove route for.
   * @param prefixLength
   *        The prefix length of the route we'd like to modify.
   * @param [optional] gateway
   *        Gateway ip for the output of the host route.
   *
   * @return A deferred promise that resolves on success or rejects with a
   *         specified reason otherwise.
   */
  jsval modifyRoute(in long      action,
                    in DOMString interfaceName,
                    in DOMString host,
                    in long      prefixLength,
                    [optional] in DOMString gateway);

  /**
   * Add route to secondary routing table.
   *
   * @param interfaceName
   *        The network interface for this route.
   * @param route
   *        The route info should have the following fields:
   *        .ip: destination ip address
   *        .prefix: destination prefix
   *        .gateway: gateway ip address
   */
  void addSecondaryRoute(in DOMString interfaceName, in jsval route,
                         in nsINativeCommandCallback callback);

  /**
   * Remove route from secondary routing table.
   *
   * @param interfaceName
   *        The network interface for the route we want to remove.
   * @param route
   *        The route info should have the following fields:
   *        .ip: destination ip address
   *        .prefix: destination prefix
   *        .gateway: gateway ip address
   */
  void removeSecondaryRoute(in DOMString interfaceName, in jsval route,
                            in nsINativeCommandCallback callback);

  /**
   * Enable or disable usb rndis.
   *
   * @param enable
   *        Boolean to indicate we want enable or disable usb rndis.
   * @param callback
   *        Callback function to report the result.
   */
  void enableUsbRndis(in boolean enable,
                      in nsIEnableUsbRndisCallback callback);

  /**
   * Update upstream.
   *
   * @param previous
   *        The previous internal and external interface.
   * @param current
   *        The current internal and external interface.
   * @param callback
   *        Callback function to report the result.
   */
  void updateUpStream(in jsval previous,
                      in jsval current,
                      in nsIUpdateUpStreamCallback callback);

  /*
   * Obtain interfaces list.
   *
   * @param callback
   *        Callback function to return the result.
   */
  void getInterfaces(in nsIGetInterfacesCallback callback);

  /**
   * Get config of a network interface.
   *
   * @param ifname
   *        Target interface.
   * @param callback
   *        Callback function to report the result.
   */
  void getInterfaceConfig(in DOMString ifname, in nsIGetInterfaceConfigCallback callback);

  /**
   * Set config for a network interface.
   *
   * @param config
   *        .ifname: Target interface.
   *        .ip: Ip address.
   *        .prefix: mask length.
   *        .link: network link properties.
   * @param callback
   *        Callback function to report the result.
   */
  void setInterfaceConfig(in jsval config, in nsISetInterfaceConfigCallback callback);

  /**
   * Configure a network interface.
   *
   * @param config
   *        An object containing the detail that we want to configure the interface:
   *
   *          - ifname:  string
   *          - ipaddr:  long
   *          - mask:    long
   *          - gateway: long
   *          - dns1:    long
   *          - dns2:    long
   *
   * @param callback
   *        Callback to notify the result of configurating network interface.
   */
  void configureInterface(in jsval config,
                          in nsINativeCommandCallback callback);

  /**
   * Issue a DHCP client request.
   *
   * @param networkInterface
   *        The network interface which we wnat to do the DHCP request on.
   *
   * @param callback
   *        Callback to notify the result of the DHCP request.
   */
  void dhcpRequest(in DOMString interfaceName,
                   in nsIDhcpRequestCallback callback);

  /**
   * Stop Dhcp daemon.
   *
   * @param ifname
   *        Target interface.
   *
   * @param callback
   *        Callback to notify the result of stopping dhcp request.
   */
  void stopDhcp(in DOMString ifname,
                in nsINativeCommandCallback callback);

  /**
   * Enable a network interface.
   *
   * @param networkInterface
   *        The network interface name which we want to enable.
   *
   * @param callback
   *        Callback to notify the result of disabling network interface.
   */
  void enableInterface(in DOMString interfaceName,
                       in nsINativeCommandCallback callback);

  /**
   * Disable a network interface.
   *
   * @param networkInterface
   *        The network interface name which we want to disable.
   *
   * @param callback
   *        Callback to notify the result of disabling network interface.
   */
  void disableInterface(in DOMString interfaceName,
                        in nsINativeCommandCallback callback);

  /**
   * Reset all connections on a specified network interface.
   *
   * @param interfaceName
   *        The network interface name which we want to reset.
   *
   * @param callback
   *        Callback to notify the result of resetting connections.
   */
  void resetConnections(in DOMString interfaceName,
                        in nsINativeCommandCallback callback);

  /**
   * Create network (required to call prior to any networking operation).
   *
   * @param interfaceName
   *        The network interface name which we want to create network for.
   *
   * @param callback
   *        Callback to notify the result of creating network.
   */
  void createNetwork(in DOMString interfaceName,
                     in nsINativeCommandCallback callback);

  /**
   * Destroy network.
   *
   * @param interfaceName
   *        The network interface name of the network we want to destroy.
   *
   * @param callback
   *        Callback to notify the result of destroying network.
   */
  void destroyNetwork(in DOMString interfaceName,
                      in nsINativeCommandCallback callback);

  /**
   * Query the netId associated with given network interface name.
   *
   * @param interfaceName
   *        The network interface name which we want to query.
   *
   * @return A deferred promise that resolves with a string to indicate.
   *         the queried netId on success and rejects if the interface name
   *         is invalid.
   *
   */
  jsval getNetId(in DOMString interfaceName);

  /**
   * Set maximum transmission unit on a network interface.
   *
   * @param interfaceName
   *        The name of the network interface that we want to set mtu.
   * @param mtu
   *        Size of maximum tranmission unit.
   *
   * @param callback
   *        Callback to notify the result of setting mtu.
   */
  void setMtu(in DOMString interfaceName, in long mtu,
              in nsINativeCommandCallback callback);
};