Skip to content

Support listening on multiple ports with a single socket #809

Open
@chayleaf

Description

@chayleaf

For VPN/proxy-like programs, it's useful to listen to all traffic on all ports. For example, see this library. I'm currently using it, but it would be nice to be able to use smoltcp for this use case as well.

How this would be implemented:

  • For TCP sockets, very little has to change - port 0 should listen on all ports instead of being forbidden (the address tuple will be changed after accepting a packet so this is fine), the state machine is obviously socket-specific so the user will be responsible for creating additional sockets as necessary.
  • For UDP sockets, it's somewhat harder as the implementation is very tied to being available only for a single port right now. Nonetheless, even just implementing sockets that listen for any traffic, then bind to the port where traffic arrived would probably be helpful. Alternatively, new code for wildcard UDP sockets with recv_to and send_from functions can be added, as UDP is a relatively simple protocol.
  • For other sockets, nothing needs to be done as they are either port-specific or port-agnostic

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions