All of lore.kernel.org
 help / color / mirror / Atom feed
* "Decoding" ipset error codes
@ 2022-03-16 16:40 Ian Pilcher
  2022-03-18 19:38 ` Jozsef Kadlecsik
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Pilcher @ 2022-03-16 16:40 UTC (permalink / raw)
  To: netfilter-devel

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.)

Is there any way that I can give users of my program something more
helpful than "unknown error XXXX"?

Thanks!

[1] https://github.com/ipilcher/fdf/blob/main/src/filters/ipset.c

-- 
========================================================================
Google                                      Where SkyNet meets Idiocracy
========================================================================

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: "Decoding" ipset error codes
  2022-03-16 16:40 "Decoding" ipset error codes Ian Pilcher
@ 2022-03-18 19:38 ` Jozsef Kadlecsik
  0 siblings, 0 replies; 2+ messages in thread
From: Jozsef Kadlecsik @ 2022-03-18 19:38 UTC (permalink / raw)
  To: Ian Pilcher; +Cc: netfilter-devel

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@blackhole.kfki.hu, kadlecsik.jozsef@wigner.hu
PGP key : https://wigner.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics
          H-1525 Budapest 114, POB. 49, Hungary

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-18 19:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-16 16:40 "Decoding" ipset error codes Ian Pilcher
2022-03-18 19:38 ` Jozsef Kadlecsik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.