//---------------------------------------------------------------------------- //Trägt Anwendung in Anwendungsliste ein void stack_init (void) { //Timer starten timer_init(); //IP, NETMASK und ROUTER_IP aus EEPROM auslesen (*((unsigned long*)&myip[0])) = get_eeprom_value(IP_EEPROM_STORE,MYIP); (*((unsigned long*)&netmask[0])) = get_eeprom_value(NETMASK_EEPROM_STORE,NETMASK); (*((unsigned long*)&router_ip[0])) = get_eeprom_value(ROUTER_IP_EEPROM_STORE,ROUTER_IP); //MAC Adresse setzen mymac[0] = MYMAC1; mymac[1] = MYMAC2; mymac[2] = MYMAC3; mymac[3] = MYMAC4; mymac[4] = MYMAC5; mymac[5] = MYMAC6; /*NIC Initialisieren*/ DEBUG("\n\rNIC init:"); ETH_INIT(); ETH_PACKET_SEND(60,eth_buffer); ETH_PACKET_SEND(60,eth_buffer); DEBUG("My IP: %1i.%1i.%1i.%1i\r\n\r\n",myip[0],myip[1],myip[2],myip[3]); }
//---------------------------------------------------------------------------- //Trägt Anwendung in Anwendungsliste ein void stack_init (void) { //Timer starten timer_init(); //IP, NETMASK und ROUTER_IP aus EEPROM auslesen (*((unsigned long*)&myip[0])) = get_eeprom_value(IP_EEPROM_STORE,MYIP); (*((unsigned long*)&netmask[0])) = get_eeprom_value(NETMASK_EEPROM_STORE,NETMASK); (*((unsigned long*)&router_ip[0])) = get_eeprom_value(ROUTER_IP_EEPROM_STORE,ROUTER_IP); //Broadcast-Adresse berechnen (*((unsigned long*)&broadcast_ip[0])) = (((*((unsigned long*)&myip[0])) & (*((unsigned long*)&netmask[0]))) | (~(*((unsigned long*)&netmask[0])))); #if USE_DNS //DNS-Server IP aus EEPROM auslesen (*((unsigned long*)&dns_server_ip[0])) = get_eeprom_value(DNS_IP_EEPROM_STORE,DNS_IP); #endif //MAC Adresse setzen mymac[0] = MYMAC1; mymac[1] = MYMAC2; mymac[2] = MYMAC3; mymac[3] = MYMAC4; mymac[4] = MYMAC5; mymac[5] = MYMAC6; /*NIC Initialisieren*/ DEBUG("\n\rNIC init:"); ETH_INIT(); DEBUG("My IP: %1i.%1i.%1i.%1i\r\n\r\n",myip[0],myip[1],myip[2],myip[3]); }
//---------------------------------------------------------------------------- // void wol_init (void) { //Broadcast-Adresse aus EEPROM auslesen, oder default verwenden (*((unsigned long*)&wol_bcast_ip[0])) = get_eeprom_value(WOL_BCAST_EEPROM_STORE,WOL_BCAST_IP); //MAC aus EEPROM auslesen, oder bei default bleiben unsigned char value[6]; for (unsigned char count = 0; count<6;count++) { eeprom_busy_wait (); value[count] = eeprom_read_byte((unsigned char *)(WOL_MAC_EEPROM_STORE + count)); } if ((*((unsigned long*)&value[0])) != 0xFFFFFFFF) { wol_mac[0] = value[0]; wol_mac[1] = value[1]; wol_mac[2] = value[2]; wol_mac[3] = value[3]; wol_mac[4] = value[4]; wol_mac[5] = value[5]; } WOL_DEBUG("** WOL-INIT IP:%1i.%1i.%1i.%1i MAC:0x%2x-0x%2x-0x%2x-0x%2x-0x%2x-0x%2x **\r\n", wol_bcast_ip[0],wol_bcast_ip[1],wol_bcast_ip[2],wol_bcast_ip[3], wol_mac[0],wol_mac[1],wol_mac[2],wol_mac[3],wol_mac[4],wol_mac[5]); }
//------------------------------------------------------------------------------ //print/edit NTP Server IP void command_ntp (void) { #if USE_NTP write_eeprom_ip(NTP_IP_EEPROM_STORE); (*((unsigned long*)&ntp_server_ip[0])) = get_eeprom_value(NTP_IP_EEPROM_STORE,NTP_IP); usart_write("NTP_Server: %1i.%1i.%1i.%1i\r\n",ntp_server_ip[0],ntp_server_ip[1],ntp_server_ip[2],ntp_server_ip[3]); #endif //USE_NTP }
//---------------------------------------------------------------------------- //Eintrag des DNS clients im stack void dns_init (void) { //ADD the DNS port as apllication to the list add_udp_app (DNS_CLIENT_PORT, (void(*)(unsigned char))dns_get); //DNS IP read from EEPROM (*((unsigned long*)&dns_server_ip[0])) = get_eeprom_value(DNS_IP_EEPROM_STORE,DNS_IP); DNS_DEBUG("DNS %1i.%1i.%1i.%1i\r\n",dns_server_ip[0],dns_server_ip[1],dns_server_ip[2],dns_server_ip[3]); return; }
/** * \ingroup tcpcmdcommon * \b Router-Befehl print/edit Router IP */ int16_t command_router (char *outbuffer) { write_eeprom_ip(ROUTER_IP_EEPROM_STORE); (*((unsigned long*)&router_ip[0])) = get_eeprom_value(ROUTER_IP_EEPROM_STORE,ROUTER_IP); if (outbuffer) { sprintf_P(outbuffer,PSTR("250 ok. Router IP: %i.%i.%i.%i\r\n"),router_ip[0],router_ip[1],router_ip[2],router_ip[3]); return strlen(outbuffer); } else { usart_write("Router IP: %1i.%1i.%1i.%1i\r\n",router_ip[0],router_ip[1],router_ip[2],router_ip[3]); return 0; } }
/** * \ingroup tcpcmdcommon * \b Net-Befehl print/edit Netmask */ int16_t command_net (char *outbuffer) { write_eeprom_ip(NETMASK_EEPROM_STORE); (*((unsigned long*)&netmask[0])) = get_eeprom_value(NETMASK_EEPROM_STORE,NETMASK); if (outbuffer) { sprintf_P(outbuffer,PSTR("NETMASK: %i.%i.%i.%i\r\n"),netmask[0],netmask[1],netmask[2],netmask[3]); return strlen(outbuffer); } else { usart_write("NETMASK: %1i.%1i.%1i.%1i\r\n",netmask[0],netmask[1],netmask[2],netmask[3]); return 0; } }
/** * \ingroup tcpcmdcommon * \b IP-Befehl print/edit own IP */ int16_t command_ip (char *outbuffer) { write_eeprom_ip(IP_EEPROM_STORE); (*((unsigned long*)&myip[0])) = get_eeprom_value(IP_EEPROM_STORE,MYIP); if (outbuffer) { sprintf_P(outbuffer,PSTR("My IP: %i.%i.%i.%i\r\n"),myip[0],myip[1],myip[2],myip[3]); return strlen(outbuffer); } else { usart_write("My IP: %1i.%1i.%1i.%1i\r\n",myip[0],myip[1],myip[2],myip[3]); return 0; } }
static void local_mac_address(fcode_env_t *env) { char *mac_str; int mac_value; mac_str = get_eeprom_value(env, "local-mac-address?"); if (mac_str != NULL && strcmp(mac_str, "true") == 0) mac_value = TRUE; else mac_value = FALSE; PUSH(DS, mac_value); }
/** * \ingroup tcpcmdcommon * \b DNS-Befehl IP des DNS-Server anzeigen/setzen * * \b Syntax: DNS [a.b.c.d] */ int16_t cmd_DNS(char *outbuffer) { write_eeprom_ip(DNS_IP_EEPROM_STORE); (*((unsigned long*)&dns_server_ip[0])) = get_eeprom_value(DNS_IP_EEPROM_STORE,DNS_IP); if (outbuffer) { sprintf_P(outbuffer,PSTR("250 ok. DNS IP: %i.%i.%i.%i\r\n"),dns_server_ip[0],dns_server_ip[1],dns_server_ip[2],dns_server_ip[3]); return strlen(outbuffer); } else { usart_write("DNS IP: %1i.%1i.%1i.%1i\r\n",dns_server_ip[0],dns_server_ip[1],dns_server_ip[2],dns_server_ip[3]); dns_reverse_request(IP(192,168,52,200),usart_rx_buffer); return 0; } }
/** * \ingroup tcpcmdcommon * \b NTP-Befehl print/edit NTP Server IP */ int16_t command_ntp (char *outbuffer) { #if USE_NTP write_eeprom_ip(NTP_IP_EEPROM_STORE); (*((unsigned long*)&ntp_server_ip[0])) = get_eeprom_value(NTP_IP_EEPROM_STORE,NTP_IP); if (outbuffer) { sprintf_P(outbuffer,PSTR("NTP_Server: %i.%i.%i.%i\r\n"),ntp_server_ip[0],ntp_server_ip[1],ntp_server_ip[2],ntp_server_ip[3]); return strlen(outbuffer); } else { usart_write("NTP_Server: %1i.%1i.%1i.%1i\r\n",ntp_server_ip[0],ntp_server_ip[1],ntp_server_ip[2],ntp_server_ip[3]); return 0; } #endif //USE_NTP }
/* * 'diagnostic-mode?' - diagnostic-mode? is equivalent to NVRAM 'diag-switch?' */ static void diagnostic_mode(fcode_env_t *env) { char *diag_str; int diag_value; if (!diag_mode_is_valid) { diag_str = get_eeprom_value(env, "diag-switch?"); if (diag_str != NULL && strcmp(diag_str, "false") == 0) diag_value = FALSE; else diag_value = TRUE; PUSH(DS, diag_value); set_diagnostic_mode(env); } push_diagnostic_mode(env); }
//------------------------------------------------------------------------------ //print/edit Router IP void command_router (void) { write_eeprom_ip(ROUTER_IP_EEPROM_STORE); (*((unsigned long*)&router_ip[0])) = get_eeprom_value(ROUTER_IP_EEPROM_STORE,ROUTER_IP); usart_write("Router IP: %1i.%1i.%1i.%1i\r\n",router_ip[0],router_ip[1],router_ip[2],router_ip[3]); }
//------------------------------------------------------------------------------ //print/edit Netmask void command_net (void) { write_eeprom_ip(NETMASK_EEPROM_STORE); (*((unsigned long*)&netmask[0])) = get_eeprom_value(NETMASK_EEPROM_STORE,NETMASK); usart_write("NETMASK: %1i.%1i.%1i.%1i\r\n",netmask[0],netmask[1],netmask[2],netmask[3]); }
//------------------------------------------------------------------------------ //print/edit own IP void command_ip (void) { write_eeprom_ip(IP_EEPROM_STORE); (*((unsigned long*)&myip[0])) = get_eeprom_value(IP_EEPROM_STORE,MYIP); usart_write("My IP: %1i.%1i.%1i.%1i\r\n",myip[0],myip[1],myip[2],myip[3]); }