If by P2P you mean torrents then you could set up the torrent client to use a static port, disable UPnP on the router and set up port forwarding for that 1 specific port on that 1 machine. This wouldn't compleatly stop P2P traffic for other devices but it would most likely slow the transfer speeds to realy low rates.
As for the router being able to know if a packet is a P2P application or not, you need to understand that data to be transfered over the internet is encapsulated multiple times, and for a router to find out what type of application the packet is it would have to use deep packet inspection technology to be able to look deep into the packet to know what it is. Most routers can't do this because there is no need to, as routers only need to look at some of the headers to do their job, they don't need to know what data is involved. To a certain degree routers can perform QoS and control traffic based on where the packet is heading (for example something heading to port 80 is most likely HTTP traffic), but P2P traffic uses random source and destination ports, so there is no way without deep packet inspection for the router to know what type of traffic it is.