Support IGD v2 port mappings by GiovanniMenzano · Pull Request #367 · jupnp/jupnp · GitHub
Skip to content

Support IGD v2 port mappings - #367

Merged
wborn merged 2 commits into
jupnp:mainfrom
GiovanniMenzano:366-igd-v2-port-mapping
Jul 29, 2026
Merged

wborn merged 2 commits into
jupnp:mainfrom
GiovanniMenzano:366-igd-v2-port-mapping

Conversation

@GiovanniMenzano

Copy link
Copy Markdown

Handle newer gateways and routers that describe ports differently.

Fixes #366

Handle newer gateways and routers that describe ports differently.

Fixes jupnp#366

Signed-off-by: Giovanni Menzano <giovanni.menzano@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates the IGD port-mapping support to work with IGD v2 gateways and routers that advertise port arguments as ui4 (instead of ui2), addressing the failure described in issue #366.

Changes:

  • Allow discovering IGD devices whose type is a newer version of InternetGatewayDevice:1 (e.g., v2).
  • Pass port arguments as strings when building AddPortMapping / DeletePortMapping action invocations so they can be coerced into the service-advertised port datatype.
  • Add unit tests covering IGD v2 discovery and ui4 port datatype handling in port-mapping callbacks.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
bundles/org.jupnp.support/src/main/java/org/jupnp/support/igd/PortMappingListener.java Accept IGD devices implementing newer InternetGatewayDevice versions (e.g., v2).
bundles/org.jupnp.support/src/main/java/org/jupnp/support/igd/callback/PortMappingAdd.java Send ports as strings to allow coercion to ui4 when required by the device/service.
bundles/org.jupnp.support/src/main/java/org/jupnp/support/igd/callback/PortMappingDelete.java Send ports as strings to allow coercion to ui4 when required by the device/service.
bundles/org.jupnp.support/src/test/java/org/jupnp/support/igd/PortMappingListenerTest.java New test ensuring IGD v2 devices are discovered.
bundles/org.jupnp.support/src/test/java/org/jupnp/support/igd/callback/PortMappingCallbackTest.java New tests asserting callbacks use the port datatype advertised by the service (ui4).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wborn wborn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

It looks good but it would be nice if you can prevent the potential NPEs.

There is also a test that I think could be improved.

@GiovanniMenzano

Copy link
Copy Markdown
Author

Sorry for the late reply, I was away from home, and thanks for the review. I totally forgot about the npe, that of course can happen now. As for the tests, I couldn’t find any in that module, so I just added a couple of simple ones for now (maybe too naive 😅).
I will fix soon and check the test too

Handle newer gateways and routers that describe ports differently.
Added check for unset ports to avoid NPEs. Covered the IGD v2 hierarchy in tests.

Fixes jupnp#366

Signed-off-by: Giovanni Menzano <giovanni.menzano@gmail.com>
@GiovanniMenzano

Copy link
Copy Markdown
Author

Anyway, Spotless can be a real pain (I won’t elaborate), it kept messing with my code formatting

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@wborn wborn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@wborn
wborn merged commit 1e77668 into jupnp:main Jul 29, 2026
4 checks passed
@wborn wborn added this to the 3.0.5 milestone Jul 29, 2026
@GiovanniMenzano
GiovanniMenzano deleted the 366-igd-v2-port-mapping branch July 29, 2026 13:00
@wborn

wborn commented Aug 12, 2026

Copy link
Copy Markdown
Member

Hi @GiovanniMenzano, the 3.0.5 release is finally published!

@GiovanniMenzano

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PortMappingListener fails with IGD v2 and ui4 port arguments

3 participants