[PATCH] umdns: add timeout_lookup parameter for services

2022-08-26 Thread Tobias Waldvogel
From: Tobias Waldvogel 

Printing on Android devices via mdns IPP does not work
with the default value of 60 seconds for the
lookup timeout. It seems that Androd expects an
immediate answer just when trying to print. Nevertheless
the umdns debug messages show that the answer is supressed
due to the timeout. As a result the printer does not
show up.
This patch implements an additional parameter
timeout_lookup for setting a dedicated timeout value
with a fallback to TOUT_LOOKUP (60s).

This is a sample ipp service definition, which works
now with Android standard printing:

{
  "ipp": {
"service": "_ipp._tcp.local",
"instance": "HL3040CN @ router",
"port": 631,
"timeout_lookup": -1,
"txt": [
  "txtvers=1",
  "UUID=308f65f9-5393-3027-4c83-374cb704e729",
  "rp=printers/HL3040CN",
  "ty=Brother HL3040CN",
  "note=Office",
  "pdl=application/pdf,image/jpeg,image/png,image/pwg-raster",
  "Color=T",
  "Copies=T"
]
  }
}

Signed-off-by: Tobias Waldvogel 
---
diff --git a/service.c b/service.c
index bd9f985..dc7f330 100644
--- a/service.c
+++ b/service.c
@@ -35,6 +35,7 @@
 #include "announce.h"

 enum {
+ SERVICE_TOUT_LOOKUP,
  SERVICE_INSTANCE,
  SERVICE_SERVICE,
  SERVICE_PORT,
@@ -51,12 +52,14 @@ struct service {
  const char *instance;
  const char *service;
  const uint8_t *txt;
+ int32_t tout_lookup;
  int txt_len;
  int port;
  int active;
 };

 static const struct blobmsg_policy service_policy[__SERVICE_MAX] = {
+ [SERVICE_TOUT_LOOKUP] = { .name = "timeout_lookup", .type =
BLOBMSG_TYPE_INT32 },
  [SERVICE_INSTANCE] = { .name = "instance", .type = BLOBMSG_TYPE_STRING },
  [SERVICE_SERVICE] = { .name = "service", .type = BLOBMSG_TYPE_STRING },
  [SERVICE_PORT] = { .name = "port", .type = BLOBMSG_TYPE_INT32 },
@@ -122,8 +125,8 @@ service_timeout(struct service *s)
 {
  time_t t = monotonic_time();

- if (t - s->t <= TOUT_LOOKUP) {
- DBG(2, "t=%" PRId64 ", s->t=%" PRId64 ", t - s->t = %" PRId64 "\n",
(int64_t)t, (int64_t)s->t, (int64_t)(t - s->t));
+ if (t - s->t <= s->tout_lookup) {
+ DBG(2, "t=%" PRId64 ", s->t=%" PRId64 ", s->tout_lookup=%d, t - s->t
= %" PRId64 "\n", (int64_t)t, (int64_t)s->t, s->tout_lookup,
(int64_t)(t - s->t));
  return 0;
  }

@@ -239,6 +242,7 @@ service_load_blob(struct blob_attr *b)
  if (!s)
  return;

+ s->tout_lookup = _tb[SERVICE_TOUT_LOOKUP] ?
blobmsg_get_u32(_tb[SERVICE_TOUT_LOOKUP]) : TOUT_LOOKUP;
  s->port = blobmsg_get_u32(_tb[SERVICE_PORT]);
  s->id = strncpy(d_id, blobmsg_name(b), n);
  if (_tb[SERVICE_INSTANCE])

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] umdns: add timeout_lookup parameter for services

2022-09-04 Thread Hauke Mehrtens

On 8/26/22 13:40, Tobias Waldvogel wrote:

From: Tobias Waldvogel 

Printing on Android devices via mdns IPP does not work
with the default value of 60 seconds for the
lookup timeout. It seems that Androd expects an
immediate answer just when trying to print. Nevertheless
the umdns debug messages show that the answer is supressed
due to the timeout. As a result the printer does not
show up.
This patch implements an additional parameter
timeout_lookup for setting a dedicated timeout value
with a fallback to TOUT_LOOKUP (60s).

This is a sample ipp service definition, which works
now with Android standard printing:

{
   "ipp": {
 "service": "_ipp._tcp.local",
 "instance": "HL3040CN @ router",
 "port": 631,
 "timeout_lookup": -1,
 "txt": [
   "txtvers=1",
   "UUID=308f65f9-5393-3027-4c83-374cb704e729",
   "rp=printers/HL3040CN",
   "ty=Brother HL3040CN",
   "note=Office",
   "pdl=application/pdf,image/jpeg,image/png,image/pwg-raster",
   "Color=T",
   "Copies=T"
 ]
   }
}

Signed-off-by: Tobias Waldvogel 


The white spaces in this patch are damaged.

It is also broken in patchwork:
https://patchwork.ozlabs.org/project/openwrt/patch/caaatp75fm8oavryfdzty2bvccmoh8pns0pxv+lpxpxcxu7h...@mail.gmail.com/

You could use "git send-email" to send the patch for example.

Hauke

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel