This is how. Change testIP to another ip. It will not match.
#include <SPI.h>
#include <Ethernet.h>
IPAddress clientIP(192,168,2,2);
IPAddress testIP(192,168,2,2);
void setup() {
Serial.begin(9600);
if(clientIP == testIP) Serial.println("match");
else Serial.println("no match");
if(clientIP[0] == testIP[0] && clientIP[1] == testIP[1] && clientIP[2] == testIP[2]) {
Serial.println("Same subnet");
}
else Serial.println("different subnets");
}
void loop() {
}
Here is a firewall-type code using the array of IPAddress types. See reply #1.
http://arduino.cc/forum/index.php/topic,135082.0.html
edit: Here is the way I have this planned. One ip changes, the subnet views, and all others are rejected.
if(clientIP == testIP) {
Serial.println("match");
// get input from the GET, process, and send page with form inputs here
}
else if(clientIP[0] == testIP[0] && clientIP[1] == testIP[1] && clientIP[2] == testIP[2]) {
Serial.println("Same subnet");
// do not get input. send page with data, but no form
}
else {
Serial.println("different subnets");
// send 401 Unauthorized page
}