<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.ethernut.de/nutwiki/index.php?action=history&amp;feed=atom&amp;title=Network_Configuration_Using_Stored_Configuration</id>
		<title>Network Configuration Using Stored Configuration - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.ethernut.de/nutwiki/index.php?action=history&amp;feed=atom&amp;title=Network_Configuration_Using_Stored_Configuration"/>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Network_Configuration_Using_Stored_Configuration&amp;action=history"/>
		<updated>2026-04-25T11:03:01Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://www.ethernut.de/nutwiki/index.php?title=Network_Configuration_Using_Stored_Configuration&amp;diff=174&amp;oldid=prev</id>
		<title>Harald: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Network_Configuration_Using_Stored_Configuration&amp;diff=174&amp;oldid=prev"/>
				<updated>2016-10-27T16:02:57Z</updated>
		
		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 16:02, 27 October 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='2' style='text-align: center;' lang='en'&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Harald</name></author>	</entry>

	<entry>
		<id>http://www.ethernut.de/nutwiki/index.php?title=Network_Configuration_Using_Stored_Configuration&amp;diff=173&amp;oldid=prev</id>
		<title>Harald: /* See also */</title>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Network_Configuration_Using_Stored_Configuration&amp;diff=173&amp;oldid=prev"/>
				<updated>2010-04-14T10:13:57Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;See also&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Test Environments ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;smalldiv&amp;quot;&lt;br /&gt;
