comparison src/set_remote.c @ 22:587437b62ed5

implement twrtp_endp_set_remote_ipv4()
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 07 Jul 2024 04:33:55 +0000
parents
children 8f1700a42ca5
comparison
equal deleted inserted replaced
21:2032201bd034 22:587437b62ed5
1 /*
2 * Here we implement functions for setting the remote end on themwi_endp,
3 * initially only IPv4, then possibly IPv6 in the future.
4 */
5
6 #include <sys/socket.h>
7 #include <netinet/in.h>
8 #include <arpa/inet.h>
9 #include <stdint.h>
10 #include <stdbool.h>
11 #include <string.h>
12
13 #include <themwi/rtp/endp.h>
14
15 void twrtp_endp_set_remote_ipv4(struct twrtp_endp *endp,
16 const struct in_addr *ip, uint16_t port)
17 {
18 endp->rtp_remote.u.sin.sin_family = AF_INET;
19 memcpy(&endp->rtp_remote.u.sin.sin_addr, ip, sizeof(struct in_addr));
20 endp->rtp_remote.u.sin.sin_port = htons(port);
21
22 endp->rtcp_remote.u.sin.sin_family = AF_INET;
23 memcpy(&endp->rtcp_remote.u.sin.sin_addr, ip, sizeof(struct in_addr));
24 endp->rtcp_remote.u.sin.sin_port = htons(port + 1);
25
26 endp->remote_set = true;
27 }