Get mac, ip, subnet, and gateway

How do I retrieve the mac, ip, subnet, and gateway from the W5100 Ethernet shield? I can see you can get it from the W5100.h file but not sure how to go about getting that info back to my sketch. I am not trying to set them I wan't to ask the device what it has set

Any help would be appreciated

The IP addresses are whatever you have them set to in the arduino sketch. The shield itself doesn’t have any settings.

What exactly are you trying to achieve ?

I Would like to ask the device what it has set for the mac, ip, subnet, gateway I know it sounds stupid but I need to know for some info

Two of my shields I believe are losing there info so I need ask it what it has set

You can check the IP address of a running arduino/shield pair connected to a network by using programs such as ping or something like a port scanner running on a computer on the same network. The port scanner should give you an idea if the arduino/shield is responding. It can give you the IP address, Mac and an idea of the subnet, but I don't think it can determine the gateway on its own.

I understand what you are saying but what I would like is the device has a get and set you can retrieve it from the Ethernet shield I just don't know how if you look at the W5100.h file there is code for getting it.

  inline void setGatewayIp(uint8_t *_addr);
  inline void getGatewayIp(uint8_t *_addr);

  inline void setSubnetMask(uint8_t *_addr);
  inline void getSubnetMask(uint8_t *_addr);

  inline void setMACAddress(uint8_t * addr);
  inline void getMACAddress(uint8_t * addr);

  inline void setIPAddress(uint8_t * addr);
  inline void getIPAddress(uint8_t * addr);

If the arduino is losing the settings, how could you trust what the same arduino says the settings are ?.

its not the arduino thats losing the settings somehow the shield gets reset I don't do it but it would be simple to right a few lines to re initialize the shield if it did not have the same ip as was set...

somehow the shield gets reset

Which shield are you using? The Adafruit version brings the Wiznet reset out to a pad. You have to connect a signal to it, or it'll be left open.

The directions recommend connecting it to the Arduino's reset. But, after reading some comments here, I connected it to a spare digital pin, and reset it in software. This allows my code to reset the Wiznet if I get an unrecoverable error on the Ethernet link.

I am using the NKC Ethernet Shield - and I have the reset for the shield connected to a digital pin for control what I wanted to do is just ask the device periodically if it has the correct ip address and etc... vs just waiting for it time out for something its going to be a web host not a client so there is not an easy way to proactively reset the shield without sending data someplace...

A word of warning: the interface for reading/writing the address registers changed significantly from arduino-0017 (which is what I've been using) to 0021 (which I just downloaded). If you use those get*XXXX*() and set*XXXX*() routines, you'll definitely find that people using older versions of the IDE will have problems, and you may find that your code breaks when you download a new version.

Let's say you've defined the Ethernet parameters like this:

uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
uint8_t ip[] = { 192, 168, 1, 64 };
uint8_t gateway[] = { 192, 168, 1, 154 };

Then you could write a routine like this to verify that the parameters haven't been changed on you:

int check_Etherhealth(void)
    uint8_t buf[6];

    if (memcmp(buf, gateway, 4))
        return 1;

    if (memcmp(buf, mac, 6))
        return 2;

    if (memcmp(buf, ip, 4))
        return 3;

    return 0;

You could add other checks if you want: just make sure they return a non-zero on error. Using constants for the return values the way I did above is a poor practice: ideally, the different codes should be given symbolic names using #define or typedef enum, but I'm being lazy ::)