2 * Copyright (C) 2001-2003 FhG Fokus
4 * This file is part of Kamailio, a free SIP server.
6 * Kamailio is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version
11 * Kamailio is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 * \brief Kamailio core :: Message forwarding
34 #include <sys/types.h>
35 #include <sys/socket.h>
37 #include <netinet/in.h>
38 #include <arpa/inet.h>
41 #include "hash_func.h"
43 #include "parser/msg_parser.h"
44 #include "char_msg_val.h"
50 #include "data_lump.h"
53 #include "crypto/md5utils.h"
54 #include "msg_translator.h"
55 #include "sr_module.h"
58 #include "name_alias.h"
59 #include "socket_info.h"
62 #ifdef USE_DNS_FAILOVER
63 #include "dns_cache.h"
65 #ifdef USE_DST_BLACKLIST
66 #include "dst_blacklist.h"
68 #include "compiler_opt.h"
69 #include "core_stats.h"
77 /* return a socket_info_pointer to the sending socket; as opposed to
78 * get_send_socket, which returns process's default socket, get_out_socket
79 * attempts to determine the outbound interface which will be used;
80 * it uses a temporary connected socket to determine it; it will
81 * be very likely noticeably slower, but it can deal better with
85 static int mhomed_sock_cache_disabled = 0;
86 static int sock_inet = -1;
87 static int sock_inet6 = -1;
88 static int _forward_set_send_info = 0;
90 void forward_set_send_info(int v)
92 _forward_set_send_info = v;
95 static void apply_force_send_socket(struct dest_info* dst, struct sip_msg* msg);
97 struct socket_info* get_out_socket(union sockaddr_union* to, int proto)
101 union sockaddr_union from;
102 struct socket_info* si;
104 union sockaddr_union uncon;
106 memset(&uncon, 0, sizeof(union sockaddr_union));
107 uncon.sin.sin_family = AF_UNSPEC;
109 if (unlikely(proto!=PROTO_UDP)) {
110 LM_CRIT("can only be called for UDP\n");
114 switch(to->s.sa_family){
116 if(unlikely(sock_inet < 0)){
117 sock_inet = socket(AF_INET, SOCK_DGRAM, 0);
119 LM_ERR("socket() failed: %s\n", strerror(errno));
123 temp_sock = &sock_inet;
127 if(unlikely(sock_inet6 < 0)){
128 sock_inet6 = socket(AF_INET6, SOCK_DGRAM, 0);
129 if (sock_inet6==-1) {
130 LM_ERR("socket() failed: %s\n", strerror(errno));
134 temp_sock = &sock_inet6;
138 LM_ERR("Unknown protocol family \n");
143 if( !mhomed_sock_cache_disabled ){
144 /* some Linux kernel versions (all?) along with other UNIXes don't re-bound the sock if already bound */
145 /* to un-bound a socket set sin_family to AF_UNSPEC and zero out the rest*/
146 if (unlikely(connect(*temp_sock, &uncon.s, sockaddru_len(uncon)) < 0))
147 mhomed_sock_cache_disabled = 1;
150 if (unlikely(connect(*temp_sock, &to->s, sockaddru_len(*to))==-1)) {
151 if (unlikely(errno==EISCONN && !mhomed_sock_cache_disabled)){
152 /* no multiple connects support on the same socket */
153 mhomed_sock_cache_disabled=1;
164 LM_ERR("connect failed: %s\n", strerror(errno));
168 if (unlikely(getsockname(*temp_sock, &from.s, &len)==-1)) {
169 LM_ERR("getsockname failed: %s\n", strerror(errno));
172 su2ip_addr(&ip, &from);
173 si=find_si(&ip, 0, proto);
174 if (si==0) goto error;
175 LM_DBG("socket determined: %p\n", si );
176 if (unlikely(mhomed_sock_cache_disabled)){
182 LM_ERR("no socket found\n");
183 ERR("no corresponding socket found for(%s:%s)\n",
184 proto2a(proto), su2a(to, sizeof(*to)));
185 if (unlikely(mhomed_sock_cache_disabled && *temp_sock >=0)){
194 /** get the sending socket for a corresponding destination.
195 * @param force_send_socket - if !=0 and the protocol and af correspond
196 * with the destination, it will be returned.
197 * If the protocol or af check fail, a look-alike
198 * socket will be searched for and mismatch will be
199 * set. If no look-alike socket is found it will
200 * fallback to normal resolution.
201 * @param to - destination
202 * @param proto - protocol
203 * @param mismatch - result parameter, set if a force_send_socket was used, but
204 * there was an error matching it exactly to the destination.
205 * Possible values: 0 ok, SS_MISMATCH_PROTO,
206 * SS_MISMATCH_ADDR, SS_MISMATCH_AF, SS_MISMATCH_MCAST.
207 * @return a socket_info pointer to the sending socket on success (and possibly
208 * sets mismatch) or 0 on error.
210 struct socket_info* get_send_socket2(struct socket_info* force_send_socket,
211 union sockaddr_union* to, int proto,
212 enum ss_mismatch* mismatch)
214 struct socket_info* send_sock;
215 struct socket_info* orig;
217 if (likely(mismatch)) *mismatch=0;
218 /* check if send interface is not forced */
219 if (unlikely(force_send_socket)){
220 orig=force_send_socket;
221 /* Special case here as there is no ;transport=wss - so wss connections
222 * will appear as ws ones and be sorted out in the WebSocket module */
223 if (unlikely(orig->proto!=proto && !(orig->proto==PROTO_TLS && proto==PROTO_WS))){
224 force_send_socket=find_si(&(force_send_socket->address),
225 force_send_socket->port_no,
227 if (unlikely(force_send_socket == 0)){
228 if (likely(mismatch)) *mismatch=SS_MISMATCH_ADDR;
229 LM_WARN("protocol/port mismatch (forced %s:%s:%d, to %s:%s)\n",
230 proto2a(orig->proto), ip_addr2a(&orig->address),
232 proto2a(proto), su2a(to, sizeof(*to)));
235 if (likely(mismatch)) *mismatch=SS_MISMATCH_PROTO;
237 if (unlikely(force_send_socket->address.af!=to->s.sa_family)){
238 LM_DBG("force_send_socket of different af"
239 " (dst %d - %s:%s forced %d -%s:%s:%d)\n",
240 to->s.sa_family, proto2a(proto), su2a(to, sizeof(*to)),
241 force_send_socket->address.af,
242 proto2a(force_send_socket->proto),
243 ip_addr2a(&force_send_socket->address),
244 force_send_socket->port_no);
245 if (likely(mismatch)) *mismatch=SS_MISMATCH_AF;
248 /* check if listening on the socket (the check does not work
249 * for TCP and TLS, for them socket==-1 on all the processes
250 * except tcp_main(), see close_extra_socks() */
251 if (likely((force_send_socket->socket!=-1 ||
252 force_send_socket->proto==PROTO_TCP ||
253 force_send_socket->proto==PROTO_TLS ||
254 force_send_socket->proto==PROTO_WS ||
255 force_send_socket->proto==PROTO_WSS) &&
256 !(force_send_socket->flags & SI_IS_MCAST)))
257 return force_send_socket;
259 if (!(force_send_socket->flags & SI_IS_MCAST))
260 LM_WARN("not listening on the requested socket (%s:%s:%d),"
262 proto2a(force_send_socket->proto),
263 ip_addr2a(&force_send_socket->address),
264 force_send_socket->port_no);
265 else if (likely(mismatch)) *mismatch=SS_MISMATCH_MCAST;
269 if (mhomed && proto==PROTO_UDP){
270 send_sock=get_out_socket(to, proto);
271 if ((send_sock==0) || (send_sock->socket!=-1))
272 return send_sock; /* found or error*/
273 else if (send_sock->socket==-1){
274 LM_WARN("not listening on the"
275 " requested socket (%s:%s:%d), no fork mode?\n",
276 proto2a(send_sock->proto), ip_addr2a(&send_sock->address),
278 /* continue: try to use some socket */
283 /* check if we need to change the socket (different address families -
284 * eg: ipv4 -> ipv6 or ipv6 -> ipv4) */
289 /* on tcp just use the "main address", we don't really now the
290 * sending address (we can find it out, but we'll need also to see
291 * if we listen on it, and if yes on which port -> too complicated*/
292 switch(to->s.sa_family){
294 case AF_INET: send_sock=sendipv4_tcp;
296 case AF_INET6: send_sock=sendipv6_tcp;
298 default: LM_ERR("don't know how to forward to af %d\n",
306 switch(to->s.sa_family){
308 case AF_INET: send_sock=sendipv4_tls;
310 case AF_INET6: send_sock=sendipv6_tls;
312 default: LM_ERR("don't know how to forward to af %d\n",
319 if ((bind_address==0) ||
320 (to->s.sa_family!=bind_address->address.af) ||
321 (bind_address->proto!=PROTO_SCTP)){
322 switch(to->s.sa_family){
323 case AF_INET: send_sock=sendipv4_sctp;
325 case AF_INET6: send_sock=sendipv6_sctp;
327 default: LM_ERR("don't know how to forward to af %d\n",
330 }else send_sock=bind_address;
332 #endif /* USE_SCTP */
334 if ((bind_address==0) ||
335 (to->s.sa_family!=bind_address->address.af) ||
336 (bind_address->proto!=PROTO_UDP)){
337 switch(to->s.sa_family){
338 case AF_INET: send_sock=sendipv4;
340 case AF_INET6: send_sock=sendipv6;
342 default: LM_ERR("don't know how to forward to af %d\n",
345 }else send_sock=bind_address;
348 LM_CRIT("unsupported proto %d (%s)\n", proto, proto2a(proto));
353 static struct _check_self_func {
355 struct _check_self_func *next;
356 } *_check_self_func_list = NULL;
358 /** check if _check_self_func_list is set
359 * - return 1 if yes, 0 if no
361 int is_check_self_func_list_set(void)
363 return (_check_self_func_list)?1:0;
366 /** register a function to be called when matching for myself
367 * - return 0 on success, -1 on error
368 * - f must have same prototype as check_self() and return same kind of values
370 int register_check_self_func(check_self_f f)
372 struct _check_self_func *nf = 0;
373 nf=(struct _check_self_func*)pkg_malloc(sizeof(struct _check_self_func));
380 nf->next = _check_self_func_list;
381 _check_self_func_list = nf;
385 /** run registered check self functions
386 * returns 1 if true, 0 if false
388 int run_check_self_func(str* host, unsigned short port, unsigned short proto)
390 struct _check_self_func *sf = 0;
392 if(_check_self_func_list==NULL)
394 for(sf=_check_self_func_list; sf; sf=sf->next)
395 if(sf->fself(host, port, proto)==1)
400 /** checks if the proto: host:port is one of the address we listen on;
402 * if port==0, the port number is ignored
403 * if proto==0 (PROTO_NONE) the protocol is ignored
404 * returns 1 if true, 0 if false, -1 on error
405 * WARNING: uses str2ip6 so it will overwrite any previous
406 * unsaved result of this function (static buffer)
408 int check_self(str* host, unsigned short port, unsigned short proto)
411 if (grep_sock_info(host, port, proto)) {
414 /* try to look into the aliases*/
415 if (grep_aliases(host->s, host->len, port, proto)==0) {
416 ret = (_check_self_func_list==NULL)?0:run_check_self_func(host,
422 LM_DBG("host (%d:%.*s:%d) == me\n", proto, host->len, host->s, port);
424 LM_DBG("host (%d:%.*s:%d) != me\n", proto, host->len, host->s, port);
429 /** checks if the proto:port is one of the ports we listen on;
430 * if proto==0 (PROTO_NONE) the protocol is ignored
431 * returns 1 if true, 0 if false, -1 on error
433 int check_self_port(unsigned short port, unsigned short proto)
435 /* aliases do not contain different ports we can skip them */
436 if (grep_sock_info_by_port(port, proto)) {
437 LM_DBG("proto:port (%d:%d) == me\n", proto, port);
440 LM_DBG("proto:port (%d:%d) != me\n", proto, port);
447 /** forwards a request to dst
450 * dst - destination name, if non-null it will be resolved and
451 * send_info updated with the ip/port. Even if dst is non
452 * null send_info must contain the protocol and if a non
453 * default port or non srv. lookup is desired, the port must
455 * port - used only if dst!=0 (else the port in send_info->to is used)
456 * send_info - value/result partially filled dest_info structure:
457 * - send_info->proto and comp are used
458 * - send_info->to will be filled (dns)
459 * - send_info->send_flags is filled from the message
460 * - if the send_socket member is null, a send_socket will be
461 * chosen automatically
462 * WARNING: don't forget to zero-fill all the unused members (a non-zero
463 * random id along with proto==PROTO_TCP can have bad consequences, same for
464 * a bogus send_socket value)
466 * return: 0 (E_OK) on success; negative (E_*) on failure
468 int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
469 struct dest_info* send_info)
474 struct socket_info* orig_send_sock; /* initial send_sock */
476 struct ip_addr ip; /* debugging only */
478 struct onsend_info onsnd_info = {0};
479 #ifdef USE_DNS_FAILOVER
480 struct socket_info* prev_send_sock;
482 struct dns_srv_handle dns_srv_h;
486 memset(&dns_srv_h, 0, sizeof(struct dns_srv_handle));
490 orig_send_sock=send_info->send_sock;
491 proto=send_info->proto;
495 #ifdef USE_DNS_FAILOVER
496 if (cfg_get(core, core_cfg, use_dns_failover)){
497 dns_srv_handle_init(&dns_srv_h);
498 err=dns_sip_resolve2su(&dns_srv_h, &send_info->to, dst, port,
501 LM_ERR("resolving \"%.*s\" failed: %s [%d]\n",
502 dst->len, ZSW(dst->s), dns_strerror(err), err);
508 if (sip_hostport2su(&send_info->to, dst, port, &proto)<0){
509 LM_ERR("bad host name %.*s, dropping packet\n", dst->len, ZSW(dst->s));
514 send_info->send_flags=msg->fwd_send_flags;
515 /* calculate branch for outbound request;
516 * calculate is from transaction key, i.e., as an md5 of From/To/CallID/
517 * CSeq exactly the same way as TM does; good for reboot -- than messages
518 * belonging to transaction lost due to reboot will still be forwarded
519 * with the same branch parameter and will be match-able downstream
521 if (!char_msg_val( msg, md5 )) { /* parses transaction key */
522 LM_ERR("char_msg_val failed\n");
526 msg->hash_index=hash( msg->callid->body, get_cseq(msg)->number);
527 if (!branch_builder( msg->hash_index, 0, md5, 0 /* 0-th branch */,
528 msg->add_to_branch_s, &msg->add_to_branch_len )) {
529 LM_ERR("branch_builder failed\n");
533 /* try to send the message until success or all the ips are exhausted
534 * (if dns lookup is performed && the dns cache used ) */
535 #ifdef USE_DNS_FAILOVER
538 if (orig_send_sock==0) /* no forced send_sock => find it **/
539 send_info->send_sock=get_send_socket(msg, &send_info->to, proto);
540 if (send_info->send_sock==0){
541 LM_ERR("cannot forward to af %d, proto %d "
542 "no corresponding listening socket\n",
543 send_info->to.s.sa_family, proto);
544 ret=ser_error=E_NO_SOCKET;
545 #ifdef USE_DNS_FAILOVER
546 /* continue, maybe we find a socket for some other ip */
553 #ifdef USE_DNS_FAILOVER
554 if (prev_send_sock!=send_info->send_sock){
555 /* rebuild the message only if the send_sock changed */
556 prev_send_sock=send_info->send_sock;
558 if (buf) pkg_free(buf);
559 send_info->proto=proto;
560 buf = build_req_buf_from_sip_req(msg, &len, send_info, 0);
562 LM_ERR("building failed\n");
563 ret=E_OUT_OF_MEM; /* most probable */
566 #ifdef USE_DNS_FAILOVER
570 LM_DBG("Sending:\n%.*s.\n", (int)len, buf);
571 LM_DBG("orig. len=%d, new_len=%d, proto=%d\n",
572 msg->len, len, send_info->proto );
574 if (run_onsend(msg, send_info, buf, len)==0){
575 su2ip_addr(&ip, &send_info->to);
576 LM_INFO("request to %s:%d(%d) dropped (onsend_route)\n",
577 ip_addr2a(&ip), su_getport(&send_info->to), send_info->proto);
578 ser_error=E_OK; /* no error */
579 ret=E_ADM_PROHIBITED;
580 #ifdef USE_DNS_FAILOVER
581 continue; /* try another ip */
583 goto error; /* error ? */
586 #ifdef USE_DST_BLACKLIST
587 if (cfg_get(core, core_cfg, use_dst_blacklist)){
588 if (dst_is_blacklisted(send_info, msg)){
589 su2ip_addr(&ip, &send_info->to);
590 LM_DBG("blacklisted destination:%s:%d (%d)\n",
591 ip_addr2a(&ip), su_getport(&send_info->to), send_info->proto);
592 ret=ser_error=E_SEND;
593 #ifdef USE_DNS_FAILOVER
594 continue; /* try another ip */
602 if(unlikely(_forward_set_send_info==1)) {
603 onsnd_info.to=&send_info->to;
604 onsnd_info.send_sock=send_info->send_sock;
608 p_onsend=&onsnd_info;
611 if (msg_send(send_info, buf, len)<0){
613 ret=ser_error=E_SEND;
614 #ifdef USE_DST_BLACKLIST
615 (void)dst_blacklist_add(BLST_ERR_SEND, send_info, msg);
617 #ifdef USE_DNS_FAILOVER
618 continue; /* try another ip */
625 /* exit succcesfully */
628 #ifdef USE_DNS_FAILOVER
629 }while(dst && cfg_get(core, core_cfg, use_dns_failover) &&
630 dns_srv_handle_next(&dns_srv_h, err) &&
631 ((err=dns_sip_resolve2su(&dns_srv_h, &send_info->to, dst, port,
632 &proto, dns_flags))==0));
633 if ((err!=0) && (err!=-E_DNS_EOR)){
634 LM_ERR("resolving %.*s host name in uri failed: %s [%d] (dropping packet)\n",
635 dst->len, ZSW(dst->s),
636 dns_strerror(err), err);
637 ret=ser_error=E_BAD_ADDRESS;
644 #ifdef USE_DNS_FAILOVER
645 if (dst && cfg_get(core, core_cfg, use_dns_failover)){
646 dns_srv_handle_put(&dns_srv_h);
649 if (buf) pkg_free(buf);
650 /* received_buf & line_buf will be freed in receive_msg by free_lump_list*/
651 #if defined STATS_REQ_FWD_OK || defined STATS_REQ_FWD_DROP
655 STATS_REQ_FWD_DROP();
656 #endif /* STATS_REQ_FWD_* */
662 int update_sock_struct_from_via( union sockaddr_union* to,
664 struct via_body* via )
674 /* _local_ reply, we ignore any rport or received value
675 * (but we will send back to the original port if rport is
677 if ((msg->msg_flags&FL_FORCE_RPORT)||(via->rport))
678 port=msg->rcv.src_port;
680 name=&(via->host); /* received=ip in 1st via is ignored (it's
681 * not added by us so it's bad) */
683 /* "normal" reply, we use rport's & received value if present */
684 if (via->rport && via->rport->value.s){
685 LM_DBG("using 'rport'\n");
686 port=str2s(via->rport->value.s, via->rport->value.len, &err);
688 LM_ERR("bad rport value(%.*s)\n",
689 via->rport->value.len, via->rport->value.s);
694 LM_DBG("using 'received'\n");
695 name=&(via->received->value);
696 /* making sure that we won't do SRV lookup on "received"
697 * (possible if no DNS_IP_HACK is used)*/
698 if (port==0) port=via->port?via->port:SIP_PORT;
700 LM_DBG("using via host\n");
702 if (port==0) port=via->port;
705 /* we do now a malloc/memcpy because gethostbyname loves \0-terminated
706 * strings; but only if host is not null terminated (host.s[len] will
707 * always be ok for a via)
709 LM_DBG("check if dns lookup is needed for [%.*s]\n", name->len, name->s);
711 he=sip_resolvehost(name, &port, &proto);
714 LM_NOTICE("resolve_host(%.*s) failure\n", name->len, name->s);
718 LM_DBG("address is [%.*s] port %d proto %d\n", name->len, name->s,
719 (int)port, (int)proto);
721 hostent2su(to, he, 0, port);
727 /** removes first via & sends msg to the second
728 * - mode param controls if modules sip response callbacks are executed */
729 static int do_forward_reply(struct sip_msg* msg, int mode)
732 struct dest_info dst;
733 unsigned int new_len;
740 init_dest_info(&dst);
742 /*check if first via host = us */
744 if (check_self(&msg->via1->host,
745 msg->via1->port?msg->via1->port:SIP_PORT,
746 msg->via1->proto)!=1){
747 LM_ERR("host in first via!=me : %.*s:%d\n",
748 msg->via1->host.len, msg->via1->host.s, msg->via1->port);
749 /* send error msg back? */
754 /* check modules response_f functions */
755 if(likely(mode==0)) {
756 for (r=0; r<mod_response_cbk_no; r++)
757 if (mod_response_cbks[r](msg)==0) goto skip;
759 /* we have to forward the reply stateless, so we need second via -bogdan*/
760 if (parse_headers( msg, HDR_VIA2_F, 0 )==-1
761 || (msg->via2==0) || (msg->via2->error!=PARSE_OK))
763 /* no second via => error */
764 LM_DBG("reply cannot be forwarded - no 2nd via\n");
768 new_buf = build_res_buf_from_sip_res( msg, &new_len);
770 LM_ERR("building failed\n");
774 dst.proto=msg->via2->proto;
775 SND_FLAGS_OR(&dst.send_flags, &msg->fwd_send_flags, &msg->rpl_send_flags);
776 if (update_sock_struct_from_via( &dst.to, msg, msg->via2 )==-1) goto error;
778 dst.comp=msg->via2->comp_no;
781 #if defined USE_TCP || defined USE_SCTP
785 || dst.proto==PROTO_WS
787 || dst.proto==PROTO_TLS
788 || dst.proto==PROTO_WSS
792 #endif /* USE_SCTP */
795 dst.proto==PROTO_SCTP
796 #endif /* USE_SCTP */
798 /* find id in i param if it exists */
799 if (msg->via1->i && msg->via1->i->value.s){
800 s=msg->via1->i->value.s;
801 len=msg->via1->i->value.len;
802 LM_DBG("i=%.*s\n",len, ZSW(s));
803 if (reverse_hex2int(s, len, (unsigned int*)&dst.id)<0){
804 LM_ERR("bad via i param \"%.*s\"\n", len, ZSW(s));
812 apply_force_send_socket(&dst, msg);
814 /* call onsend_route */
815 if(dst.send_sock == NULL) {
816 dst.send_sock=get_send_socket(msg, &dst.to, dst.proto);
817 if (dst.send_sock==0){
818 LM_ERR("cannot forward reply\n");
822 if (onsend_route_enabled(SIP_REPLY)){
823 if (run_onsend(msg, &dst, new_buf, new_len)==0){
824 su2ip_addr(&ip, &(dst.to));
825 LM_ERR("reply to %s:%d(%d) dropped (onsend_route)\n",
826 ip_addr2a(&ip), su_getport(&(dst.to)), dst.proto);
827 goto error; /* error ? */
831 if (msg_send(&dst, new_buf, new_len)<0)
833 STATS_RPL_FWD_DROP();
837 LM_DBG("reply forwarded (2nd via address: %.*s port %d)\n",
838 msg->via2->host.len, msg->via2->host.s,
839 (int) msg->via2->port);
842 LM_DBG("reply forwarding finished (2nd via address: %.*s port %d)\n",
843 msg->via2->host.len, msg->via2->host.s,
844 (int) msg->via2->port);
851 if (new_buf) pkg_free(new_buf);
855 /** removes first via & sends msg to the second */
856 int forward_reply(struct sip_msg* msg)
858 return do_forward_reply(msg, 0);
861 /** removes first via & sends msg to the second - no module callbacks */
862 int forward_reply_nocb(struct sip_msg* msg)
864 return do_forward_reply(msg, 1);
867 static void apply_force_send_socket(struct dest_info* dst, struct sip_msg* msg)
869 if (msg->force_send_socket != 0) {
870 dst->send_sock = get_send_socket(msg, &dst->to, dst->proto);