# HG changeset patch # User Mychaela Falconia # Date 1720326835 0 # Node ID 587437b62ed5d06b699c3dbc0bae247b1ca23acf # Parent 2032201bd034dec1977a531378751e5433996b83 implement twrtp_endp_set_remote_ipv4() diff -r 2032201bd034 -r 587437b62ed5 include/endp.h --- a/include/endp.h Sun Jul 07 04:17:18 2024 +0000 +++ b/include/endp.h Sun Jul 07 04:33:55 2024 +0000 @@ -61,3 +61,6 @@ int twrtp_endp_register_fds(struct twrtp_endp *endp); int twrtp_endp_bind_ip_port(struct twrtp_endp *endp, const char *ip, uint16_t port); + +void twrtp_endp_set_remote_ipv4(struct twrtp_endp *endp, + const struct in_addr *ip, uint16_t port); diff -r 2032201bd034 -r 587437b62ed5 src/Makefile --- a/src/Makefile Sun Jul 07 04:17:18 2024 +0000 +++ b/src/Makefile Sun Jul 07 04:33:55 2024 +0000 @@ -1,5 +1,5 @@ -OBJS= bind_fdpair.o endp_bind.o endp_create.o endp_register.o twjit.o \ - twjit_in.o twjit_out.o twjit_vty.o +OBJS= bind_fdpair.o endp_bind.o endp_create.o endp_register.o set_remote.o \ + twjit.o twjit_in.o twjit_out.o twjit_vty.o LIB= libtwrtp.a include ../config.defs diff -r 2032201bd034 -r 587437b62ed5 src/set_remote.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/set_remote.c Sun Jul 07 04:33:55 2024 +0000 @@ -0,0 +1,27 @@ +/* + * Here we implement functions for setting the remote end on themwi_endp, + * initially only IPv4, then possibly IPv6 in the future. + */ + +#include +#include +#include +#include +#include +#include + +#include + +void twrtp_endp_set_remote_ipv4(struct twrtp_endp *endp, + const struct in_addr *ip, uint16_t port) +{ + endp->rtp_remote.u.sin.sin_family = AF_INET; + memcpy(&endp->rtp_remote.u.sin.sin_addr, ip, sizeof(struct in_addr)); + endp->rtp_remote.u.sin.sin_port = htons(port); + + endp->rtcp_remote.u.sin.sin_family = AF_INET; + memcpy(&endp->rtcp_remote.u.sin.sin_addr, ip, sizeof(struct in_addr)); + endp->rtcp_remote.u.sin.sin_port = htons(port + 1); + + endp->remote_set = true; +}