It's an interceptor trap:
http://www.draindomain.com/interceptor%20traps.html
Ahhhhh - that explains it. Many thanks for the swift responses.
One other question: how should I re-attach the cap? If I just push it
back in it probably won't be a very good fit & may fall out again.
Should it be fully or partially mortared in to prevent smells getting
back through? I don't know if something more modern like mastic may
work as it would make it easy to get out.
Michael