| style=&amp;quot;background-color:#F6F9ED&amp;quot; |&lt;br /&gt;
| style=&amp;quot;background-color:#F6F9ED&amp;quot; | Hardware&amp;lt;br&amp;gt;Comments&lt;br /&gt;
| style=&amp;quot;background-color:#F6F9ED&amp;quot; | '''Nut/OS&amp;lt;br&amp;gt;4.6.4'''&lt;br /&gt;
| style=&amp;quot;background-color:#F6F9ED&amp;quot; | '''Nut/OS&amp;lt;br&amp;gt;4.7.4'''&lt;br /&gt;
| style=&amp;quot;background-color:#F6F9ED&amp;quot; | '''Nut/OS&amp;lt;br&amp;gt;4.8.0'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;Ethernut 1.3 H&amp;lt;/span&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/network-configuration-stored-enut13H-nutos-4.6.4.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/network-configuration-stored-enut13H-nutos-4.7.4.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/network-configuration-stored-enut13H-nutos-4.8.0.zip '''Binaries''']&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;Ethernut 2.1 B&amp;lt;/span&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/network-configuration-stored-enut21B-nutos-4.6.4.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/network-configuration-stored-enut21B-nutos-4.7.4.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/network-configuration-stored-enut21B-nutos-4.8.0.zip '''Binaries''']&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;Ethernut 3.0 E&amp;lt;/span&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/network-configuration-stored-enut30E-nutos-4.6.4.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/network-configuration-stored-enut30E-nutos-4.7.4.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/network-configuration-stored-enut30E-nutos-4.8.0.zip '''Binaries''']&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;EIR 1.0 C&amp;lt;/span&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
| Configuration&amp;lt;br&amp;gt;Error.&lt;br /&gt;
| Configuration&amp;lt;br&amp;gt;Error.&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/network-configuration-stored-eir1c-nutos-4.8.0.zip '''Binaries''']&lt;br /&gt;
|-&lt;br /&gt;
| id=&amp;quot;compilertd&amp;quot; colspan=&amp;quot;5&amp;quot; |'''Compiler:''' ARM-GCC 4.2.2 ; AVR-GCC 4.3.0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
In most cases the network configuration is stored in non-volatile memory and optionally uses DHCP.&lt;br /&gt;
&lt;br /&gt;
== Source Code ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;dev/board.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/timer.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/confnet.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;io.h&amp;gt;&lt;br /&gt;
#include &amp;lt;arpa/inet.h&amp;gt;&lt;br /&gt;
#include &amp;lt;pro/dhcp.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    u_long baud = 115200;&lt;br /&gt;
&lt;br /&gt;
    /* Assign stdout to the DEBUG device. */&lt;br /&gt;
    NutRegisterDevice(&amp;amp;DEV_DEBUG, 0, 0);&lt;br /&gt;
    freopen(DEV_DEBUG_NAME, &amp;quot;w&amp;quot;, stdout);&lt;br /&gt;
    _ioctl(_fileno(stdout), UART_SETSPEED, &amp;amp;baud);&lt;br /&gt;
    puts(&amp;quot;Network Configuration Sample 2&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* Register Ethernet controller. */&lt;br /&gt;
    if (NutRegisterDevice(&amp;amp;DEV_ETHER, 0, 0)) {&lt;br /&gt;
        puts(&amp;quot;Registering &amp;quot; DEV_ETHER_NAME &amp;quot; failed.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    /* Configure network. */&lt;br /&gt;
    else if (NutDhcpIfConfig(DEV_ETHER_NAME, NULL, 0)) {&lt;br /&gt;
        puts(&amp;quot;Configuring &amp;quot; DEV_ETHER_NAME &amp;quot; failed.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    /* Done. */&lt;br /&gt;
    else {&lt;br /&gt;
        printf(&amp;quot;Now try 'ping %s' on your PC.\n&amp;quot;, inet_ntoa(confnet.cdn_ip_addr));&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    for (;;) {&lt;br /&gt;
        NutSleep(1000);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
if (NutDhcpIfConfig(DEV_ETHER_NAME, NULL, 0)) {&lt;br /&gt;
    puts(&amp;quot;Configuring &amp;quot; DEV_ETHER_NAME &amp;quot; failed.&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead of using NutNetIfConfig we call NutDhcpIfConfig here. This will check the configuration stored in non-volatile memory first. If the IP address is 0.0.0.0, then a DHCP request will be sent out.&lt;br /&gt;
&lt;br /&gt;
If no valid configuration has been previously stored, then this call will fail because of the missing MAC address. As an alternative the MAC address may be provided by the application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
uint8_t mac[6] = { 0x00, 0x06, 0x98, 0x30, 0x02, 0x76 };&lt;br /&gt;
&lt;br /&gt;
if (NutDhcpIfConfig(DEV_ETHER_NAME, mac, 0)) {&lt;br /&gt;
    puts(&amp;quot;Configuring &amp;quot; DEV_ETHER_NAME &amp;quot; failed.&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, the hard coded MAC address may provide problems when running more than one Nut/OS device. A much better solution would be to use a different piece of software, which allows to store a network configuration in non-volatile memory on a virgin device first (see next sample).&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Network Configuration]] Overview&lt;br /&gt;
** [[Network Configuration Using Hard Coded Configuration]]&lt;br /&gt;
** [[Network Configuration Using a Configuration Editor]]&lt;br /&gt;
** [[Discovery Service]]&lt;br /&gt;
* [[Basic TCP Server]]&lt;br /&gt;
* [[Basic TCP Client]]&lt;br /&gt;
* More [[Nut/OS Examples]]&lt;br /&gt;
&lt;br /&gt;
= External Links =&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Mac_address MAC address] A Media Access Control address (MAC address) is a unique identifier assigned to network adapters for identification.&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Ip_address IP address] A numerical identification that is assigned to devices participating in a computer network utilizing the Internet Protocol.&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Dhcp Dynamic Host Configuration Protocol] A protocol used by networked devices to obtain the parameters necessary for operation in an Internet Protocol network.&lt;br /&gt;
&lt;br /&gt;
[[Category:Code Snippets]]&lt;br /&gt;
&lt;br /&gt;
{{Languages}}&lt;/div&gt;</summary>
		<author><name>Harald</name></author>	</entry>

	</feed>