<?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_Hard_Coded_Configuration</id>
		<title>Network Configuration Using Hard Coded 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_Hard_Coded_Configuration"/>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Network_Configuration_Using_Hard_Coded_Configuration&amp;action=history"/>
		<updated>2026-04-18T19:46:24Z</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_Hard_Coded_Configuration&amp;diff=172&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_Hard_Coded_Configuration&amp;diff=172&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_Hard_Coded_Configuration&amp;diff=171&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_Hard_Coded_Configuration&amp;diff=171&amp;oldid=prev"/>
				<updated>2010-04-14T10:14:33Z</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-hard-coded-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-hard-coded-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-hard-coded-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-hard-coded-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-hard-coded-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-hard-coded-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-hard-coded-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-hard-coded-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-hard-coded-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-hard-coded-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;
The most simple way is to use hard coded configuration values in your application. This will work for any environment, but changing the configuration requires to re-compile the code.&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;
&lt;br /&gt;
#include &amp;lt;stdint.h&amp;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;
&lt;br /&gt;
/* Hard coded network configuration. */&lt;br /&gt;
#define MY_MAC  { 0x00, 0x06, 0x98, 0x30, 0x02, 0x76 }&lt;br /&gt;
#define MY_IP   &amp;quot;192.168.192.111&amp;quot;&lt;br /&gt;
#define MY_MASK &amp;quot;255.255.255.0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    u_long baud = 115200;&lt;br /&gt;
    uint8_t mac[6] = MY_MAC;&lt;br /&gt;
    uint32_t ip_addr = inet_addr(MY_IP);&lt;br /&gt;
    uint32_t ip_mask = inet_addr(MY_MASK);&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 1&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 (NutNetIfConfig(DEV_ETHER_NAME, mac, ip_addr, ip_mask)) {&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;
        puts(&amp;quot;Now try 'ping &amp;quot; MY_IP &amp;quot;' on your PC.&amp;quot;);&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;
We use pre-processor macros to define the configuration values. They are located on top of the code, directly following the header includes. This makes it easier to find them for later modification.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#define MY_MAC  { 0x00, 0x06, 0x98, 0x30, 0x02, 0x76 }&lt;br /&gt;
#define MY_IP   &amp;quot;192.168.192.111&amp;quot;&lt;br /&gt;
#define MY_MASK &amp;quot;255.255.255.0&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before configuring the network interface, we must first register the device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&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;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally the network interface is configured by calling NutNetIfConfig. When this function returns 0, then the interface is up and running.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
if (NutNetIfConfig(DEV_ETHER_NAME, mac, ip_addr, ip_mask)) {&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;
We can now use ping from any PC in our network to check the configuration.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Network Configuration]] Overview&lt;br /&gt;
** [[Network Configuration Using Stored 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>