Radclient : received bad packet

classic Classic list List threaded Threaded
5 messages Options
| Threaded
Open this post in threaded view
|

Radclient : received bad packet

Arvind Chauhan
I am new in freeradius.
I am generating DM-request Package from Radius server side with below
mention command Acct-Session-ID and NAS-IP_address taken as random value
for testing:
echo "User-Name=arv,Acct-Session-Id=12354679, NAS-IP_Address=1.1.1.1"|
radclient 1.1.1.1:3799 disconnect testing123

code::

Attached with mail

Error:

radclient: received bad packet

# What is causing this problem and how we can solve this problem?

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

coa_dm_sample.c (5K) Download Attachment
| Threaded
Open this post in threaded view
|

Re: Radclient : received bad packet

Alan DeKok-2
On Oct 5, 2019, at 6:43 AM, Arvind Chauhan <[hidden email]> wrote:

>
> I am new in freeradius.
> I am generating DM-request Package from Radius server side with below
> mention command Acct-Session-ID and NAS-IP_address taken as random value
> for testing:
> echo "User-Name=arv,Acct-Session-Id=12354679, NAS-IP_Address=1.1.1.1"|
> radclient 1.1.1.1:3799 disconnect testing123
>
> code::
>
> Attached with mail
>
> Error:
>
> radclient: received bad packet
>
> # What is causing this problem and how we can solve this problem?

  Print the actual error message:

                printf( "radclient: received bad packet: %s\n",strerror(errno));

  This is wrong.  You should use fr_strerror(), which returns a descriptive message.  strerror() is for getting errors from system calls / system libraries.  We use our own error wrapper.

  Alan DeKok.


-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
| Threaded
Open this post in threaded view
|

Re: Radclient : received bad packet

Arvind Chauhan
with fr_strerror(), I m getting unknown error.
radclient: received bad packet: (unknown error)

Thanks,
Arvind Chauhan

On Sat, Oct 5, 2019 at 5:10 PM Alan DeKok <[hidden email]> wrote:

> On Oct 5, 2019, at 6:43 AM, Arvind Chauhan <[hidden email]> wrote:
> >
> > I am new in freeradius.
> > I am generating DM-request Package from Radius server side with below
> > mention command Acct-Session-ID and NAS-IP_address taken as random value
> > for testing:
> > echo "User-Name=arv,Acct-Session-Id=12354679, NAS-IP_Address=1.1.1.1"|
> > radclient 1.1.1.1:3799 disconnect testing123
> >
> > code::
> >
> > Attached with mail
> >
> > Error:
> >
> > radclient: received bad packet
> >
> > # What is causing this problem and how we can solve this problem?
>
>   Print the actual error message:
>
>                 printf( "radclient: received bad packet:
> %s\n",strerror(errno));
>
>   This is wrong.  You should use fr_strerror(), which returns a
> descriptive message.  strerror() is for getting errors from system calls /
> system libraries.  We use our own error wrapper.
>
>   Alan DeKok.
>
>
> -
> List info/subscribe/unsubscribe? See
> http://www.freeradius.org/list/users.html
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
| Threaded
Open this post in threaded view
|

Re: Radclient : received bad packet

Alan DeKok-2
On Oct 6, 2019, at 4:49 AM, Arvind Chauhan <[hidden email]> wrote:
>
> with fr_strerror(), I m getting unknown error.
> radclient: received bad packet: (unknown error)

  Well, the radclient we ship works.  Something else is going wrong, and you'll have to debug it.

  You have the source code, so you can use a debugger, or you can instrument the source code.

  Alan DeKok.


-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
| Threaded
Open this post in threaded view
|

Re: Radclient : received bad packet

Orestes Leal Rodríguez
In reply to this post by Arvind Chauhan
Arvind,

You have this code:

           reply = fr_packet_list_recv(pl, &rdset);
           if (!reply) {
                printf( "radclient: received bad packet: %s\n",strerror(errno));
                return -1;  /* bad packet */
            }
                       
Two things about it:

On the freeradius library: packet.c:908 (fr_packet_list_recv) there
are two possible
reasons that the function will return NULL (your case).

  1. pl OR rdset == NULL    (packet.c: if (!pl || !set) return NULL;)

  2. This doesn't hold (from packet.c):

                 start = pl->last_recv;
         do
                 ...
                 } while (start != pl->last_recv);

I would say that you have an issue with pl or rdset or pl->last_recv
is different than what freeradius expect.


NOTES:

I would actually suggest replacing:

> if ((bind(fd, (struct sockaddr *)&serveraddr, addrsize))<0)

by this:

> if ((bind(fd, (struct sockaddr *)&serveraddr, addrsize)) == -1)

From bind(2) (POSIX.1)

RETURN VALUE
       On success, zero is returned.  On error, -1 is returned, and
errno is set appropriately.


Orestes
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html