sync with trunk
This commit is contained in:
commit
8c65bf87d2
12 changed files with 103 additions and 22 deletions
|
@ -136,12 +136,12 @@ enum {
|
|||
|
||||
|
||||
struct sip_via {
|
||||
struct pl transp;
|
||||
struct pl sentby;
|
||||
struct sa addr;
|
||||
struct pl params;
|
||||
struct pl branch;
|
||||
struct pl val;
|
||||
enum sip_transp tp;
|
||||
};
|
||||
|
||||
struct sip_addr {
|
||||
|
@ -231,19 +231,23 @@ typedef void(sip_keepalive_h)(int err, void *arg);
|
|||
int sip_alloc(struct sip **sipp, struct dnsc *dnsc, uint32_t ctsz,
|
||||
uint32_t stsz, uint32_t tcsz, const char *software,
|
||||
sip_exit_h *exith, void *arg);
|
||||
int sip_transp_add(struct sip *sip, enum sip_transp tp,
|
||||
const struct sa *laddr, ...);
|
||||
void sip_transp_flush(struct sip *sip);
|
||||
bool sip_transp_isladdr(const struct sip *sip, enum sip_transp tp,
|
||||
const struct sa *laddr);
|
||||
void sip_close(struct sip *sip, bool force);
|
||||
int sip_listen(struct sip_lsnr **lsnrp, struct sip *sip, bool req,
|
||||
sip_msg_h *msgh, void *arg);
|
||||
int sip_debug(struct re_printf *pf, const struct sip *sip);
|
||||
int sip_send(struct sip *sip, void *sock, enum sip_transp tp,
|
||||
const struct sa *dst, struct mbuf *mb);
|
||||
|
||||
|
||||
/* transport */
|
||||
int sip_transp_add(struct sip *sip, enum sip_transp tp,
|
||||
const struct sa *laddr, ...);
|
||||
void sip_transp_flush(struct sip *sip);
|
||||
bool sip_transp_isladdr(const struct sip *sip, enum sip_transp tp,
|
||||
const struct sa *laddr);
|
||||
const char *sip_transp_name(enum sip_transp tp);
|
||||
const char *sip_transp_param(enum sip_transp tp);
|
||||
uint16_t sip_transp_port(enum sip_transp tp, uint16_t port);
|
||||
|
||||
|
||||
/* request */
|
||||
|
|
|
@ -57,6 +57,12 @@ const char *sys_os_get(void);
|
|||
const char *sys_libre_version_get(void);
|
||||
int sys_coredump_set(bool enable);
|
||||
int sys_daemon(void);
|
||||
void sys_usleep(unsigned int us);
|
||||
|
||||
static inline void sys_msleep(unsigned int ms)
|
||||
{
|
||||
sys_usleep(ms * 1000);
|
||||
}
|
||||
|
||||
|
||||
uint16_t sys_htols(uint16_t v);
|
||||
|
|
|
@ -120,6 +120,7 @@ SOURCE daemon.c
|
|||
SOURCE endian.c
|
||||
SOURCE rand.c
|
||||
SOURCE sys.c
|
||||
SOURCE symbian\sleep.cpp
|
||||
|
||||
SOURCEPATH ..\..\src\telev
|
||||
SOURCE telev.c
|
||||
|
|
|
@ -763,6 +763,9 @@
|
|||
<File
|
||||
RelativePath="..\..\src\sys\rand.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\sys\sleep.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\sys\sys.c">
|
||||
</File>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#define COMP_MASK 0xc0
|
||||
#define OFFSET_MASK 0x3fff
|
||||
#define COMP_LOOP 255
|
||||
|
||||
|
||||
struct dname {
|
||||
|
@ -140,15 +141,15 @@ int dns_dname_encode(struct mbuf *mb, const char *name,
|
|||
|
||||
int dns_dname_decode(struct mbuf *mb, char **name, size_t start)
|
||||
{
|
||||
uint32_t i = 0, loopc = 0;
|
||||
bool comp = false;
|
||||
size_t pos = 0;
|
||||
char buf[256];
|
||||
uint32_t i = 0;
|
||||
|
||||
if (!mb || !name)
|
||||
return EINVAL;
|
||||
|
||||
while (mbuf_get_left(mb)) {
|
||||
while (mb->pos < mb->end) {
|
||||
|
||||
uint8_t len = mb->buf[mb->pos++];
|
||||
if (!len) {
|
||||
|
@ -168,6 +169,9 @@ int dns_dname_decode(struct mbuf *mb, char **name, size_t start)
|
|||
else if ((len & COMP_MASK) == COMP_MASK) {
|
||||
uint16_t offset;
|
||||
|
||||
if (loopc++ > COMP_LOOP)
|
||||
break;
|
||||
|
||||
--mb->pos;
|
||||
|
||||
offset = ntohs(mbuf_read_u16(mb)) & OFFSET_MASK;
|
||||
|
|
|
@ -78,7 +78,9 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
|
|||
for (i = 0; i < NS_IN6ADDRSZ; i++)
|
||||
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
|
||||
best.base = -1;
|
||||
best.len = 0;
|
||||
cur.base = -1;
|
||||
cur.len = 0;
|
||||
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
|
||||
if (words[i] == 0) {
|
||||
if (cur.base == -1)
|
||||
|
|
|
@ -74,7 +74,6 @@ int sip_transp_laddr(struct sip *sip, struct sa *laddr, enum sip_transp tp,
|
|||
bool sip_transp_supported(struct sip *sip, enum sip_transp tp, int af);
|
||||
const char *sip_transp_srvid(enum sip_transp tp);
|
||||
bool sip_transp_reliable(enum sip_transp tp);
|
||||
uint16_t sip_transp_port(enum sip_transp tp, uint16_t port);
|
||||
int sip_transp_debug(struct re_printf *pf, const struct sip *sip);
|
||||
|
||||
|
||||
|
|
|
@ -448,17 +448,6 @@ static void tcp_estab_handler(void *arg)
|
|||
struct le *le;
|
||||
int err;
|
||||
|
||||
#ifdef USE_TLS
|
||||
if (conn->sc) {
|
||||
char cn[256];
|
||||
|
||||
err = tls_verify_cert(conn->sc, cn, sizeof(cn));
|
||||
|
||||
re_fprintf(stderr, "CN: '%s' (%sverified)\n",
|
||||
cn, err ? "not " : "");
|
||||
}
|
||||
#endif
|
||||
|
||||
conn->established = true;
|
||||
|
||||
le = list_head(&conn->ql);
|
||||
|
|
|
@ -28,7 +28,7 @@ static int decode_hostport(const struct pl *hostport, struct pl *host,
|
|||
|
||||
int sip_via_decode(struct sip_via *via, const struct pl *pl)
|
||||
{
|
||||
struct pl host, port;
|
||||
struct pl transp, host, port;
|
||||
int err;
|
||||
|
||||
if (!via || !pl)
|
||||
|
@ -37,11 +37,20 @@ int sip_via_decode(struct sip_via *via, const struct pl *pl)
|
|||
err = re_regex(pl->p, pl->l,
|
||||
"SIP[ \t\r\n]*/[ \t\r\n]*2.0[ \t\r\n]*/[ \t\r\n]*"
|
||||
"[A-Z]+[ \t\r\n]*[^; \t\r\n]+[ \t\r\b]*[^]*",
|
||||
NULL, NULL, NULL, NULL, &via->transp,
|
||||
NULL, NULL, NULL, NULL, &transp,
|
||||
NULL, &via->sentby, NULL, &via->params);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (!pl_strcmp(&transp, "TCP"))
|
||||
via->tp = SIP_TRANSP_TCP;
|
||||
else if (!pl_strcmp(&transp, "TLS"))
|
||||
via->tp = SIP_TRANSP_TLS;
|
||||
else if (!pl_strcmp(&transp, "UDP"))
|
||||
via->tp = SIP_TRANSP_UDP;
|
||||
else
|
||||
via->tp = SIP_TRANSP_NONE;
|
||||
|
||||
err = decode_hostport(&via->sentby, &host, &port);
|
||||
if (err)
|
||||
return err;
|
||||
|
|
|
@ -7,4 +7,5 @@
|
|||
SRCS += sys/daemon.c
|
||||
SRCS += sys/endian.c
|
||||
SRCS += sys/rand.c
|
||||
SRCS += sys/sleep.c
|
||||
SRCS += sys/sys.c
|
||||
|
|
45
src/sys/sleep.c
Normal file
45
src/sys/sleep.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
* @file sleep.c System sleep functions
|
||||
*
|
||||
* Copyright (C) 2010 Creytiv.com
|
||||
*/
|
||||
#include <re_types.h>
|
||||
#include <re_fmt.h>
|
||||
#include <re_sys.h>
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#define _BSD_SOURCE 1
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Blocking sleep for [us] number of microseconds
|
||||
*
|
||||
* @param us Number of microseconds to sleep
|
||||
*/
|
||||
void sys_usleep(unsigned int us)
|
||||
{
|
||||
if (!us)
|
||||
return;
|
||||
|
||||
#ifdef WIN32
|
||||
Sleep(us / 1000);
|
||||
#elif defined(HAVE_SELECT)
|
||||
do {
|
||||
struct timeval tv;
|
||||
|
||||
tv.tv_sec = us / 1000000;
|
||||
tv.tv_usec = us % 1000000;
|
||||
|
||||
(void)select(0, NULL, NULL, NULL, &tv);
|
||||
} while (0);
|
||||
#else
|
||||
(void)usleep(us);
|
||||
#endif
|
||||
}
|
18
src/sys/symbian/sleep.cpp
Normal file
18
src/sys/symbian/sleep.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* @file sleep.cpp System sleep for Symbian
|
||||
*
|
||||
* Copyright (C) 2010 Creytiv.com
|
||||
*/
|
||||
|
||||
#include <e32std.h>
|
||||
|
||||
extern "C" {
|
||||
#include <re_types.h>
|
||||
#include <re_sys.h>
|
||||
}
|
||||
|
||||
|
||||
void sys_usleep(unsigned int us)
|
||||
{
|
||||
User::After(us);
|
||||
}
|
Loading…
Add table
Reference in a new issue