function of gateway
additionally gateway is something that is used for communication with the external network. A VoIP gateway is used for communication from a network, lets say mobile network where channels are allocated as circuit switched the backbone is partially packet switched (ATM or VoIP based). now communicating with external entitiy you need some thing which acts as a interworking function which converts one protocol to another and makes the frame format in such a way that it is compatible to both the end points. hope that answers your question.
rgds
Gauiver