Close and distant reprocessing media in Mkn 509 studied with BeppoSAX