Asterisk as IMS home gateway

Hi All,

I am developing Asterisk 1.8 based IMS (IP Multimedia Systems) home gateway. Can anyone please tell me how can i differentiate between IMS UA and SIP UA from asterisk point of view.

Basic functionality is to pass through the IMS UA message to IMS server and act as B2BUA for SIP UA.