None of the current P2P technologies are illegal per definition. The target file of a download or upload might be a violation of copyright laws, though, which is the reason why some people try to criminalize the complete technology. Actually the deal with P2P is as with any other technology or invention, beginning from the first stone age knife: It’s meant as a helpful tool, but can be misused at any given time.
The misuse of the P2P technology is the reason why P2P traffic is often strongly observed by certain organizations. In case one is uncertain, if the up- or download of a file might be unlawful, it’s better not to do either one. By rule of thumb one can say, that Open Source files and files in the Public Domain are free to share – though one must also keep in mind, that Public Domain in the USA for example doesn't mean, the same content might be free elsewhere. In certain situations one has to analyze the given situation and decide the sharing of each file individually.
It’s important to understand that each download usually also is an upload (if one does not block incoming traffic) and therefore the sharing of a file. If you download an illegal distributed file, you are not only violating copyright laws in a passive manner, but also very actively, if the file segments also are uploaded. Both activities are forbidden by law and enforced very strictly throughout the world.