File and line of IP address

Asterisk has stored the Port and Ip of the phones. So when I call someone, I have an asterisk Id (the equivalent of the phone number) and somewhere in the code the asterisk id is translated into an ip and port.

Where is that code? Can someone tell me the file and the line where this happens? How and where is the port stored?

That’s not really specific enough. You’d have to specify the channel driver in use, and what exactly you are trying to achieve with the information.

I am trying to understand the code.
I want to store all the user information in one database table
Phone number | ip | port

But for that I need to know, how the ip and port is determined.

For chan_sip, it is struct sip_pvt that contains the information used. There will be something similar for chan_pjsip, however I assume that it is decomposed in a similar way to the way in which the conf file is structured.

However, Asterisk doesn’t store phone numbers, in this context. It identifies peers by IP address or user name. The user name doesn’t have to be a phone number, and some of the security advice is that it should not be.

extensions.conf is where phone numbers are identified for outgoing calls, and that is processed by pbx.c. There need be no phone number associated with an incoming call.

For outgoing calls, the peer may also use user name to identify a local endpoint, in which case IP address and port will not uniquely identify an endpoint (which may or may not correspond to a phone number).

The above is very much a simplification, only applies to SIP, and is really outside the scope of this forum, as it is a developer, not an end user question. There are mailing lists and IRC channels for developers.

I’d suggest that, if you cannot answer the question by looking at the code, you don’t know enough about Asterisk to be trying to answer it.

For many channel technologies, the concept of an IP address is completely foreign.