Hello all,
I need help on accounting packets.
I'm sending an accounting request using the sample code in the radclient.c
and my request is silently discarded.
The reason is due to invalid shared secret (from the server log)
Could anyone tell me what am I doing wrong here ?
Thanks
Shauli Lehavi
I'm building the following accounting packet:
lrad_attr_add_int(request, PW_ACCT_STATUS_TYPE, PW_STATUS_START);
lrad_attr_add (request, PW_ACCT_SESSION_ID, "1", strlen ("1"));
slNasIPAddr = inet_addr("XXX.XXX.XXX.XXX");
lrad_attr_add_int (request, PW_NAS_IP_ADDRESS, slNasIPAddr);
// Create the request authenticator
fCreateRequestAuthenticator (request, szMD5Hash, &ulMD5HashLen);
memcpy (request->vector, szMD5Hash, 16);
rcode = lrad_client_send_recv(request, reply, pszServer, "1646", 5);
int fCreateRequestAuthenticator (
AUTH_HDR *request,
char *pszMD5Hash,
unsigned long *pulMD5HashLen)
{
char szRequestAuth [512];
char szZeroes [16];
unsigned long ulOffset = 0;
RADIUS_ATTR *pAttrib;
short swLength;
// Add the authenticator
memset (szZeroes, 0, sizeof (szZeroes));
memcpy (szRequestAuth, &request->code, sizeof (request->code));
ulOffset += sizeof (request->code);
memcpy (szRequestAuth + ulOffset,&request->id, sizeof
(request->id));
ulOffset += sizeof (request->id);
swLength = ntohs (request->length);
memcpy (szRequestAuth + ulOffset,&swLength, sizeof (swLength));
ulOffset += sizeof (request->length);
memcpy (szRequestAuth + ulOffset, szZeroes,16);
ulOffset += 16;
pAttrib = lrad_attr_fetch(request, PW_ACCT_STATUS_TYPE);
memcpy (szRequestAuth + ulOffset,
&pAttrib->attribute,pAttrib->length);
ulOffset += pAttrib->length;
pAttrib = lrad_attr_fetch(request, PW_ACCT_SESSION_ID);
memcpy (szRequestAuth + ulOffset,
&pAttrib->attribute,pAttrib->length);
ulOffset += pAttrib->length;
memcpy (szRequestAuth + ulOffset, "secret", strlen ("secret"));
ulOffset += strlen ("secret");
lrad_md5_calc(pszMD5Hash, szRequestAuth, ulOffset);
*pulMD5HashLen = ulOffset;
return 0;
} // End of function fCreateRequestAuthenticator
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html