--- asterisk-12.2.0/channels/chan_sip.c 2014-04-21 17:02:00.000000000 -0400 +++ asterisk-12.2.0-modified/channels/chan_sip.c 2014-05-24 12:43:53.816120532 -0400 @@ -24024,6 +24024,29 @@ sip_publish_registry(r->username, r->hostname, regstate2str(r->regstate)); r->regattempts = 0; ast_debug(1, "Registration successful\n"); + + //Get PEER from Realtime subsystem, and if peer exist, update field with useragent, ipaddr, port, ... + struct sip_peer *peer; + const char *useragent; + peer = sip_find_peer(r->peername, NULL, TRUE, FINDPEERS, FALSE, 0); + //Peer can be not available in case of use "register=>" in 'sip.conf' and not in 'sippeers' table with 'callbackextension' field + if(peer) + { + ao2_lock(peer); + set_peer_nat(p, peer); + ast_copy_flags(&p->flags[0], &peer->flags[0], SIP_NAT_FORCE_RPORT); + parse_register_contact(p,peer,req); + + //Parse User Agent (Server Header) + useragent = sip_get_header(req, "Server"); + if (strcasecmp(useragent, peer->useragent)) { + ast_string_field_set(peer, useragent, useragent); + ast_verb(4, "Saved useragent \"%s\" for peer %s\n", peer->useragent, peer->name); + } + update_peer(peer, p->expiry); + ao2_unlock(peer); + } + if (r->timeout > -1) { ast_debug(1, "Cancelling timeout %d\n", r->timeout); }