openwrt / openwrt/packages

p910nd: bonjour printers show up on the printer list with the hostname instead of the printer name

Open
#10,496 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Makefile
Stars
4.6k
Forks
4k
Avg merge
3d 12h
Merged PRs (30d)
134

Description

Maintainer: @pkerling (find it by checking history of the package Makefile)
Environment: OpenWRT master, Archer C5 v1 MIPS, macOS

Description:

p910nd advertises printers over mdns but the service instance name is hardcoded to be the hostname of the router instead of a more descriptive name. This instance name shows up when adding printers on macOS and everyone else puts the printer model there (or "model @ hostname" for printers shared via another computer).

umdns has support for setting instance names since 2017 but this support was is not exposed in the procd helpers. I managed to hack around this issue but unfortunately there appears to be no easy way to extend the procd mdns shell API properly.

Here are my hacks that are enough to make this work:

--- a/rom/etc/init.d/p910nd
+++ b/overlay/upper/etc/init.d/p910nd
@@ -52,7 +52,7 @@ start_p910nd() {
 		config_get mdns_mfg "$section" mdns_mfg
 		config_get mdns_mdl "$section" mdns_mdl
 		config_get mdns_cmd "$section" mdns_cmd
-		[ "$mdns" -gt 0 ] && procd_add_mdns "pdl-datastream" "tcp" "$((port+9100))" "note=$mdns_note" "ty=$mdns_ty" "product=$mdns_product" "usb_MFG=$mdns_mfg" "usb_MDL=$mdns_mdl" "usb_CMD=$mdns_cmd"
+		[ "$mdns" -gt 0 ] && MDNS_INSTANCE_NAME="$mdns_ty" procd_add_mdns "pdl-datastream" "tcp" "$((port+9100))" "note=$mdns_note" "ty=$mdns_ty" "product=$mdns_product" "usb_MFG=$mdns_mfg" "usb_MDL=$mdns_mdl" "usb_CMD=$mdns_cmd"

 		procd_close_instance
 	fi
diff --git a/rom/lib/functions/procd.sh b/overlay/upper/lib/functions/procd.sh
index b8f9a21..1f47ba9 100644
--- a/rom/lib/functions/procd.sh
+++ b/overlay/upper/lib/functions/procd.sh
@@ -499,6 +499,7 @@ procd_add_mdns_service() {
 	json_add_object "${service}_$port"
 	json_add_string "service" "_$service._$proto.local"
 	json_add_int port "$port"
+	[ -n "$MDNS_INSTANCE_NAME" ] && json_add_string "instance" "$MDNS_INSTANCE_NAME"
 	[ -n "$1" ] && {
 		json_add_array txt
 		for txt in "$@"; do json_add_string "" "$txt"; done

Btw. this is probably not the ideal place to discuss the procd API extension problem. Should I file another bug at bugs.openwrt.org against umdns or procd?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the p910nd init script at rom/etc/init.d/p910nd and the procd helper in rom/lib/functions/procd.sh, then compare the referenced umdns service.c support for instance names. Determine an appropriate procd API extension and verify that the advertised printer name appears correctly when discovered on macOS.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
embedded-iot, networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.