Пример #1
0
void
nvm_data_write(void)
{
  LOG6LBR_INFO("Writing 6LBR NVM\n");
  int rv;
  rv = ext_flash_open();

  if(!rv) {
    LOG6LBR_ERROR("Could not open external flash\n");
    ext_flash_close();
    return;
  }

  rv = ext_flash_erase(CETIC_6LBR_NVM_ADDRESS, CETIC_6LBR_NVM_SIZE);

  if(!rv) {
    LOG6LBR_ERROR("Error erasing flash\n");
  } else {
    rv = ext_flash_write(CETIC_6LBR_NVM_ADDRESS, sizeof(nvm_data_t),
                         (uint8_t *)&nvm_data);
    if(!rv) {
      LOG6LBR_ERROR("Error writing flash\n");
    }
  }

  ext_flash_close();
}
Пример #2
0
void
check_nvm(nvm_data_t * nvm_data, int reset)
{
  uint8_t flash = 0;

  if(reset || nvm_data->magic != CETIC_6LBR_NVM_MAGIC
     || nvm_data->version > CETIC_6LBR_NVM_CURRENT_VERSION) {
    //NVM is invalid or we are rollbacking from another version
    //Set all data to default values
    if (!reset) {
      LOG6LBR_ERROR
        ("Invalid NVM magic number or unsupported NVM version, reseting it...\n");
    }
    nvm_reset_version_0(nvm_data);
    flash = 1;
  }
  if (nvm_data->size != sizeof(nvm_data_t)) {
    LOG6LBR_ERROR
      ("Invalid NVM size, reseting it...\n");
    nvm_reset_version_0(nvm_data);
    flash = 1;
  }

  if(flash) {
    nvm_data_write();
  }
}
Пример #3
0
void
nvm_data_write(void)
{
  long err;
  int retry = 4;
  while (retry > 0 ) {
    LOG6LBR_INFO("Flashing 6LBR NVM\n");
    err = rom_util_page_erase(CETIC_6LBR_NVM_ADDRESS, CETIC_6LBR_NVM_SIZE);
    if ( err != 0 ) {
      LOG6LBR_ERROR("erase error : %ld\n", err);
    }
    rom_util_program_flash( (uint32_t*)&nvm_data,
     CETIC_6LBR_NVM_ADDRESS, (sizeof(nvm_data_t)/4+1)*4);
    if ( err != 0 ) {
      LOG6LBR_ERROR("write error : %ld\n", err);
    }
    if(rom_util_memcmp( (void *)&nvm_data, (void *)CETIC_6LBR_NVM_ADDRESS, sizeof(nvm_data_t)) == 0) {
      break;
    }
    LOG6LBR_ERROR("verify NVM failed, retry\n");
    retry--;
  }
  if(retry == 0) {
    LOG6LBR_FATAL("Could not program 6LBR NVM !\n");
  } else {
    LOG6LBR_INFO("Flashing 6LBR NVM done\n");
  }
}
Пример #4
0
void
cetic_6lbr_save_ip(void)
{
  if (sixlbr_config_ip_file_name) {
    char str[INET6_ADDRSTRLEN];
#if CETIC_6LBR_SMARTBRIDGE
    inet_ntop(AF_INET6, (struct sockaddr_in6 *)&wsn_ip_addr, str, INET6_ADDRSTRLEN);
#else
    inet_ntop(AF_INET6, (struct sockaddr_in6 *)&eth_ip_addr, str, INET6_ADDRSTRLEN);
#endif
    FILE *ip_config_file = fopen(sixlbr_config_ip_file_name, "w");
    if(ip_config_file) {
      fprintf(ip_config_file, "%s\n", str);
      fclose(ip_config_file);
    } else {
      LOG6LBR_ERROR("Cannot create ip log file '%s' : %s\n", sixlbr_config_ip_file_name, strerror(errno));
    }

    char * ip4_file_name = (char *)malloc(strlen(sixlbr_config_ip_file_name + 1 + 1));
    strcpy(ip4_file_name, sixlbr_config_ip_file_name);
    strcat(ip4_file_name, "4");
    FILE *ip4_config_file = fopen(ip4_file_name, "w");
    if(ip4_config_file) {
      if((nvm_data.global_flags & CETIC_GLOBAL_IP64) != 0) {
        inet_ntop(AF_INET, (struct sockaddr_in *)&eth_ip64_addr, str, INET_ADDRSTRLEN);
        fprintf(ip4_config_file, "%s\n", str);
      } else {
        fprintf(ip4_config_file, "0.0.0.0\n");
      }
      fclose(ip4_config_file);
    } else {
      LOG6LBR_ERROR("Cannot create ip4 log file '%s' : %s\n", ip4_file_name, strerror(errno));
    }
  }
}
Пример #5
0
void plugins_load() {
  DIR *dirp;
  struct dirent *dp;

  list_init(sixlbr_plugins);

  if (slip_config_plugins == NULL) return;

  if ((dirp = opendir(slip_config_plugins)) == NULL) {
    LOG6LBR_ERROR("couldn't open '%s' : %s\n", slip_config_plugins, strerror(errno));
    return;
  }

  do {
    errno = 0;
    if ((dp = readdir(dirp)) != NULL) {
      int len = strlen(dp->d_name);
      if ( len > 3 && strcmp(&dp->d_name[len-3], ".so") == 0 ) {
        char * filename = (char *)malloc(strlen(slip_config_plugins)+len+1);
        strcpy(filename, slip_config_plugins);
        strcat(filename, "/");
        strcat(filename, dp->d_name);
        plugin_load(filename);
      }
    }
  } while (dp != NULL);

  if (errno != 0) {
    LOG6LBR_ERROR("error reading directory: %s", strerror(errno));
  }
  closedir(dirp);
}
Пример #6
0
uint8_t
wireless_output(const uip_lladdr_t * src, const uip_lladdr_t * dest)
{
	int ret;

	//Packet filtering
	//----------------
	if(uip_len == 0) {
		LOG6LBR_ERROR("wireless_output: uip_len = 0\n");
		return 0;
	}
	if(dest && linkaddr_cmp((linkaddr_t *) & dest,
			(linkaddr_t *) & wsn_mac_addr)) {
		LOG6LBR_ERROR("wireless_output: sending to self\n");
		return 0;
	}

	//Packet sending
	//--------------
	if(wireless_outputfunc != NULL) {
		LOG6LBR_PRINTF(PACKET, PF_OUT, "wireless_output: sending packet\n");
		ret = wireless_outputfunc(dest);
	} else {
		ret = 0;
	}
	return ret;
}
Пример #7
0
/*---------------------------------------------------------------------------*/
static void
send_packet(mac_callback_t sent, void *ptr)
{
  int size;

  /* 3 bytes per packet attribute is required for serialization */
  uint8_t buf[PACKETBUF_NUM_ATTRS * 3 + PACKETBUF_SIZE + 3];
  int sid;

  packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);

  /* ack or not ? */
  packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, 1);

  if(NETSTACK_FRAMER.create_and_secure() < 0) {
    /* Failed to allocate space for headers */
    LOG6LBR_ERROR("br-rdc: send failed, too large header\n");
    mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1);

  } else {
    /* here we send the data over SLIP to the radio-chip */
    size = 0;
    if(sixlbr_config_slip_serialize_tx_attrs) {
      size = packetutils_serialize_atts(&buf[3], sizeof(buf) - 3);
    }
    if(size < 0 || size + packetbuf_totlen() + 3 > sizeof(buf)) {
      LOG6LBR_ERROR("br-rdc: send failed, too large header\n");
      mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1);
    } else {
      sid = setup_callback(sent, ptr);
      if (sid != -1) {
        LOG6LBR_PRINTF(PACKET, RADIO_OUT, "write: %d (sid: %d, cb: %d)\n", packetbuf_datalen(), sid, callback_count);
        LOG6LBR_DUMP_PACKET(RADIO_OUT, packetbuf_dataptr(), packetbuf_datalen());

        buf[0] = '!';
        buf[1] = 'S';
        buf[2] = sid;             /* sequence or session number for this packet */

        /* Copy packet data */
        memcpy(&buf[3 + size], packetbuf_hdrptr(), packetbuf_totlen());
        callbacks[sid].buf_len = packetbuf_totlen() + size + 3;
        memcpy(callbacks[sid].buf, buf, callbacks[sid].buf_len);
        write_to_slip(buf, callbacks[sid].buf_len);
      } else {
        LOG6LBR_INFO("native-rdc queue full\n");
        mac_call_sent_callback(sent, ptr, MAC_TX_NOACK, 1);
      }
    }
  }
}
Пример #8
0
/*---------------------------------------------------------------------------*/
static void
packet_input(void)
{
  LOG6LBR_PRINTF(PACKET, RADIO_IN, "read: %d\n", packetbuf_datalen());
  if (LOG6LBR_COND(DUMP, RADIO_IN)) {
    uint8_t *data = packetbuf_dataptr();
    int len = packetbuf_datalen();
    int i;
#if WIRESHARK_IMPORT_FORMAT
    printf("0000");
    for(i = 0; i < len; i++)
      printf(" %02x", data[i]);
#else
    printf("         ");
    for(i = 0; i < len; i++) {
      printf("%02x", data[i]);
      if((i & 3) == 3)
        printf(" ");
      if((i & 15) == 15)
        printf("\n         ");
    }
#endif
    printf("\n");
  }
  if(NETSTACK_FRAMER.parse() < 0) {
    LOG6LBR_ERROR("br-rdc: failed to parse %u\n", packetbuf_datalen());
  } else {
    NETSTACK_MAC.input();
  }
}
Пример #9
0
void
nvm_data_write(void)
{
  memcpy(nvm_mem, (uint8_t *) & nvm_data, sizeof(nvm_data));
  LOG6LBR_DEBUG("Opening nvm file '%s'\n", sixlbr_config_nvm_file);
  int s = open(sixlbr_config_nvm_file, O_WRONLY | O_TRUNC | O_CREAT, 0644);

  if(s > 0) {
    if(write(s, nvm_mem, NVM_SIZE) != NVM_SIZE) {
      LOG6LBR_ERROR("Failed to write to NVM");
    }
    close(s);
  } else {
    LOG6LBR_ERROR("Could not open nvm file\n");
  }
}
Пример #10
0
/*---------------------------------------------------------------------------*/
static void
packet_timeout(void *ptr)
{
    struct tx_callback *callback = ptr;
    if (callback->isused) {
        callback_count--;
        callback->isused = 0;
        native_rdc_ack_timeout++;
        LOG6LBR_ERROR("br-rdc: send failed, slip ack timeout (%d)\n", callback->sid);
        packetbuf_clear();
        packetbuf_attr_copyfrom(callback->attrs, callback->addrs);
        mac_call_sent_callback(callback->cback, callback->ptr, MAC_TX_NOACK, 1);
    } else {
        LOG6LBR_ERROR("br-rdc: ack timeout for already acked packet (%d)\n", callback->sid);
    }
}
Пример #11
0
/*---------------------------------------------------------------------------*/
static int
connect_to_server(const char *host, const char *port)
{
  /* Setup TCP connection */
  struct addrinfo hints, *servinfo, *p;
  char s[INET6_ADDRSTRLEN];
  int rv, fd;

  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;

  if((rv = getaddrinfo(host, port, &hints, &servinfo)) != 0) {
    LOG6LBR_ERROR("getaddrinfo(): %s", gai_strerror(rv));
    return -1;
  }

  /* loop through all the results and connect to the first we can */
  for(p = servinfo; p != NULL; p = p->ai_next) {
    if((fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
      LOG6LBR_ERROR("socket() : %s\n", strerror(errno));
      continue;
    }

    if(connect(fd, p->ai_addr, p->ai_addrlen) == -1) {
      close(fd);
      LOG6LBR_ERROR("connect() : %s\n", strerror(errno));
      continue;
    }
    break;
  }

  if(p == NULL) {
    LOG6LBR_ERROR("can't connect to %s:%s", host, port);
    return -1;
  }

  fcntl(fd, F_SETFL, O_NONBLOCK);

  inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr),
            s, sizeof(s));

  /* all done with this structure */
  freeaddrinfo(servinfo);
  return fd;
}
Пример #12
0
static int
eth_output(const uip_lladdr_t * src, const uip_lladdr_t * dest)
{
	//Packet filtering
	//----------------
	if(uip_len == 0) {
		LOG6LBR_ERROR("eth_output: uip_len = 0\n");
		return 0;
	}

	if(dest && linkaddr_cmp((linkaddr_t *) & dest,
			(linkaddr_t *) & eth_mac64_addr)) {
		LOG6LBR_ERROR("ethernet_output: sending to self\n");
		return 0;
	}

	//Create packet header
	//--------------------
	//Packet type
	BUF->type = uip_htons(UIP_ETHTYPE_IPV6);

	//Destination address
	if(IS_BROADCAST_ADDR(dest)) {
		BUF->dest.addr[0] = 0x33;
		BUF->dest.addr[1] = 0x33;
		BUF->dest.addr[2] = UIP_IP_BUF->destipaddr.u8[12];
		BUF->dest.addr[3] = UIP_IP_BUF->destipaddr.u8[13];
		BUF->dest.addr[4] = UIP_IP_BUF->destipaddr.u8[14];
		BUF->dest.addr[5] = UIP_IP_BUF->destipaddr.u8[15];
	} else {
		memcpy(BUF->dest.addr, dest, 6);
	}

	//Source address
	if ( src != NULL ) {
		memcpy(BUF->src.addr, src, 6);
	} else {
		memcpy(BUF->src.addr, eth_mac_addr, 6);
	}
	//Sending packet
	//--------------
	LOG6LBR_PRINTF(PACKET, PF_OUT, "eth_output: Sending packet to Ethernet\n");
	eth_drv_send();

	return 1;
}
Пример #13
0
uint8_t
wireless_output(const uip_lladdr_t * src, const uip_lladdr_t * dest)
{
  int ret;

  //Packet filtering
  //----------------
  if(uip_len == 0) {
    LOG6LBR_ERROR("wireless_output: uip_len = 0\n");
    return 0;
  }
  if(dest && linkaddr_cmp((linkaddr_t *) & dest,
      (linkaddr_t *) & wsn_mac_addr)) {
    LOG6LBR_ERROR("wireless_output: sending to self\n");
    return 0;
  }

#if CETIC_6LBR_WSN_FILTER_RA
  //Filter out RA/RS towards WSN
  if(UIP_IP_BUF->proto == UIP_PROTO_ICMP6 &&
     (UIP_ICMP_BUF->type == ICMP6_RS || UIP_ICMP_BUF->type == ICMP6_RA)) {
    return 0;
  }
#endif

  //Packet sending
  //--------------
  if(wireless_outputfunc != NULL) {
#if CETIC_6LBR_TRANSPARENTBRIDGE
	if ( src != NULL ) {
      platform_set_wsn_mac((linkaddr_t *)src);
	}
#endif
	LOG6LBR_PRINTF(PACKET, PF_OUT, "wireless_output: sending packet\n");
    ret = wireless_outputfunc(dest);
#if CETIC_6LBR_TRANSPARENTBRIDGE
	if ( src != NULL ) {
      //Restore node address
	  platform_set_wsn_mac((linkaddr_t *) & wsn_mac_addr);
	}
#endif
  } else {
    ret = 0;
  }
  return ret;
}
Пример #14
0
static void
send_to_uip(void)
{
  if(tcpip_inputfunc != NULL) {
    tcpip_inputfunc();
  } else {
    LOG6LBR_ERROR("No input function set\n");
  }
}
Пример #15
0
static int native_config_network_route_handler(config_level_t level, void* user, const char* section, const char* name,
    const char* value) {
  static uip_ipaddr_t ipaddr;
  static uint8_t length = 0;
  static uip_ipaddr_t next_hop;

  if(level != CONFIG_LEVEL_NETWORK) {
    return 1;
  }

  if(!name) {
    if(!uip_is_addr_unspecified(&ipaddr) && length > 0 && !uip_is_addr_unspecified(&next_hop)) {
      uip_ds6_route_add_static(&ipaddr, length, &next_hop);
    } else {
      LOG6LBR_ERROR("Missing parameters for route creation\n");
      return 0;
    }
    //Reset parameters
    uip_create_unspecified(&ipaddr);
    uip_create_unspecified(&next_hop);
    length = 0;
    return 1;
  }

  if(strcmp(name, "dest") == 0) {
    if(uiplib_ipaddrconv(value, &ipaddr) == 0) {
      LOG6LBR_ERROR("Invalid ip address : %s\n", value);
      return 0;
    }
    length = 128;
  } else if (strcmp(name, "via") == 0) {
    if(uiplib_ipaddrconv(value, &next_hop) == 0) {
      LOG6LBR_ERROR("Invalid ip address : %s\n", value);
      return 0;
    }
  } else {
    LOG6LBR_ERROR("Invalid parameter : %s\n", name);
    return 0;
  }
  return 1;
}
Пример #16
0
static void
plugin_load(char const * plugin_file) {
  void *handle;
  const char *error;
  sixlbr_plugin_t *plugin_descriptor;
  sixlbr_plugin_info_t *plugin_info;

  LOG6LBR_INFO("Loading %s\n", plugin_file);
  handle = dlopen(plugin_file, RTLD_NOW);
  if(handle == NULL) {
    LOG6LBR_ERROR("Could not open %s : %s\n", plugin_file, dlerror());
    return;
  }

  *(void **)(&plugin_descriptor) =
      dlsym(handle, "sixlbr_plugin_info");
  if((error = dlerror()) || plugin_descriptor == NULL) {
    LOG6LBR_ERROR("Plugin descriptor not found in %s\n", plugin_file);
    return;
  }
  plugin_info = (sixlbr_plugin_info_t *)malloc(sizeof(sixlbr_plugin_info_t));
  plugin_info->plugin = plugin_descriptor;
  list_add(sixlbr_plugins, plugin_info);

  if (plugin_descriptor->api_version < SIXLBR_PLUGIN_API_VERSION) {
    LOG6LBR_ERROR("Plugin %s uses an obsolete api\n", plugin_file);
    plugin_info->status = -1;
    return;
  }
  plugin_info->status = 0;
  int result = 0;
  if (plugin_descriptor->load != NULL) {
    LOG6LBR_INFO("Initialising %s\n", plugin_descriptor->id);
    result = plugin_descriptor->load();
  }
  if (result != 0) {
    LOG6LBR_ERROR("Load code of %s failed, error code is %d\n", plugin_descriptor->id, result);
  }
  plugin_info->init_status = result;
}
Пример #17
0
/*---------------------------------------------------------------------------*/
void
packet_sent(uint8_t sessionid, uint8_t status, uint8_t tx)
{
    LOG6LBR_PRINTF(PACKET, RADIO_OUT, "sid ack: %d (%d, %d)\n", sessionid, status, tx);
    if(sessionid < MAX_CALLBACKS) {
        struct tx_callback *callback;

        callback = &callbacks[sessionid];
        if (callback->isused) {
            callback_count--;
            callback->isused = 0;
            packetbuf_clear();
            packetbuf_attr_copyfrom(callback->attrs, callback->addrs);
            ctimer_stop(&callback->timeout);
            mac_call_sent_callback(callback->cback, callback->ptr, status, tx);
        } else {
            LOG6LBR_ERROR("br-rdc: ack received for unknown packet (%d)\n", callback->sid);
        }
    } else {
        LOG6LBR_ERROR("*** ERROR: too high session id %d\n", sessionid);
    }
}
Пример #18
0
/*---------------------------------------------------------------------------*/
static void
packet_input(void)
{
    LOG6LBR_PRINTF(PACKET, RADIO_IN, "read: %d\n", packetbuf_datalen());
    LOG6LBR_DUMP_PACKET(RADIO_IN, packetbuf_dataptr(), packetbuf_datalen());

    if(NETSTACK_FRAMER.parse() < 0) {
        LOG6LBR_ERROR("br-rdc: failed to parse %u\n", packetbuf_datalen());
        native_rdc_parse_error++;
    } else {
        NETSTACK_MAC.input();
    }
}
Пример #19
0
/*---------------------------------------------------------------------------*/
void
packet_sent(uint8_t sessionid, uint8_t status, uint8_t tx)
{
  if(sessionid < MAX_CALLBACKS) {
    struct tx_callback *callback;

    callback = &callbacks[sessionid];
    packetbuf_clear();
    packetbuf_attr_copyfrom(callback->attrs, callback->addrs);
    mac_call_sent_callback(callback->cback, callback->ptr, status, tx);
  } else {
    LOG6LBR_ERROR("*** ERROR: too high session id %d\n", sessionid);
  }
}
Пример #20
0
void
llsec_wrapper_init(void)
{
  if(nvm_data.security_layer == CETIC_6LBR_SECURITY_LAYER_NONE) {
    LOG6LBR_INFO("Using 'nullsec' llsec driver\n");
    current_llsec_driver = &nullsec_driver;
  } else if(nvm_data.security_layer == CETIC_6LBR_SECURITY_LAYER_NONCORESEC) {
    LOG6LBR_INFO("Using 'noncoresec' llsec driver\n");
    current_llsec_driver = &noncoresec_driver;
  } else {
    LOG6LBR_ERROR("Unknown llsec driver, using 'nullsec' instead\n");
    current_llsec_driver = &nullsec_driver;
  }
}
Пример #21
0
void
nvm_data_write(void)
{
  memcpy(nvm_mem, (uint8_t *) & nvm_data, sizeof(nvm_data));
  LOG6LBR_INFO("Opening nvm file '%s'\n", nvm_file);
  int s = open(nvm_file, O_WRONLY | O_TRUNC | O_CREAT, 0644);

  if(s > 0) {
    write(s, nvm_mem, NVM_SIZE);
    close(s);
  } else {
    LOG6LBR_ERROR("Could not write nvm file\n");
  }
}
Пример #22
0
void
nvm_data_read(void)
{
  int valid = 1;
  LOG6LBR_DEBUG("Opening nvm file '%s'\n", sixlbr_config_nvm_file);
  memset(nvm_mem, 0xff, NVM_SIZE);
  int s = open(sixlbr_config_nvm_file, O_RDONLY);
  if(s > 0) {
    if(read(s, nvm_mem, NVM_SIZE) < 0) {
      LOG6LBR_ERROR("Failed to read NVM");
      valid = 0;
    }
    close(s);
  } else {
    LOG6LBR_ERROR("Could not open nvm file\n");
    valid = 0;
  }
  if(valid) {
    memcpy((uint8_t *) & nvm_data, nvm_mem, sizeof(nvm_data));
  } else {
    nvm_data_reset();
  }
}
Пример #23
0
void
nvm_data_read(void)
{
  LOG6LBR_INFO("Opening nvm file '%s'\n", nvm_file);
  int s = open(nvm_file, O_RDONLY);

  if(s > 0) {
    read(s, nvm_mem, NVM_SIZE);
    close(s);
  } else {
    LOG6LBR_ERROR("Could not read nvm file\n");
    memset(nvm_mem, 0xff, NVM_SIZE);
  }
  memcpy((uint8_t *) & nvm_data, nvm_mem, sizeof(nvm_data));
}
Пример #24
0
void
nvm_data_read(void)
{
  nvmType_t type = 0;
  nvmErr_t err;

  LOG6LBR_INFO("Reading 6LBR NVM\n");
  err = nvm_detect(gNvmInternalInterface_c, &type);
  err =
    nvm_read(gNvmInternalInterface_c, type, (uint8_t *) & nvm_data,
             CETIC_6LBR_NVM_ADDRESS, sizeof(nvm_data_t));
  if (err) {
    LOG6LBR_ERROR("read error : %d\n", err);
  }
}
Пример #25
0
void
plugins_init(void)
{
  sixlbr_plugin_info_t *info = plugins_list_head();
  while(info != NULL) {
    if (info->status == 0 && info->init_status == 0 && info->plugin->init != NULL) {
      LOG6LBR_INFO("Initialising %s\n", info->plugin->id);
      info->init_status = info->plugin->init();
      if (info->init_status != 0) {
        LOG6LBR_ERROR("Initialisation failed, error code is %d\n", info->init_status);
      }
    }
    info = info->next;
  }
}
Пример #26
0
/*---------------------------------------------------------------------------*/
static void
cleanup(void)
{
  if(sixlbr_config_ifdown_script != NULL) {
    if(access(sixlbr_config_ifdown_script, R_OK | X_OK) == 0) {
      LOG6LBR_INFO("Running 6lbr-ifdown script '%s'\n", sixlbr_config_ifdown_script);
      int status = ssystem("%s %s %s 2>&1", sixlbr_config_ifdown_script,
              sixlbr_config_use_raw_ethernet ? "raw" : "tap", sixlbr_config_eth_device);
      if(status != 0) {
        LOG6LBR_ERROR("6lbr-ifdown script returned an error\n");
      }
    } else {
      LOG6LBR_ERROR("Could not access %s : %s\n", sixlbr_config_ifdown_script,
              strerror(errno));
    }
  } else {
    LOG6LBR_INFO("No 6lbr-ifdown script specified\n");
  }
  cetic_6lbr_clear_ip();
#if !CETIC_6LBR_ONE_ITF
  slip_set_mac(&linkaddr_null);
  slip_flushbuf(slipfd);
#endif
}
Пример #27
0
void
mac_wrapper_init(void)
{
  if(nvm_data.mac_layer == CETIC_6LBR_MAC_LAYER_NONE) {
    LOG6LBR_INFO("Using 'nullmac' mac driver\n");
    current_mac_driver = &nullmac_driver;
  } else if(nvm_data.mac_layer == CETIC_6LBR_MAC_LAYER_CSMA) {
    LOG6LBR_INFO("Using 'csma' mac driver\n");
    current_mac_driver = &csma_driver;
  } else {
    LOG6LBR_ERROR("Unknown mac driver, using 'csma' instead\n");
    current_mac_driver = &csma_driver;
    nvm_data.mac_layer = CETIC_6LBR_MAC_LAYER_CSMA;
  }
  current_mac_driver->init();
}
Пример #28
0
/*---------------------------------------------------------------------------*/
void
ifconf(const char *tundev)
{
  if(slip_config_ifup_script != NULL) {
    if(access(slip_config_ifup_script, R_OK | X_OK) == 0) {
      LOG6LBR_INFO("Running 6lbr-ifdown script '%s'\n", slip_config_ifup_script);
      ssystem("%s %s %s 2>&1", slip_config_ifup_script,
              use_raw_ethernet ? "raw" : "tap", slip_config_tundev);
    } else {
      LOG6LBR_ERROR("Could not access %s : %s\n", slip_config_ifup_script,
              strerror(errno));
    }
  } else {
    LOG6LBR_INFO("No 6lbr-down script specified\n");
  }
}
Пример #29
0
void
nvm_data_write(void)
{
  nvmType_t type = 0;
  nvmErr_t err;

  LOG6LBR_INFO("Flashing 6LBR NVM\n");
  mc1322x_config_save(&mc1322x_config);
  err = nvm_detect(gNvmInternalInterface_c, &type);
  err =
    nvm_write(gNvmInternalInterface_c, type, (uint8_t *) & nvm_data,
              CETIC_6LBR_NVM_ADDRESS, sizeof(nvm_data_t));
  if (err) {
    LOG6LBR_ERROR("write error : %d\n", err);
  }
}
Пример #30
0
/*---------------------------------------------------------------------------*/
static void
ifconf(const char *eth_dev)
{
  if(sixlbr_config_ifup_script != NULL) {
    if(access(sixlbr_config_ifup_script, R_OK | X_OK) == 0) {
      LOG6LBR_INFO("Running 6lbr-ifup script '%s'\n", sixlbr_config_ifup_script);
      int status = ssystem("%s %s %s 2>&1", sixlbr_config_ifup_script,
              sixlbr_config_use_raw_ethernet ? "raw" : "tap", sixlbr_config_eth_device);
      if(status != 0) {
        LOG6LBR_FATAL("6lbr-ifup script returned an error, aborting...\n");
        exit(1);
      }
    } else {
      LOG6LBR_ERROR("Could not access %s : %s\n", sixlbr_config_ifup_script,
              strerror(errno));
    }
  } else {
    LOG6LBR_INFO("No 6lbr-up script specified\n");
  }
}