Skip to content

Commit

Permalink
Import re-0.4.17.tar.gz
Browse files Browse the repository at this point in the history
  • Loading branch information
traviscross committed Jul 12, 2016
1 parent f8eb137 commit c71d858
Show file tree
Hide file tree
Showing 20 changed files with 220 additions and 57 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
# Master version number
VER_MAJOR := 0
VER_MINOR := 4
VER_PATCH := 16
VER_PATCH := 17

PROJECT := re
VERSION := 0.4.16
VERSION := 0.4.17

MK := mk/re.mk

Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
libre (0.4.17) unstable; urgency=medium

* version 0.4.17

-- Alfred E. Heggestad <aeh@db.org> Fri, 24 Jun 2016 15:00:00 +0100

libre (0.4.16) unstable; urgency=medium

* version 0.4.16
Expand Down
19 changes: 19 additions & 0 deletions docs/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
2016-06-24 Alfred E. Heggestad <aeh@db.org>

* Version 0.4.17

* build: add USE_OPENSSL_AES and USE_OPENSSL_HMAC

* dns: add key to dns_rrlist_sort()
add dns_rrlist_sort_addr

* tls: add tls_set_ciphers()
add tls_set_servername()

* sip: fix for stateless SIP requests
sort DNS RR entries by a fixed key

* stun: fix bug with 8-bit and 16-bit attributes on certain
platforms, such as MIPS


2016-04-27 Alfred E. Heggestad <aeh@db.org>

