You could use tcpdump
or wireshark
to monitor the network interface on the Pi and set up a filter for the magic packet of your choice. For example, for a ping packet that could be:
tcpdump -i eth0 icmp and icmp[icmptype]=icmp-echo
Pipe the output of tcpdump
to a script which wakes up the target computer on any new input:
while read line; do wakeonlan <mac address>; done
and the target computer should wake up every time someone pings your Pi.