FreeCalypso > hg > themwi-rtp-lib
annotate src/endp_bind.c @ 37:8f1700a42ca5 default tip
set_remote: add functions for IPv6 and for sockaddr_{in,in6}
A convenient way to pass in remote end address as struct sockaddr_in
is needed for tw-border-mgw; IPv6 support will be needed in order to
bring twrtp_endp into Osmocom mainline.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 23 Nov 2024 19:08:28 +0000 |
parents | 2032201bd034 |
children |
rev | line source |
---|---|
21
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Here we implement the wrapper function that first obtains a pair of fds |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * bound to IP & port for RTP & RTCP, then registers them with twrtp_endp. |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdint.h> |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdbool.h> |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <errno.h> |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <themwi/rtp/endp.h> |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <themwi/rtp/fdpair.h> |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 int twrtp_endp_bind_ip_port(struct twrtp_endp *endp, const char *ip, |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 uint16_t port) |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 { |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 int rc; |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 if (endp->register_done) |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 return -EBUSY; |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 rc = twrtp_bind_fdpair(ip, port, &endp->rtp_fd, &endp->rtcp_fd); |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 if (rc < 0) |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 return rc; |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 return twrtp_endp_register_fds(endp); |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 } |