Oh, your issue is about incoming calls on those gateways?

If it's actually via the FreeSWITCH system of a gateway (instead of just an open IP:PORT) you can have it set a variable that you can monitor for:

https://freeswitch.org/confluence/display/FREESWITCH/Gateways+Configuration#GatewaysConfiguration-Variables 
<gateway>
 ...params...
 <variables>
   <variable name="inbound_var_name"  value="this is inbound"  direction="inbound"/>
   <variable name="outbound_var_name" value="this is outbound" direction="outbound"/>
   <variable name="both_var_name"     value="this on any direction"/>
 </variables>
</gateway>