GUPNP-BINDING-TOOL(1)
πΈ NAME πΈ
okay so bestie, welcome to GUPNP-BINDING-TOOL(1) β the manual page for gupnp-binding-tool-1.2, and it creates C convenience wrappers for UPnP services. that's the whole gig, and it's kinda iconic ngl.
β¨ SYNOPSIS β¨
the invocation vibe is literally:
gupnp-binding-tool-1.2 [--prefix {PREFIX}] [--mode {client|server}]
{SCPD file}
π DESCRIPTION π
okay so gupnp-binding-tool-1.2 takes a SCPD file and generates convenience C functions which call the actual GUPnP functions. the client-side bindings can be seen as a service-specific version of the GUPnPServiceProxy API, and the service-side bindings are the same for GUPnPService.
these generated functions are less verbose and also safer as function call parameters are correctly typed. action, variable and query names are easier to get correct with bindings (or at least the errors will be compile-time errors instead of run-time), and are also available in editor autocompletion. literally a little glow-up for your C code, no cap π .
π¦ CLIENT SIDE BINDINGS π¦
as an example, this action:
<action>
<name>DeletePortMapping</name>
<argumentList>
<argument>
<name>NewRemoteHost</name>
<direction>in</direction>
<relatedStateVariable>RemoteHost</relatedStateVariable>
</argument>
<argument>
<name>NewExternalPort</name>
<direction>in</direction>
<relatedStateVariable>ExternalPort</relatedStateVariable>
</argument>
<argument>
<name>NewProtocol</name>
<direction>in</direction>
<relatedStateVariable>PortMappingProtocol</relatedStateVariable>
</argument>
</argumentList>
</action>
will generate the following synchronous client-side (control point) function:
static inline gboolean
igd_delete_port_mapping (GUPnPServiceProxy *proxy,
const gchar *in_new_remote_host,
const guint in_new_external_port,
const gchar *in_new_protocol,
GError **error);
as can be seen, the arguments have the correct types and are prefixed with the argument direction. slay.
gupnp-binding-tool-1.2 generates both synchronous and asynchronous wrappers. the igd_delete_port_mapping example above is the synchronous form, the asynchronous form is as follows:
typedef void (*igd_delete_port_mapping_reply) (GUPnPServiceProxy *proxy,
GError *error,
gpointer userdata);
static inline GUPnPServiceProxyAction *
igd_delete_port_mapping_async (GUPnPServiceProxy *proxy,
const gchar *in_new_remote_host,
const guint in_new_external_port,
const gchar *in_new_protocol,
igd_delete_port_mapping_reply callback,
gpointer userdata);
the asynchronous form (implemented using gupnp_service_proxy_begin_action() and gupnp_service_proxy_end_action()) will return without blocking and later invoke the callback from the main loop when the reply is received. main character energy fr fr β¨.
the tool also creates bindings for state variable notifications. this state variable definition:
<stateVariable sendEvents="yes">
<name>ExternalIPAddress</name>
<dataType>string</dataType>
</stateVariable>
will create this client binding that can be used to get notifications on "ExternalIPAddress" changes:
typedef void
(*igd_external_ip_address_changed_callback) (GUPnPServiceProxy *proxy,
const gchar *external_ip_address,
gpointer userdata);
static inline gboolean
igd_external_ip_address_add_notify (GUPnPServiceProxy *proxy,
igd_external_ip_address_changed_callback callback,
gpointer userdata);
all of the examples were produced with gupnp-binding-tool-1.2 --prefix igd --mode client WANIPConnection.xml. periodt π.
π₯ SERVER SIDE BINDINGS π₯
the corresponding server bindings for the same UPnP action (DeletePortMapping) look like this:
void
igd_delete_port_mapping_action_get (GUPnPServiceAction *action,
gchar **in_new_remote_host,
guint *in_new_external_port,
gchar **in_new_protocol);
gulong
igd_delete_port_mapping_action_connect (GUPnPService *service,
GCallback callback,
gpointer userdata);
the generated *_action_connect() function can be used to connect the action handler. the *_action_get() and *_action_set() functions can then be used inside the action handler to get/set action variables. if notified variables are modified, the *_variable_notify() should be used to send the notifications (see below).
typedef gchar *(*igd_external_ip_address_query_callback) (GUPnPService *service,
gpointer userdata);
gulong
igd_external_ip_address_query_connect (GUPnPService *service,
igd_external_ip_address_query_callback callback,
gpointer userdata);
void
igd_external_ip_address_variable_notify (GUPnPService *service,
const gchar *external_ip_address);
the *_query_connect() function can be used to connect the service-specific query handler. the return value of the handler is the returned state variable value. iykyk π«Ά.
all of the examples were produced with gupnp-binding-tool-1.2 --prefix igd --mode server WANIPConnection.xml. ate and left no crumbs π
.
cute sign-off bestie: the footer source/version is GUPnP 1.4.3, and the date spot isn't in this footer text, so i'm not inventing one β byeee ππ¦π.
π¦ where this page comes from
- epel 9: gupnp-devel 1.4.3-3.el9 Β· LGPLv2+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms