"getIP()" makes no sense, since it would only make sense to call it once, thus it is not needed. In order to do what you want, you should pass the instance of "IPAddress" as an argument to "getIP" or return the numeric value representing the IP:
//As argument
void getIP1(IPAddress &ipa)
{
byte byteArray[4]={0,1,2,3};
ipa = IPAddress(byteArray[0], byteArray[1], byteArray[2], byteArray[3]);
sp("ip in callee is "); spln(ipa);
}
//Numeric value
uint32_t getIP2(){
byte byteArray[4]={4,5,6,7};
IPAddress ip (byteArray[0], byteArray[1], byteArray[2], byteArray[3]);
sp("ip in callee is "); spln(ip);
return ip;
}
void setup() {
Serial.begin(38400);
IPAddress myIP;
getIP1(myIP);
sp("returned ip is ");spln(myIP);
myIP = getIP2();
sp("returned ip is ");spln(myIP);
}