Skip to content

Commit 991a410

Browse files
committedMay 9, 2024
socket_info: provide send callback for internal listeners
When a proto hooks on top of another proto to operate (such as proto_ipsec is using proto_udp and proto_tcp listners), we need a hook before sending a message out.
1 parent 018e9be commit 991a410

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
 

‎forward.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static inline int msg_send( const struct socket_info* send_sock, int proto,
102102
out_buff.len = len;
103103
out_buff.s = buf;
104104

105-
/* determin the send socket */
105+
/* determine the send socket */
106106
if (send_sock==0)
107107
send_sock=get_send_socket(0, to, proto);
108108
if (send_sock==0){
@@ -119,6 +119,8 @@ static inline int msg_send( const struct socket_info* send_sock, int proto,
119119

120120
/* update the length for further processing */
121121
len = out_buff.len;
122+
if ((send_sock->flags & SI_INTERNAL) && send_sock->internal_proto != PROTO_NONE)
123+
proto = send_sock->internal_proto;
122124

123125
if (protos[proto].tran.send(send_sock, out_buff.s, out_buff.len, to,id)<0){
124126
get_su_info(to, ip, port);

‎socket_info.h

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct socket_info {
6363
unsigned short workers;
6464
struct scaling_profile *s_profile;
6565
void *extra_data;
66+
enum sip_protos internal_proto;
6667

6768
/* these are IP-level local/remote ports used during the last write op via
6869
* this sock (or a connection belonging to this sock). These values are

0 commit comments

Comments
 (0)
Please sign in to comment.