I have built such a gateway for SSH: it accepts the connection, powers on the target machine if needed, then forwards traffic.
https://github.com/stapelberg/zkj-nas-tools/blob/master/wolg...
The advantage over just catching any packets is that an SSH connection is authorized, so less noisy in terms of undesired wakeups.