* Version 0.4.16
Expand Down
3 changes: 2 additions & 1 deletion include/re_dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ int dns_dname_encode(struct mbuf *mb, const char *name,
int dns_dname_decode(struct mbuf *mb, char **name, size_t start);
int dns_cstr_encode(struct mbuf *mb, const char *str);
int dns_cstr_decode(struct mbuf *mb, char **str);
void dns_rrlist_sort(struct list *rrl, uint16_t type);
void dns_rrlist_sort(struct list *rrl, uint16_t type, size_t key);
void dns_rrlist_sort_addr(struct list *rrl, size_t key);
struct dnsrr *dns_rrlist_apply(struct list *rrl, const char *name,
uint16_t type, uint16_t dnsclass,
bool recurse, dns_rrlist_h *rrlh, void *arg);
Expand Down
2 changes: 1 addition & 1 deletion include/re_sip.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ int sip_transp_laddr(struct sip *sip, struct sa *laddr, enum sip_transp tp,
/* request */
int sip_request(struct sip_request **reqp, struct sip *sip, bool stateful,
const char *met, int metl, const char *uri, int uril,
const struct uri *route, struct mbuf *mb,
const struct uri *route, struct mbuf *mb, size_t sortkey,
sip_send_h *sendh, sip_resp_h *resph, void *arg);
int sip_requestf(struct sip_request **reqp, struct sip *sip, bool stateful,
const char *met, const char *uri, const struct uri *route,
Expand Down
2 changes: 2 additions & 0 deletions include/re_tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ int tls_srtp_keyinfo(const struct tls_conn *tc, enum srtp_suite *suite,
uint8_t *cli_key, size_t cli_key_size,
uint8_t *srv_key, size_t srv_key_size);
const char *tls_cipher_name(const struct tls_conn *tc);
int tls_set_ciphers(struct tls *tls, const char *cipherv[], size_t count);
int tls_set_servername(struct tls_conn *tc, const char *servername);


/* TCP */
Expand Down
5 changes: 5 additions & 0 deletions mk/re.mk
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ CFLAGS += -DUSE_OPENSSL_SRTP -DUSE_DTLS_SRTP
USE_DTLS_SRTP := yes
endif

USE_OPENSSL_AES := yes
USE_OPENSSL_HMAC := yes

endif


Expand Down Expand Up @@ -658,6 +661,8 @@ info:
@echo " LIBRE_INC: $(LIBRE_INC)"
@echo " LIBRE_SO: $(LIBRE_SO)"
@echo " USE_OPENSSL: $(USE_OPENSSL)"
@echo " USE_OPENSSL_AES: $(USE_OPENSSL_AES)"
@echo " USE_OPENSSL_HMAC: $(USE_OPENSSL_HMAC)"
@echo " USE_TLS: $(USE_TLS)"
@echo " USE_DTLS: $(USE_DTLS)"
@echo " USE_DTLS_SRTP: $(USE_DTLS_SRTP)"
Expand Down
2 changes: 1 addition & 1 deletion src/aes/mod.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright (C) 2010 Creytiv.com
#

ifneq ($(USE_OPENSSL),)
ifneq ($(USE_OPENSSL_AES),)
SRCS += aes/openssl/aes.c
else ifneq ($(USE_APPLE_COMMONCRYPTO),)
SRCS += aes/apple/aes.c
Expand Down
83 changes: 68 additions & 15 deletions src/dns/rrlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
*
* Copyright (C) 2010 Creytiv.com
*/
#include <string.h>
#include <re_types.h>
#include <re_list.h>
#include <re_hash.h>
#include <re_mbuf.h>
#include <re_fmt.h>
#include <re_dns.h>
Expand All @@ -15,31 +17,56 @@ enum {
};


struct sort {
uint16_t type;
uint32_t key;
};


static uint32_t sidx(const struct dnsrr *rr, uint32_t key)
{
uint32_t addr[4];

switch (rr->type) {

case DNS_TYPE_A:
return rr->rdata.a.addr ^ key;

case DNS_TYPE_AAAA:
memcpy(addr, rr->rdata.aaaa.addr, 16);

return addr[0] ^ addr[1] ^ addr[2] ^ addr[3] ^ key;

case DNS_TYPE_SRV:
return ((hash_fast_str(rr->rdata.srv.target) & 0xfff) ^ key) +
rr->rdata.srv.weight;

default:
return 0;
}
}


static bool std_sort_handler(struct le *le1, struct le *le2, void *arg)
{
struct dnsrr *rr1 = le1->data;
struct dnsrr *rr2 = le2->data;
const uint16_t type = *(uint16_t *)arg;
struct sort *sort = arg;

if (type != rr1->type)
return type != rr2->type;
if (sort->type != rr1->type)
return sort->type != rr2->type;

if (type != rr2->type)
if (sort->type != rr2->type)
return true;

switch (type) {
switch (sort->type) {

case DNS_TYPE_MX:
return rr1->rdata.mx.pref <= rr2->rdata.mx.pref;

case DNS_TYPE_SRV:
if (rr1->rdata.srv.pri == rr2->rdata.srv.pri) {

if (rr1->rdata.srv.weight)
return 0 != rr2->rdata.srv.weight;

return true;
}
if (rr1->rdata.srv.pri == rr2->rdata.srv.pri)
return sidx(rr1, sort->key) >= sidx(rr2, sort->key);

return rr1->rdata.srv.pri < rr2->rdata.srv.pri;

Expand All @@ -57,16 +84,42 @@ static bool std_sort_handler(struct le *le1, struct le *le2, void *arg)
}


static bool addr_sort_handler(struct le *le1, struct le *le2, void *arg)
{
struct dnsrr *rr1 = le1->data;
struct dnsrr *rr2 = le2->data;
struct sort *sort = arg;

return sidx(rr1, sort->key) >= sidx(rr2, sort->key);
}


/**
* Sort a list of DNS Resource Records
*
* @param rrl DNS Resource Record list
* @param type DNS Record type
* @param key Sort key
*/
void dns_rrlist_sort(struct list *rrl, uint16_t type, size_t key)
{
struct sort sort = {type, (uint32_t)key>>5};

list_sort(rrl, std_sort_handler, &sort);
}


/**
* Sort a list of A/AAAA DNS Resource Records
*
* @param rrl DNS Resource Record list
* @param key Sort key
*/
void dns_rrlist_sort(struct list *rrl, uint16_t type)
void dns_rrlist_sort_addr(struct list *rrl, size_t key)
{
list_sort(rrl, std_sort_handler, &type);
/* todo add SRV postprocessing for weighted load balancing. */
struct sort sort = {0, (uint32_t)key>>5};

list_sort(rrl, addr_sort_handler, &sort);
}


Expand Down
2 changes: 1 addition & 1 deletion src/hmac/mod.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

SRCS += hmac/hmac_sha1.c

ifneq ($(USE_OPENSSL),)
ifneq ($(USE_OPENSSL_HMAC),)
SRCS += hmac/openssl/hmac.c
else ifneq ($(USE_APPLE_COMMONCRYPTO),)
SRCS += hmac/apple/hmac.c
Expand Down
4 changes: 2 additions & 2 deletions src/json/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static int object_start(const struct pl *pl_name, unsigned idx,
struct json_handlers *h)
{
char *name = NULL;
int err;
int err = 0;

if (pl_name->p) {

Expand All @@ -249,7 +249,7 @@ static int array_start(const struct pl *pl_name, unsigned idx,
struct json_handlers *h)
{
char *name = NULL;
int err;
int err = 0;

if (pl_name->p) {

Expand Down
2 changes: 1 addition & 1 deletion src/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
- Look at howto optimise main loop
*/

#ifndef RELEASE
#if !defined (RELEASE) && !defined (MAIN_DEBUG)
#define MAIN_DEBUG 1 /**< Enable main loop debugging */
#endif

Expand Down
10 changes: 10 additions & 0 deletions src/sip/dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct sip_dialog {
char *ltag;
char *rtag;
char *uri;
uint32_t hash;
uint32_t lseq;
uint32_t rseq;
size_t cpos;
Expand Down Expand Up @@ -105,6 +106,7 @@ int sip_dialog_alloc(struct sip_dialog **dlgp,
if (!dlg)
return ENOMEM;

dlg->hash = hash_fast_str(from_uri);
dlg->lseq = rand_u16();

err = str_dup(&dlg->uri, uri);
Expand Down Expand Up @@ -211,6 +213,7 @@ int sip_dialog_accept(struct sip_dialog **dlgp, const struct sip_msg *msg)
if (!dlg)
return ENOMEM;

dlg->hash = rand_u32();
dlg->lseq = rand_u16();
dlg->rseq = msg->cseq.num;

Expand Down Expand Up @@ -401,6 +404,7 @@ int sip_dialog_fork(struct sip_dialog **dlgp, struct sip_dialog *odlg,

dlg->callid = mem_ref(odlg->callid);
dlg->ltag = mem_ref(odlg->ltag);
dlg->hash = odlg->hash;
dlg->lseq = odlg->lseq;
dlg->rseq = msg->req ? msg->cseq.num : 0;

Expand Down Expand Up @@ -560,6 +564,12 @@ const struct uri *sip_dialog_route(const struct sip_dialog *dlg)
}


uint32_t sip_dialog_hash(const struct sip_dialog *dlg)
{
return dlg ? dlg->hash : 0;
}


/**
* Get the Call-ID from a SIP Dialog
*
Expand Down

0 comments on commit c71d858

Please sign in to comment.