Re: "Decoding" ipset error codes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Ian,

On Wed, 16 Mar 2022, Ian Pilcher wrote:

> I am using libmnl to add entries to an IP set.  (Code here[1] if anyone
> is interested.)  I've got everything working, but I haven't yet found a
> way to "decode" any protocol-specific errors that may be returned,
> because the set is not of the correct type, for example.
> 
> I see that libipset has an ipset_errcode() function but it looks to be
> designed for use only when libipset is being used for the actual netlink
> communication.  (I didn't do that in this case, because libipset looks
> to be targeted only on parsing and executing commands that are passed to
> the ipset command.  It didn't make any sense to me to create a command
> string in a buffer just so libipset could parse it back into information
> that is already known.)

You can avoid parsing: it is possible to fill out the session data fields 
directly by calling ipset_data_set() and then issuing the required 
command.
 
> Is there any way that I can give users of my program something more
> helpful than "unknown error XXXX"?

You can "copy" the errcode table from the libipset source tree. Or it 
could be extended with a new ipset_errcode_raw() command which would just 
translate the returned errcode into the appropriate error string.

Best regards,
Jozsef
-
E-mail  : kadlec@xxxxxxxxxxxxxxxxx, kadlecsik.jozsef@xxxxxxxxx
PGP key : https://wigner.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics
          H-1525 Budapest 114, POB. 49, Hungary



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux