root/opal/mca/pmix/pmix4x/pmix/src/mca/pif/base/pif_base_components.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. pmix_pif_base_register
  2. pmix_pif_base_open
  3. pmix_pif_base_close
  4. pmix_pif_construct

   1 /*
   2  * Copyright (c) 2010-2013 Cisco Systems, Inc.  All rights reserved.
   3  * Copyright (c) 2015-2016 Intel, Inc.  All rights reserved.
   4  * Copyright (c) 2015-2016 Research Organization for Information Science
   5  *                         and Technology (RIST). All rights reserved.
   6  * $COPYRIGHT$
   7  *
   8  * Additional copyrights may follow
   9  *
  10  * $HEADER$
  11  *
  12  */
  13 
  14 #include "pmix_config.h"
  15 
  16 #include "pmix_common.h"
  17 #include "src/util/output.h"
  18 #include "src/mca/mca.h"
  19 #include "src/mca/pif/pif.h"
  20 #include "src/mca/pif/base/base.h"
  21 #include "src/mca/pif/base/static-components.h"
  22 
  23 /* instantiate the global list of interfaces */
  24 pmix_list_t pmix_if_list = {{0}};
  25 bool pmix_if_do_not_resolve = false;
  26 bool pmix_if_retain_loopback = false;
  27 
  28 static int pmix_pif_base_register (pmix_mca_base_register_flag_t flags);
  29 static int pmix_pif_base_open (pmix_mca_base_open_flag_t flags);
  30 static int pmix_pif_base_close(void);
  31 static void pmix_pif_construct(pmix_pif_t *obj);
  32 
  33 static bool frameopen = false;
  34 
  35 /* instance the pmix_pif_t object */
  36 PMIX_CLASS_INSTANCE(pmix_pif_t, pmix_list_item_t, pmix_pif_construct, NULL);
  37 
  38 PMIX_MCA_BASE_FRAMEWORK_DECLARE(pmix, pif, NULL, pmix_pif_base_register, pmix_pif_base_open, pmix_pif_base_close,
  39                                 mca_pif_base_static_components, 0);
  40 
  41 static int pmix_pif_base_register (pmix_mca_base_register_flag_t flags)
  42 {
  43     pmix_if_do_not_resolve = false;
  44     (void) pmix_mca_base_framework_var_register (&pmix_pif_base_framework, "do_not_resolve",
  45                                                  "If nonzero, do not attempt to resolve interfaces",
  46                                                  PMIX_MCA_BASE_VAR_TYPE_BOOL, NULL, 0, PMIX_MCA_BASE_VAR_FLAG_SETTABLE,
  47                                                  PMIX_INFO_LVL_9, PMIX_MCA_BASE_VAR_SCOPE_ALL_EQ,
  48                                                  &pmix_if_do_not_resolve);
  49 
  50     pmix_if_retain_loopback = false;
  51     (void) pmix_mca_base_framework_var_register (&pmix_pif_base_framework, "retain_loopback",
  52                                                  "If nonzero, retain loopback interfaces",
  53                                                  PMIX_MCA_BASE_VAR_TYPE_BOOL, NULL, 0, PMIX_MCA_BASE_VAR_FLAG_SETTABLE,
  54                                                  PMIX_INFO_LVL_9, PMIX_MCA_BASE_VAR_SCOPE_ALL_EQ,
  55                                                  &pmix_if_retain_loopback);
  56 
  57     return PMIX_SUCCESS;
  58 }
  59 
  60 
  61 static int pmix_pif_base_open (pmix_mca_base_open_flag_t flags)
  62 {
  63     if (frameopen) {
  64         return PMIX_SUCCESS;
  65     }
  66     frameopen = true;
  67 
  68     /* setup the global list */
  69     PMIX_CONSTRUCT(&pmix_if_list, pmix_list_t);
  70 
  71     return pmix_mca_base_framework_components_open(&pmix_pif_base_framework, flags);
  72 }
  73 
  74 
  75 static int pmix_pif_base_close(void)
  76 {
  77     pmix_list_item_t *item;
  78 
  79     if (!frameopen) {
  80         return PMIX_SUCCESS;
  81     }
  82     frameopen = false;
  83 
  84     while (NULL != (item = pmix_list_remove_first(&pmix_if_list))) {
  85         PMIX_RELEASE(item);
  86     }
  87     PMIX_DESTRUCT(&pmix_if_list);
  88 
  89     return pmix_mca_base_framework_components_close(&pmix_pif_base_framework, NULL);
  90 }
  91 
  92 static void pmix_pif_construct(pmix_pif_t *obj)
  93 {
  94     memset(obj->if_name, 0, sizeof(obj->if_name));
  95     obj->if_index = -1;
  96     obj->if_kernel_index = (uint16_t) -1;
  97     obj->af_family = PF_UNSPEC;
  98     obj->if_flags = 0;
  99     obj->if_speed = 0;
 100     memset(&obj->if_addr, 0, sizeof(obj->if_addr));
 101     obj->if_mask = 0;
 102     obj->if_bandwidth = 0;
 103     memset(obj->if_mac, 0, sizeof(obj->if_mac));
 104     obj->ifmtu = 0;
 105 }

/* [<][>][^][v][top][bottom][index][help] */