After you added
__GP_REGISTER_N(RIPR, 0x000C, 4); // Remote IP address
to the public section of W5100Class you already are able to access the IP address via W5100.readRIPR(). Just add a place to store the IP and call the function at the proper moment
#include <Ethernet.h>
#include <utility/w5100.h>
...
uint8_t remoteIP[4];
...
W5100.readRIPR(remoteIP);
I'm using Arduino v1.0 and the used defines in W5100.h manage all you need - only the single line you figured out and an additional include to access the W5100 (exported global object) are necessary. Testing of the code is now up to you.
Explanation of the define:
#define __GP_REGISTER_N(name, address, size) \
static uint16_t write##name(uint8_t *_buff) { \
return write(address, _buff, size); \
} \
static uint16_t read##name(uint8_t *_buff) { \
return read(address, _buff, size); \
}
this one does the trick.
The preprocessor expands the following two lines
__GP_REGISTER_N(RIPR, 0x000C, 4); // Remote IP address
__GP_REGISTER_N(SIPR, 0x000F, 4); // Source IP address
into the following code before compiling
static uint16_t writeRIPR(uint8_t *_buff) {
return write(0x000C, _buff, 4);
}
static uint16_t readRIPR(uint8_t *_buff) {
return read(0x000C, _buff, 4);
}
static uint16_t writeSIPR(uint8_t *_buff) {
return write(0x000F, _buff, 4);
}
static uint16_t readSIPR(uint8_t *_buff) {
return read(0x000F, _buff, 4);
}