MCPcopy Create free account
hub / github.com/RangeNetworks/openbts / ipSet

Method ipSet

SIP/SIPUtility.cpp:205–238  ·  view source on GitHub ↗

On success, set the resolved address stuff, mipValid, and return true.

Source from the content-addressed store, hash-verified

203
204// On success, set the resolved address stuff, mipValid, and return true.
205bool IPAddressSpec::ipSet(string addrSpec, const char * provenance)
206{
207 mipName = addrSpec;
208
209 // (pat 7-230-2013) Someone else added this, I am preserving it:
210 // Check for illegal hostname length. 253 bytes for domain name + 6 bytes for port and colon.
211 // This isn't "pretty", but it should be fast, and gives us a ballpark. Their hostname will
212 // fail elsewhere if it is longer than 253 bytes (since this assumes a 5 byte port string).
213 if (addrSpec.size() == 0) {
214 LOG(ALERT) << "hostname is empty from "<<provenance;
215 return false;
216 }
217 if (addrSpec.size() > 259) {
218 LOG(ALERT) << "hostname is greater than 253 bytes from "<<provenance;
219 return false;
220 }
221
222 if (!resolveAddress(&mipSockAddr,addrSpec.c_str())) {
223 LOG(CRIT) << "cannot resolve IP address for " << addrSpec <<" from "<<provenance; // << sbText();
224 return false;
225 }
226
227 { char host[256];
228 const char* ret = inet_ntop(AF_INET,&(mipSockAddr.sin_addr),host,255);
229 if (!ret) {
230 LOG(CRIT) << "cannot translate proxy IP address:" << addrSpec <<" from "<<provenance;;
231 return false;
232 }
233 mipIP = string(host);
234 mipPort = ntohs(mipSockAddr.sin_port);
235 mipValid = true;
236 }
237 return true;
238}
239
240string IPAddressSpec::ipToText() const
241{

Callers 5

updateProxyMethod · 0.80
SipBaseInitMethod · 0.80
saveMOResponseMethod · 0.80
newSendEarlyErrorMethod · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected