MCPcopy Create free account
hub / github.com/Beckhoff/ADS / GetRemoteAddress

Function GetRemoteAddress

AdsLib/AdsLib.cpp:179–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179long GetRemoteAddress(const std::string &remote, AmsNetId &netId)
180{
181 Frame f{ 128 };
182
183 const uint32_t tagCount = 0;
184 f.prepend(htole(tagCount));
185
186 const auto myAddr = AmsAddr{ {}, 0 };
187 f.prepend(&myAddr, sizeof(myAddr));
188
189 const auto status = SendRecv(remote, f, UdpServiceId::SERVERINFO);
190 if (status) {
191 return status;
192 }
193
194 // We expect at least the AmsAddr
195 if (sizeof(netId) > f.capacity()) {
196 LOG_ERROR(__FUNCTION__
197 << "(): frame too short to be AMS response '0x"
198 << std::hex << f.capacity() << "'\n");
199 return ADSERR_DEVICE_INVALIDSIZE;
200 }
201 memcpy(&netId, f.data(), sizeof(netId));
202 return 0;
203}
204}
205}
206

Callers 1

RunNetIdFunction · 0.85

Calls 4

htoleFunction · 0.85
SendRecvFunction · 0.85
capacityMethod · 0.80
dataMethod · 0.80

Tested by

no test coverage detected