MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / Inet_AtoN

Function Inet_AtoN

opt_utils/apps/ros2udp_converter.cpp:279–297  ·  view source on GitHub ↗

convert a string represenation of an IP address into its numeric equivalent

Source from the content-addressed store, hash-verified

277typedef unsigned long uint32;
278// convert a string represenation of an IP address into its numeric equivalent
279static uint32 Inet_AtoN(const char * buf)
280{
281
282 uint32 ret = 0;
283 int shift = 24; // fill out the MSB first
284 bool startQuad = true;
285 while((shift >= 0)&&(*buf))
286 {
287 if (startQuad)
288 {
289 unsigned char quad = (unsigned char) atoi(buf);
290 ret |= (((uint32)quad) << shift);
291 shift -= 8;
292 }
293 startQuad = (*buf == '.');
294 buf++;
295 }
296 return ret;
297}
298
299int
300main(int argc, char **argv)

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected