-while (rad->nonstop)
- {
- if (!rad->WaitPackets(rad->sock))
- {
- continue;
- }
- struct sockaddr_in outerAddr;
- if (rad->RecvData(&packet, &outerAddr))
- {
- printfd(__FILE__, "RADIUS::Run Error on RecvData\n");
- }
- else
- {
- if (rad->ProcessData(&packet))
- {
- packet.packetType = RAD_REJECT_PACKET;
- }
- rad->Send(packet, &outerAddr);
- }
- }
-
-rad->isRunning = false;
-
-return NULL;
-}
-//-----------------------------------------------------------------------------
-int RADIUS::RecvData(RAD_PACKET * packet, struct sockaddr_in * outerAddr)
-{
- int8_t buf[RAD_MAX_PACKET_LEN];
- socklen_t outerAddrLen = sizeof(struct sockaddr_in);
- int dataLen = recvfrom(sock, buf, RAD_MAX_PACKET_LEN, 0, reinterpret_cast<struct sockaddr *>(outerAddr), &outerAddrLen);
- if (dataLen > 0) {
- Decrypt(&ctx, (char *)packet, (const char *)buf, dataLen / 8);
- }
- if (strncmp((char *)packet->magic, RAD_ID, RAD_MAGIC_LEN))
- {
- printfd(__FILE__, "RADIUS::RecvData Error magic. Wanted: '%s', got: '%s'\n", RAD_ID, packet->magic);
- return -1;
- }
- return 0;
-}
-//-----------------------------------------------------------------------------
-int RADIUS::Send(const RAD_PACKET & packet, struct sockaddr_in * outerAddr)
-{
-size_t len = sizeof(RAD_PACKET);
-char buf[1032];
-
-Encrypt(&ctx, buf, (char *)&packet, len / 8);
-return sendto(sock, buf, len, 0, reinterpret_cast<struct sockaddr *>(outerAddr), sizeof(struct sockaddr_in));
-}
-//-----------------------------------------------------------------------------
-int RADIUS::ProcessData(RAD_PACKET * packet)
-{
-if (strncmp((const char *)packet->protoVer, "01", 2))
- {
- printfd(__FILE__, "RADIUS::ProcessData packet.protoVer incorrect\n");