Exemplo n.º 1
0
int16_t parse_cmd_gw(char *cmd, char *output, uint16_t len)
{
    uip_ipaddr_t gwaddr;

    while (*cmd == ' ')
	cmd++;

#ifndef DISABLE_IPCONF_SUPPORT
#if (!UIP_CONF_IPV6 || IPV6_STATIC_SUPPORT) && !defined(BOOTP_SUPPORT)

    if (*cmd != '\0') {
        /* try to parse ip */
        if (parse_ip (cmd, &gwaddr))
	    return ECMD_ERR_PARSE_ERROR;

        eeprom_save(gateway, &gwaddr, IPADDR_LEN);
        eeprom_update_chksum();

        return ECMD_FINAL_OK;
    }
    else
#endif /* !UIP_CONF_IPV6 and !BOOTP_SUPPORT */
#endif /* DISABLE_IPCONF_SUPPORT */
    {
        uip_getdraddr(&gwaddr);

        return ECMD_FINAL(print_ipaddr(&gwaddr, output, len));
    }
}
Exemplo n.º 2
0
int16_t parse_cmd_ip(char *cmd, char *output, uint16_t len)
{
    uip_ipaddr_t hostaddr;

    while (*cmd == ' ')
	cmd++;

#ifndef DISABLE_IPCONF_SUPPORT
#if (!defined(IPV6_SUPPORT) && !defined(BOOTP_SUPPORT))		\
  || defined(IPV6_STATIC_SUPPORT)
    if (*cmd != '\0') {
        /* try to parse ip */
        if (parse_ip(cmd, &hostaddr))
	    return ECMD_ERR_PARSE_ERROR;

        eeprom_save(ip, &hostaddr, IPADDR_LEN);
        eeprom_update_chksum();

        return ECMD_FINAL_OK;
    }
    else
#endif /* IPv4-static || IPv6-static || OpenVPN */
#endif /* DISABLE_IPCONF_SUPPORT */
    {
        uip_gethostaddr(&hostaddr);

        return ECMD_FINAL(print_ipaddr(&hostaddr, output, len));
    }
}
Exemplo n.º 3
0
int16_t parse_cmd_netmask(char *cmd, char *output, uint16_t len)
{
    uip_ipaddr_t netmask;

    while (*cmd == ' ')
	cmd++;

#ifndef DISABLE_IPCONF_SUPPORT
#if !UIP_CONF_IPV6 && !defined(BOOTP_SUPPORT)
    if (*cmd != '\0') {
        /* try to parse ip */
        if (parse_ip (cmd, &netmask))
	    return ECMD_ERR_PARSE_ERROR;

        eeprom_save(netmask, &netmask, IPADDR_LEN);
        eeprom_update_chksum();

        return ECMD_FINAL_OK;
    }
    else
#endif /* !UIP_CONF_IPV6 and !BOOTP_SUPPORT */
#endif /* DISABLE_IPCONF_SUPPORT */
    {
        uip_getnetmask(&netmask);

        return ECMD_FINAL(print_ipaddr(&netmask, output, len));
    }
}
Exemplo n.º 4
0
int eeprom_main(int argc, char *argv[])
{
	if (argc >= 2) {
		if (!strcmp(argv[1], "start"))
			eeprom_start();

		if (!strcmp(argv[1], "save_param"))
			eeprom_save(argv[2]);

		if (!strcmp(argv[1], "load_param"))
			eeprom_load(argv[2]);

		if (!strcmp(argv[1], "erase"))
			eeprom_erase();

		if (!strcmp(argv[1], "test"))
			eeprom_test();

		if (0) {	/* these actually require a file on the filesystem... */

			if (!strcmp(argv[1], "reformat"))
				eeprom_ioctl(FIOC_REFORMAT);

			if (!strcmp(argv[1], "repack"))
				eeprom_ioctl(FIOC_OPTIMIZE);
		}
	}

	errx(1, "expected a command, try 'start'\n\t'save_param /eeprom/parameters'\n\t'load_param /eeprom/parameters'\n\t'erase'\n");
}
Exemplo n.º 5
0
static NVRAM_HANDLER( policetr )
{
	if (read_or_write)
		eeprom_save(file);
	else
	{
		eeprom_init(machine, &eeprom_interface_policetr);
		if (file)	eeprom_load(file);
	}
}
Exemplo n.º 6
0
int16_t parse_cmd_pass (char *cmd, char *output, uint16_t len)
{
	
	while (*cmd == ' ')
	cmd++;

    if (*cmd != '\0') {
		memset(sms77_pass, 0, SMS77_VALUESIZE);
		memcpy(sms77_pass, cmd, SMS77_VALUESIZE);
		eeprom_save(sms77_password, cmd, strlen(cmd));
		eeprom_update_chksum();
		return ECMD_FINAL_OK;
    }
    else {
		return ECMD_FINAL(snprintf_P(output, len, PSTR("%s"), sms77_pass));
    }	
}
Exemplo n.º 7
0
int16_t parse_cmd_user (char *cmd, char *output, uint16_t len)
{
	SMSDEBUG ("username\n");
	while (*cmd == ' ')
	cmd++;

    if (*cmd != '\0') {
		memset(sms77_user, 0, SMS77_VALUESIZE);
		memcpy(sms77_user, cmd, SMS77_VALUESIZE);
		eeprom_save(sms77_username, cmd, strlen(cmd));
		eeprom_update_chksum();
		SMSDEBUG ("set new : %s\n",cmd);
		return ECMD_FINAL_OK;
    }
    else {
    	SMSDEBUG ("get current : %s\n ",sms77_user);
		return ECMD_FINAL(snprintf_P(output, len, PSTR("%s"), sms77_user));
    }	
}
Exemplo n.º 8
0
int16_t parse_cmd_dns_server(char *cmd, char *output, uint16_t len)
{
    uip_ipaddr_t dnsaddr;

    while (*cmd == ' ')
	cmd++;

    if (*cmd != '\0') {
	/* try to parse ip */
	if (parse_ip(cmd, &dnsaddr))
	    return ECMD_ERR_PARSE_ERROR;

	resolv_conf(&dnsaddr);

	eeprom_save(dns_server, &dnsaddr, IPADDR_LEN);
	eeprom_update_chksum();
	return ECMD_FINAL_OK;
    }
    else {
	return ECMD_FINAL(print_ipaddr(resolv_getserver(), output, len));
    }
}
Exemplo n.º 9
0
void
eeprom_init (void)
{
  uip_ipaddr_t ip;
  (void) ip;			/* Keep GCC quiet. */

#ifdef ETHERNET_SUPPORT
  eeprom_save_P (mac, PSTR (CONF_ETHERSEX_MAC), 6);
#endif

#if (defined(IPV4_SUPPORT) && !defined(BOOTP_SUPPORT) && !defined(DHCP_SUPPORT)) || defined(IPV6_STATIC_SUPPORT)
  set_CONF_ETHERSEX_IP (&ip);
  eeprom_save (ip, &ip, IPADDR_LEN);
#ifdef ETHERNET_SUPPORT
  set_CONF_ETHERSEX_GATEWAY (&ip);
  eeprom_save (gateway, &ip, IPADDR_LEN);
#endif

#ifdef IPV4_SUPPORT
  set_CONF_ETHERSEX_IP4_NETMASK (&ip);
  eeprom_save (netmask, &ip, IPADDR_LEN);
#endif
#endif

#ifdef DNS_SUPPORT
  set_CONF_DNS_SERVER (&ip);
  eeprom_save (dns_server, &ip, IPADDR_LEN);
#endif

#ifdef PAM_SINGLE_USER_EEPROM_SUPPORT
  /* Copy the httpd's password. */
  eeprom_save_P (pam_username, PSTR (PAM_SINGLE_USERNAME), 16);
  eeprom_save_P (pam_password, PSTR (PAM_SINGLE_PASSWORD), 16);
#endif

#ifdef ADC_VOLTAGE_SUPPORT
  eeprom_save_int (adc_vref, ADC_REF_VOLTAGE);
#endif

#ifdef KTY_SUPPORT
  eeprom_save_char (kty_calibration, 0);
#endif

#ifdef MQ2_SUPPORT
  eeprom_save_long (mq2_calibration, 0);
#endif

#ifdef MQ135_SUPPORT
  eeprom_save_long (mq135_calibration, 0);
#endif

#ifdef STELLA_EEPROM
  uint8_t stella_temp[10] = { 0 };
  eeprom_save (stella_channel_values, stella_temp, 10);
#endif

#ifdef DMX_FXSLOT_SUPPORT
  struct fxslot_struct_stripped fxslots_temp[DMX_FXSLOT_AMOUNT] = { {0,0,0,0,0,0,0} };
  eeprom_save (dmx_fxslots, fxslots_temp, DMX_FXSLOT_AMOUNT*sizeof(struct fxslot_struct_stripped));
#endif

#ifdef ONEWIRE_NAMING_SUPPORT
  ow_name_t temp_name;
  memset(&temp_name, 0, sizeof(ow_name_t));
  for (int8_t i = 0; i < OW_SENSORS_COUNT; i++)
  {
    eeprom_save(ow_names[i], &temp_name, sizeof(ow_name_t));
  }
#endif

#ifdef SMS77_EEPROM_SUPPORT
  eeprom_save_P (sms77_username, PSTR (CONF_SMS77_USER), SMS77_VALUESIZE);
  eeprom_save_P (sms77_password, PSTR (CONF_SMS77_PASS), SMS77_VALUESIZE);
  eeprom_save_P (sms77_receiver, PSTR (CONF_SMS77_TO), SMS77_VALUESIZE);
  eeprom_save_P (sms77_type, PSTR (CONF_SMS77_TYPE), SMS77_VALUESIZE);
#endif

#ifdef JABBER_EEPROM_SUPPORT
  eeprom_save_P (jabber_username, PSTR (CONF_JABBER_USERNAME),
		 JABBER_VALUESIZE);
  eeprom_save_P (jabber_password, PSTR (CONF_JABBER_PASSWORD),
		 JABBER_VALUESIZE);
  eeprom_save_P (jabber_resource, PSTR (CONF_JABBER_RESOURCE),
		 JABBER_VALUESIZE);
  eeprom_save_P (jabber_hostname, PSTR (CONF_JABBER_HOSTNAME),
		 JABBER_VALUESIZE);
#endif

#ifdef MOTD_SUPPORT
  eeprom_save_P (motd_text, PSTR (CONF_MOTD_DEFAULT), MOTD_VALUESIZE);
#endif

#ifdef CRON_EEPROM_SUPPORT
  uint8_t count = 0;
  eeprom_save_offset(crontab, 0, &count, sizeof(count));
#endif

#ifdef TANKLEVEL_SUPPORT
  tanklevel_params_t tanklevel_temp = {
    .sensor_offset = TANKLEVEL_SENSOR_OFFSET,
    .med_density = TANKLEVEL_MED_DENSITY,
    .ltr_per_m = TANKLEVEL_LTR_PER_M,
    .ltr_full = TANKLEVEL_LTR_FULL,
    .raise_time = TANKLEVEL_RAISE_TIME,
    .hold_time = TANKLEVEL_HOLD_TIME
  };
  eeprom_save (tanklevel_params, &tanklevel_temp, sizeof(tanklevel_params_t));
#endif
  eeprom_update_chksum ();
}
Exemplo n.º 10
0
void
eeprom_init (void)
{
  uip_ipaddr_t ip;
  (void) ip;			/* Keep GCC quiet. */

#ifdef ETHERNET_SUPPORT
  eeprom_save_P (mac, PSTR (CONF_ETHERRAPE_MAC), 6);
#endif

#if (defined(IPV4_SUPPORT) && !defined(BOOTP_SUPPORT) && !defined(DHCP_SUPPORT)) || defined(IPV6_STATIC_SUPPORT)
  set_CONF_ETHERRAPE_IP (&ip);
  eeprom_save (ip, &ip, IPADDR_LEN);
#ifdef ETHERNET_SUPPORT
  set_CONF_ETHERRAPE_GATEWAY (&ip);
  eeprom_save (gateway, &ip, IPADDR_LEN);
#endif

#ifdef IPV4_SUPPORT
  set_CONF_ETHERRAPE_IP4_NETMASK (&ip);
  eeprom_save (netmask, &ip, IPADDR_LEN);
#endif
#endif

#ifdef DNS_SUPPORT
  set_CONF_DNS_SERVER (&ip);
  eeprom_save (dns_server, &ip, IPADDR_LEN);
#endif

#ifdef PAM_SINGLE_USER_EEPROM_SUPPORT
  /* Copy the httpd's password. */
  eeprom_save_P (pam_username, PSTR (PAM_SINGLE_USERNAME), 16);
  eeprom_save_P (pam_password, PSTR (PAM_SINGLE_PASSWORD), 16);
#endif

#ifdef KTY_SUPPORT
  eeprom_save_char (kty_calibration, 0);
#endif

#ifdef STELLA_EEPROM
  uint8_t stella_temp[10] = { 0 };
  eeprom_save (stella_channel_values, stella_temp, 10);
#endif

#ifdef DMX_FXSLOT_SUPPORT
  struct fxslot_struct_stripped fxslots_temp[DMX_FXSLOT_AMOUNT] = { {0,0,0,0,0,0,0} };
  eeprom_save (dmx_fxslots, fxslots_temp, DMX_FXSLOT_AMOUNT*sizeof(struct fxslot_struct_stripped));
#endif

#ifdef SMS77_EEPROM_SUPPORT
  eeprom_save_P (sms77_username, PSTR (CONF_SMS77_USER), SMS77_VALUESIZE);
  eeprom_save_P (sms77_password, PSTR (CONF_SMS77_PASS), SMS77_VALUESIZE);
  eeprom_save_P (sms77_receiver, PSTR (CONF_SMS77_TO), SMS77_VALUESIZE);
  eeprom_save_P (sms77_type, PSTR (CONF_SMS77_TYPE), SMS77_VALUESIZE);
#endif

#ifdef JABBER_EEPROM_SUPPORT
  eeprom_save_P (jabber_username, PSTR (CONF_JABBER_USERNAME),
		 JABBER_VALUESIZE);
  eeprom_save_P (jabber_password, PSTR (CONF_JABBER_PASSWORD),
		 JABBER_VALUESIZE);
  eeprom_save_P (jabber_resource, PSTR (CONF_JABBER_RESOURCE),
		 JABBER_VALUESIZE);
  eeprom_save_P (jabber_hostname, PSTR (CONF_JABBER_HOSTNAME),
		 JABBER_VALUESIZE);
#endif

#ifdef MOTD_SUPPORT
  eeprom_save_P (motd_text, PSTR (CONF_MOTD_DEFAULT), MOTD_VALUESIZE);
#endif
  eeprom_update_chksum ();
}
Exemplo n.º 11
0
void
bootp_handle_reply(void)
{
    int i;
    struct bootp *pk = uip_appdata;

    if(pk->bp_op != BOOTREPLY)
	return;					/* ugh? shouldn't happen */

    if(pk->bp_htype != HTYPE_ETHERNET)
	return;

    for(i = 0; i < 4; i ++) {
	if(pk->bp_xid[i] != uip_udp_conn->appstate.bootp.xid[i])
	    return;				/* session id doesn't match */

	if(pk->bp_vend[i] != replycookie[i])
	    return;				/* reply cookie doesn't match */
    }


    /*
     * looks like we have received a valid bootp reply,
     * prepare to override eeprom configuration
     */
    uip_ipaddr_t ips[5];
    memset(&ips, 0, sizeof(ips));

    /* extract our ip addresses, subnet-mask and gateway ... */
    memcpy(&ips[0], pk->bp_yiaddr, 4);
    uip_sethostaddr(&ips[0]);

    debug_printf ("BOOTP: configured new ip address %d.%d.%d.%d\n",
                  ((unsigned char *) ips)[0], ((unsigned char *) ips)[1],
                  ((unsigned char *) ips)[2], ((unsigned char *) ips)[3]);

    unsigned char *ptr = pk->bp_vend + 4;
    while(*ptr != 0xFF) {
	switch(* ptr) {
	case TAG_SUBNET_MASK:
	    memcpy(&ips[1], &ptr[2], 4);
	    uip_setnetmask(&ips[1]);
	    break;

	case TAG_GATEWAY:
	    memcpy(&ips[2], &ptr[2], 4);
	    uip_setdraddr(&ips[2]);
	    break;
#ifdef DNS_SUPPORT
        case TAG_DOMAIN_SERVER:
	    memcpy(&ips[3], &ptr[2], 4);
            resolv_conf(&ips[3]);
            break;
#endif
#ifdef NTP_SUPPORT
        case TAG_NTP_SERVER:
            /* This will set the ntp connection to the server set by the bootp
             * request
             */
	    memcpy(&ips[4], &ptr[2], 4);
            ntp_conf(&ips[4]);
            break;
#endif
	}

	ptr = ptr + ptr[1] + 2;
    }

    /* Remove the bootp connection */
    uip_udp_remove(uip_udp_conn);

#ifdef BOOTP_TO_EEPROM_SUPPORT
    eeprom_save(ip, &ips[0], IPADDR_LEN);
    eeprom_save(netmask, &ips[1], IPADDR_LEN);
    eeprom_save(gateway, &ips[2], IPADDR_LEN);
#ifdef DNS_SUPPORT
    eeprom_save(dns_server, &ips[3], IPADDR_LEN);
#endif
#ifdef NTP_SUPPORT
    eeprom_save(ntp_server, &ips[4], IPADDR_LEN);
#endif
#endif /* BOOTP_TO_EEPROM_SUPPORT */

#ifdef DYNDNS_SUPPORT
    dyndns_update();
#endif

#if defined(TFTP_SUPPORT) && defined(BOOTLOADER_SUPPORT)
    if(pk->bp_file[0] == 0)
	return;					/* no boot filename provided */

    debug_putstr("load:");
    debug_putstr(pk->bp_file);
    debug_putchar('\n');

    /* create tftp connection, which will fire the download request */
    uip_ipaddr_t ip;
    uip_ipaddr(&ip, pk->bp_siaddr[0], pk->bp_siaddr[1],
	       pk->bp_siaddr[2], pk->bp_siaddr[3]);

    tftp_fire_tftpomatic(&ip, pk->bp_file);
#endif /* TFTP_SUPPORT */
}
Exemplo n.º 12
0
void
stella_storeToEEROM(void)
{
  eeprom_save(stella_channel_values, stella_brightness, STELLA_CHANNELS);
  eeprom_update_chksum();
}
Exemplo n.º 13
0
void
stella_storeToEEROM()
{
	eeprom_save(stella_channel_values, stella_brightness, 8);
}
Exemplo n.º 14
0
int8_t
solometer_parse (char* ptr)
{
  char *str,*ptr1,c,*buf;
#ifdef DNS_SUPPORT
  uip_ipaddr_t dnsserver;
#endif
  int n;
  int16_t *int1_p,*int2_p,*int3_p,*int4_p;

  //buf=(char*)malloc(24);
  if(!(buf=(char*)malloc(24))) {
    //debug_printf("smt_parse: Not enough memory!\n");
    return -1;
  }
  
  int1_p = (int16_t*)(buf+16);
  int2_p = (int16_t*)(buf+18);
  int3_p = (int16_t*)(buf+20);
  int4_p = (int16_t*)(buf+22);

  ptr1 = strchr (ptr, ' ');
  if (ptr1 == NULL) {
    //debug_printf ("smt_parse: space after filename not found.\n");
    return -1;
  }

  /* Make a copy of the parameter string */
  c = *ptr1;
  *ptr1 = 0;
  if(!(str = malloc(strlen(ptr) + 1))) {
    //debug_printf("smt_parse: Not enough memory. Exiting.\n");
    *ptr1 = c;
    return -1;
  }
  ptr = strcpy(str,ptr);
  *ptr1 = c;

  urldecode(ptr);
  //debug_printf("String to parse: --%s--\n",ptr);

  if(get_string(ptr,PSTR("WRID="),buf,3)) {
    WRID[0] = (uint8_t)atoi(buf);
    eeprom_save(solometer_WRID, &WRID[0], 1);
    eeprom_update_chksum();
  }
  //debug_printf("Ausgewertet:WRID=--%u--\n",WRID[0]);

  if(get_string(ptr,PSTR("PVID="),post_cookie,11)) {
    eeprom_save(solometer_cookie, post_cookie, strlen(post_cookie) + 1);
    eeprom_update_chksum();
  }
  //debug_printf("Ausgewertet:PVID=--%s--\n",post_cookie);

  if(get_string(ptr,PSTR("HST="),post_hostname,64)) {
    eeprom_save(solometer_host, post_hostname, strlen(post_hostname) + 1);
    eeprom_update_chksum();
  }
  //debug_printf("Ausgewertet:HST=--%s--\n",post_hostname);

  if(get_string(ptr,PSTR("SCR="),post_scriptname,64)) {
    eeprom_save(solometer_script, post_scriptname, strlen(post_scriptname) + 1);
    eeprom_update_chksum();
  }
  //debug_printf("Ausgewertet:SCRPT=--%s--\n",post_scriptname);

  if(get_string(ptr,PSTR("HIP="),buf,16)) {
    n = sscanf(buf,"%d.%d.%d.%d",int1_p,int2_p,int3_p,int4_p);
    if(n == 4) {
      //debug_printf("Setting Host IP: %d %d %d %d\n",*int1_p,*int2_p,*int3_p,*int4_p);
      uip_ipaddr(&post_hostip,*int1_p,*int2_p,*int3_p,*int4_p);
      eeprom_save(solometer_hostip, post_hostip, sizeof(uip_ipaddr_t));
      eeprom_update_chksum();
      memset(buf,0,16);
      print_ipaddr(&post_hostip,buf,16);
      buf[15]=0;
    } else {
      //debug_printf("Not setting Host IP (n != 4).\n");
      buf[0] = 0;
    }
  } else {
    buf[0] = 0;
  }
  //debug_printf("Ausgewertet:HIP=--%s--\n",buf);

#ifdef DNS_SUPPORT
  if(get_string(ptr,PSTR("DNS="),buf,16)) {
    n = sscanf(buf,"%d.%d.%d.%d",int1_p,int2_p,int3_p,int4_p);
    if(n == 4) {
      //debug_printf("Setting DNS server IP\n");
      uip_ipaddr(&dnsserver,*int1_p,*int2_p,*int3_p,*int4_p);
      eeprom_save(dns_server, &dnsserver, sizeof(uip_ipaddr_t));
      eeprom_update_chksum();
      resolv_conf(&dnsserver);
      memset(buf,0,16);
      print_ipaddr(&dnsserver,buf,16);
      buf[15]=0;
    } else {
      //debug_printf("Not setting DNS server IP (n <> 4).\n");
      buf[0] = 0;
    }
  } else {
    buf[0] = 0;
  }
  //debug_printf("Ausgewertet:DNS=--%s--\n",buf);
#endif

  free(ptr);
  free(buf);
  return 0;
}