usage of "FR_TOKEN op" parameter to pairmake ?

Alan DeKok aland at deployingradius.com
Tue Feb 4 15:47:46 CET 2014


Chaigneau, Nicolas wrote:
> So I tried using "pairmove". But I'm encountering some strange behaviour when combining the operators.

  The behavior of the operators is documented.

> I don't know if it's a weird bug or I'm doing it wrong (probably the latter...)
> 
> What I'm doing:
> 
>       // macro for easier use: 
> 	#define pairmove_reply(_vp, _a, _b, _c) _vp = pairmake(request->reply, NULL, _a, _b, _c); pairmove(request->reply, &(request->reply->vps), &_vp); pairfree(&_vp);

  That marco is not recommended.  You don't check that _vp is NULL.
Also, the second argument to pairmake() is NULL.  Why?  It should be the
destination list.  So there's no need to call pairmove() *after* calling
pairmake().  You should just call pairmake() with a pointer to the list.

> 	VALUE_PAIR *vp_test;
> 	
> 	pairmove_reply(vp_test, "Reply-Message", "Msg1.EQ", T_OP_EQ);
> 	pairmove_reply(vp_test, "Reply-Message", "Msg2.EQ", T_OP_EQ);
> 	pairmove_reply(vp_test, "Reply-Message", "Msg3.SET", T_OP_SET);
> 	pairmove_reply(vp_test, "Reply-Message", "Msg4.ADD", T_OP_ADD);
> 	pairmove_reply(vp_test, "Reply-Message", "Msg5.ADD", T_OP_ADD);
> 
> At the end I expect to obtain three Reply-Message attributes with, respectively: "Msg3.SET", "Msg4.ADD", "Msg5.ADD".
> What I get is:
> 
> rad_recv: Access-Accept packet from host <...> port 1812, id=128, length=143
>         Reply-Message = 'Msg4.ADD'
>         Reply-Message = 'Msg4.ADD'
>         Reply-Message = 'Msg5.ADD'
> 
> (ie, twice "Msg4.ADD").

  That does appear wrong.

> I tried to use "radius_pairmove" instead. I'm not having the same issue with this function.

  Well... that would suggest it's the better function to use.

> Am I doing something wrong with "pairmove" ?

  Maybe, maybe not.

  But your use of the functions / macro above is weird.

  Alan DeKok.


More information about the Freeradius-Devel mailing list