Home | History | Annotate | Download | only in c
      1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2  * Use of this source code is governed by a BSD-style license that can be
      3  * found in the LICENSE file.
      4  */
      5 
      6 /* From ppb_network_list.idl modified Mon Sep  9 11:16:26 2013. */
      7 
      8 #ifndef PPAPI_C_PPB_NETWORK_LIST_H_
      9 #define PPAPI_C_PPB_NETWORK_LIST_H_
     10 
     11 #include "ppapi/c/pp_array_output.h"
     12 #include "ppapi/c/pp_bool.h"
     13 #include "ppapi/c/pp_macros.h"
     14 #include "ppapi/c/pp_resource.h"
     15 #include "ppapi/c/pp_stdint.h"
     16 #include "ppapi/c/pp_var.h"
     17 
     18 #define PPB_NETWORKLIST_INTERFACE_1_0 "PPB_NetworkList;1.0"
     19 #define PPB_NETWORKLIST_INTERFACE PPB_NETWORKLIST_INTERFACE_1_0
     20 
     21 /**
     22  * @file
     23  * This file defines the <code>PPB_NetworkList</code> interface.
     24  */
     25 
     26 
     27 /**
     28  * @addtogroup Enums
     29  * @{
     30  */
     31 /**
     32  * Type of a network interface.
     33  */
     34 typedef enum {
     35   /**
     36    * Type of the network interface is not known.
     37    */
     38   PP_NETWORKLIST_TYPE_UNKNOWN = 0,
     39   /**
     40    * Wired Ethernet network.
     41    */
     42   PP_NETWORKLIST_TYPE_ETHERNET = 1,
     43   /**
     44    * Wireless Wi-Fi network.
     45    */
     46   PP_NETWORKLIST_TYPE_WIFI = 2,
     47   /**
     48    * Cellular network (e.g. LTE).
     49    */
     50   PP_NETWORKLIST_TYPE_CELLULAR = 3
     51 } PP_NetworkList_Type;
     52 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetworkList_Type, 4);
     53 
     54 /**
     55  * State of a network interface.
     56  */
     57 typedef enum {
     58   /**
     59    * Network interface is down.
     60    */
     61   PP_NETWORKLIST_STATE_DOWN = 0,
     62   /**
     63    * Network interface is up.
     64    */
     65   PP_NETWORKLIST_STATE_UP = 1
     66 } PP_NetworkList_State;
     67 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetworkList_State, 4);
     68 /**
     69  * @}
     70  */
     71 
     72 /**
     73  * @addtogroup Interfaces
     74  * @{
     75  */
     76 /**
     77  * The <code>PPB_NetworkList</code> is used to represent a list of
     78  * network interfaces and their configuration. The content of the list
     79  * is immutable.  The current networks configuration can be received
     80  * using the <code>PPB_NetworkMonitor</code> interface.
     81  */
     82 struct PPB_NetworkList_1_0 {
     83   /**
     84    * Determines if the specified <code>resource</code> is a
     85    * <code>NetworkList</code> object.
     86    *
     87    * @param[in] resource A <code>PP_Resource</code> resource.
     88    *
     89    * @return Returns <code>PP_TRUE</code> if <code>resource</code> is
     90    * a <code>PPB_NetworkList</code>, <code>PP_FALSE</code>
     91    * otherwise.
     92    */
     93   PP_Bool (*IsNetworkList)(PP_Resource resource);
     94   /**
     95    * Gets number of interfaces in the list.
     96    *
     97    * @param[in] resource A <code>PP_Resource</code> corresponding to a
     98    * network list.
     99    *
    100    * @return Returns number of available network interfaces or 0 if
    101    * the list has never been updated.
    102    */
    103   uint32_t (*GetCount)(PP_Resource resource);
    104   /**
    105    * Gets name of a network interface.
    106    *
    107    * @param[in] resource A <code>PP_Resource</code> corresponding to a
    108    * network list.
    109    * @param[in] index Index of the network interface.
    110    *
    111    * @return Returns name for the network interface with the specified
    112    * <code>index</code>.
    113    */
    114   struct PP_Var (*GetName)(PP_Resource resource, uint32_t index);
    115   /**
    116    * Gets type of a network interface.
    117    *
    118    * @param[in] resource A <code>PP_Resource</code> corresponding to a
    119    * network list.
    120    * @param[in] index Index of the network interface.
    121    *
    122    * @return Returns type of the network interface with the specified
    123    * <code>index</code>.
    124    */
    125   PP_NetworkList_Type (*GetType)(PP_Resource resource, uint32_t index);
    126   /**
    127    * Gets state of a network interface.
    128    *
    129    * @param[in] resource A <code>PP_Resource</code> corresponding to a
    130    * network list.
    131    * @param[in] index Index of the network interface.
    132    *
    133    * @return Returns current state of the network interface with the
    134    * specified <code>index</code>.
    135    */
    136   PP_NetworkList_State (*GetState)(PP_Resource resource, uint32_t index);
    137   /**
    138    * Gets list of IP addresses for a network interface.
    139    *
    140    * @param[in] resource A <code>PP_Resource</code> corresponding to a
    141    * network list.
    142    * @param[in] index Index of the network interface.
    143    * @param[in] output An output array which will receive
    144    * <code>PPB_NetAddress</code> resources on success. Please note that the
    145    * ref count of those resources has already been increased by 1 for the
    146    * caller.
    147    *
    148    * @return An error code from <code>pp_errors.h</code>.
    149    */
    150   int32_t (*GetIpAddresses)(PP_Resource resource,
    151                             uint32_t index,
    152                             struct PP_ArrayOutput output);
    153   /**
    154    * Gets display name of a network interface.
    155    *
    156    * @param[in] resource A <code>PP_Resource</code> corresponding to a
    157    * network list.
    158    * @param[in] index Index of the network interface.
    159    *
    160    * @return Returns display name for the network interface with the
    161    * specified <code>index</code>.
    162    */
    163   struct PP_Var (*GetDisplayName)(PP_Resource resource, uint32_t index);
    164   /**
    165    * Gets MTU (Maximum Transmission Unit) of a network interface.
    166    *
    167    * @param[in] resource A <code>PP_Resource</code> corresponding to a
    168    * network list.
    169    * @param[in] index Index of the network interface.
    170    *
    171    * @return Returns MTU for the network interface with the specified
    172    * <code>index</code> or 0 if MTU is unknown.
    173    */
    174   uint32_t (*GetMTU)(PP_Resource resource, uint32_t index);
    175 };
    176 
    177 typedef struct PPB_NetworkList_1_0 PPB_NetworkList;
    178 /**
    179  * @}
    180  */
    181 
    182 #endif  /* PPAPI_C_PPB_NETWORK_LIST_H_ */
    183 
    184