STRUCT into EEPROM lib

i have been using EEPROM to store my ethrent shield ip, mac and gateway.

like this

//this codes are for writing and reaeding from EEPROM the ip, mac and gateway data

//EEPROM MAC and IP setter
//http://arduino.cc/playground/Code/EEPROMWriteAnything

#include <EEPROM.h>
#include <avr/eeprom.h>


//http://arduino.cc/forum/index.php/topic,64673.0.html

// these values are saved in EEPROM

struct NET_t
{
  byte   MAC[6]; 
  byte   IP[4];   
  byte   GATE[4];
  short  myPort;             // should be an uint16_t myPort  !!! range = 0..65535
  short  serverPort;        // idem
} 
LAN =
{
  {0xDE, 0xAD, 0xDE, 0xEF, 0x00, 0x03} //change last bit
  ,
  {10,0,0,13} // change ip
  ,
  {10,0,0,1}
  ,
  6666
  ,
  9999
};


void setup(){
  eeprom_write_block((const void*)&LAN, (void*)0, sizeof(LAN)); //write
  //eeprom_read_block((void*)&LAN, (void*)0, sizeof(LAN)); //read
}

void loop(){

}

i would like to use the EEPROM lib instead
anything nicer then this to store it all?

/*
 * EEPROM Write
 *
 * Stores values read from analog input 0 into the EEPROM.
 * These values will stay in the EEPROM when the board is
 * turned off and may be retrieved later by another sketch.
 */

#include <EEPROM.h>

// the current address in the EEPROM (i.e. which byte
// we're going to write to next)
int addr = 0;

struct NET_t
{
  byte   MAC[6]; 
  byte   IP[4];   
  byte   GATE[4];
  short  myPort;             // should be an uint16_t myPort  !!! range = 0..65535
  short  serverPort;        // idem
} 
LAN =
{
  {
    0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x03  } //change last bit
  ,
  {
    10,0,0,13  } // change ip
  ,
  {
    10,0,0,1  }
  ,
  6666
    ,
  9999
};

void setup()
{
}

void loop()
{
  for(int i=0;i<6;i++){
    EEPROM.write(addr,LAN.MAC[i] );
    addr++;
  }
  for(int i=0;i<4;i++){
    EEPROM.write(addr,LAN.IP[i] );
    addr++;
  }
  // advance to the next address.  there are 512 bytes in 
  // the EEPROM, so go back to 0 when we hit 512.
  if (addr == 512)
    addr = 0;

  delay(100);
}

the eeprom_write_block looks nicer to me. also, you can use the read function to verify if anything needs to be written.

If you save the values in code, store the data in PROGMEM, EEPROM is more for settings and data changed during run-time( not DHCP, as this could change anytime ).

your second style with the loops, writes to the same place with LAN.MAC, then LAN.IP