mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-08 12:18:42 +00:00
Minor cleanups
This commit is contained in:
parent
5e8df049fb
commit
eeba61ccd5
@ -957,7 +957,7 @@ fragment_val_str(u8 val)
|
|||||||
return "???";
|
return "???";
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static uint
|
||||||
net_format_flow(char *buf, uint blen, const byte *data, uint dlen, int ipv6)
|
net_format_flow(char *buf, uint blen, const byte *data, uint dlen, int ipv6)
|
||||||
{
|
{
|
||||||
buffer b = {
|
buffer b = {
|
||||||
@ -1125,7 +1125,7 @@ net_format_flow(char *buf, uint blen, const byte *data, uint dlen, int ipv6)
|
|||||||
* of written chars. If final string is too large, the string will ends the with
|
* of written chars. If final string is too large, the string will ends the with
|
||||||
* ' ...}' sequence and zero-terminator.
|
* ' ...}' sequence and zero-terminator.
|
||||||
*/
|
*/
|
||||||
int
|
uint
|
||||||
flow4_net_format(char *buf, uint blen, const net_addr_flow4 *f)
|
flow4_net_format(char *buf, uint blen, const net_addr_flow4 *f)
|
||||||
{
|
{
|
||||||
return net_format_flow(buf, blen, f->data, f->length - sizeof(net_addr_flow4), 0);
|
return net_format_flow(buf, blen, f->data, f->length - sizeof(net_addr_flow4), 0);
|
||||||
@ -1141,7 +1141,7 @@ flow4_net_format(char *buf, uint blen, const net_addr_flow4 *f)
|
|||||||
* of written chars. If final string is too large, the string will ends the with
|
* of written chars. If final string is too large, the string will ends the with
|
||||||
* ' ...}' sequence and zero-terminator.
|
* ' ...}' sequence and zero-terminator.
|
||||||
*/
|
*/
|
||||||
int
|
uint
|
||||||
flow6_net_format(char *buf, uint blen, const net_addr_flow6 *f)
|
flow6_net_format(char *buf, uint blen, const net_addr_flow6 *f)
|
||||||
{
|
{
|
||||||
return net_format_flow(buf, blen, f->data, f->length - sizeof(net_addr_flow6), 1);
|
return net_format_flow(buf, blen, f->data, f->length - sizeof(net_addr_flow6), 1);
|
||||||
|
@ -131,7 +131,7 @@ void flow6_validate_cf(net_addr_flow6 *f);
|
|||||||
* Net Formatting
|
* Net Formatting
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int flow4_net_format(char *buf, uint blen, const net_addr_flow4 *f);
|
uint flow4_net_format(char *buf, uint blen, const net_addr_flow4 *f);
|
||||||
int flow6_net_format(char *buf, uint blen, const net_addr_flow6 *f);
|
uint flow6_net_format(char *buf, uint blen, const net_addr_flow6 *f);
|
||||||
|
|
||||||
#endif /* _BIRD_FLOWSPEC_H_ */
|
#endif /* _BIRD_FLOWSPEC_H_ */
|
||||||
|
@ -30,20 +30,17 @@ t_read_length(void)
|
|||||||
{
|
{
|
||||||
byte data[] = { 0xcc, 0xcc, 0xcc };
|
byte data[] = { 0xcc, 0xcc, 0xcc };
|
||||||
|
|
||||||
u16 get;
|
|
||||||
u16 expect;
|
|
||||||
|
|
||||||
for (uint expect = 0; expect < 0xf0; expect++)
|
for (uint expect = 0; expect < 0xf0; expect++)
|
||||||
{
|
{
|
||||||
*data = expect;
|
*data = expect;
|
||||||
get = flow_read_length(data);
|
uint get = flow_read_length(data);
|
||||||
bt_assert_msg(get == expect, "Testing get length 0x%02x (get 0x%02x)", expect, get);
|
bt_assert_msg(get == expect, "Testing get length 0x%02x (get 0x%02x)", expect, get);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint expect = 0; expect <= 0xfff; expect++)
|
for (uint expect = 0; expect <= 0xfff; expect++)
|
||||||
{
|
{
|
||||||
put_u16(data, expect | 0xf000);
|
put_u16(data, expect | 0xf000);
|
||||||
get = flow_read_length(data);
|
uint get = flow_read_length(data);
|
||||||
bt_assert_msg(get == expect, "Testing get length 0x%03x (get 0x%03x)", expect, get);
|
bt_assert_msg(get == expect, "Testing get length 0x%03x (get 0x%03x)", expect, get);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,12 +51,10 @@ static int
|
|||||||
t_write_length(void)
|
t_write_length(void)
|
||||||
{
|
{
|
||||||
byte data[] = { 0xcc, 0xcc, 0xcc };
|
byte data[] = { 0xcc, 0xcc, 0xcc };
|
||||||
uint offset;
|
|
||||||
byte *c;
|
|
||||||
|
|
||||||
for (uint expect = 0; expect <= 0xfff; expect++)
|
for (uint expect = 0; expect <= 0xfff; expect++)
|
||||||
{
|
{
|
||||||
offset = flow_write_length(data, expect);
|
uint offset = flow_write_length(data, expect);
|
||||||
|
|
||||||
uint set = (expect < 0xf0) ? *data : (get_u16(data) & 0x0fff);
|
uint set = (expect < 0xf0) ? *data : (get_u16(data) & 0x0fff);
|
||||||
bt_assert_msg(set == expect, "Testing set length 0x%03x (set 0x%03x)", expect, set);
|
bt_assert_msg(set == expect, "Testing set length 0x%03x (set 0x%03x)", expect, set);
|
||||||
|
@ -2,3 +2,5 @@ src := babel.c packets.c
|
|||||||
obj := $(src-o-files)
|
obj := $(src-o-files)
|
||||||
$(all-daemon)
|
$(all-daemon)
|
||||||
$(cf-local)
|
$(cf-local)
|
||||||
|
|
||||||
|
tests_objs := $(tests_objs) $(src-o-files)
|
@ -2,3 +2,5 @@ src := rpki.c packets.c tcp_transport.c ssh_transport.c transport.c
|
|||||||
obj := $(src-o-files)
|
obj := $(src-o-files)
|
||||||
$(all-daemon)
|
$(all-daemon)
|
||||||
$(cf-local)
|
$(cf-local)
|
||||||
|
|
||||||
|
tests_objs := $(tests_objs) $(src-o-files)
|
@ -531,8 +531,6 @@ rpki_send_pdu(struct rpki_cache *cache, const void *pdu, const uint len)
|
|||||||
static int
|
static int
|
||||||
rpki_check_receive_packet(struct rpki_cache *cache, const struct pdu_header *pdu)
|
rpki_check_receive_packet(struct rpki_cache *cache, const struct pdu_header *pdu)
|
||||||
{
|
{
|
||||||
struct rpki_proto *p = cache->p;
|
|
||||||
int error = RPKI_SUCCESS;
|
|
||||||
u32 pdu_len = ntohl(pdu->len);
|
u32 pdu_len = ntohl(pdu->len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -557,7 +555,6 @@ rpki_check_receive_packet(struct rpki_cache *cache, const struct pdu_header *pdu
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
else if (cache->last_update == 0
|
else if (cache->last_update == 0
|
||||||
&& pdu->ver >= RPKI_MIN_VERSION
|
|
||||||
&& pdu->ver <= RPKI_MAX_VERSION
|
&& pdu->ver <= RPKI_MAX_VERSION
|
||||||
&& pdu->ver < cache->version)
|
&& pdu->ver < cache->version)
|
||||||
{
|
{
|
||||||
@ -608,7 +605,6 @@ rpki_handle_error_pdu(struct rpki_cache *cache, const struct pdu_error *pdu)
|
|||||||
case UNSUPPORTED_PROTOCOL_VER:
|
case UNSUPPORTED_PROTOCOL_VER:
|
||||||
CACHE_TRACE(D_PACKETS, cache, "Client uses unsupported protocol version");
|
CACHE_TRACE(D_PACKETS, cache, "Client uses unsupported protocol version");
|
||||||
if (pdu->ver <= RPKI_MAX_VERSION &&
|
if (pdu->ver <= RPKI_MAX_VERSION &&
|
||||||
pdu->ver >= RPKI_MIN_VERSION &&
|
|
||||||
pdu->ver < cache->version)
|
pdu->ver < cache->version)
|
||||||
{
|
{
|
||||||
CACHE_TRACE(D_EVENTS, cache, "Downgrading from protocol version %d to version %d", cache->version, pdu->ver);
|
CACHE_TRACE(D_EVENTS, cache, "Downgrading from protocol version %d to version %d", cache->version, pdu->ver);
|
||||||
|
@ -358,7 +358,7 @@ rpki_stop_retry_timer_event(struct rpki_cache *cache)
|
|||||||
tm_stop(cache->retry_timer);
|
tm_stop(cache->retry_timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void UNUSED
|
||||||
rpki_stop_expire_timer_event(struct rpki_cache *cache)
|
rpki_stop_expire_timer_event(struct rpki_cache *cache)
|
||||||
{
|
{
|
||||||
CACHE_DBG(cache, "Stop");
|
CACHE_DBG(cache, "Stop");
|
||||||
@ -637,7 +637,7 @@ rpki_shutdown(struct proto *P)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rpki_try_fast_reconnect(struct rpki_cache *cache, struct rpki_config *new, struct rpki_config *old)
|
rpki_try_fast_reconnect(struct rpki_cache *cache)
|
||||||
{
|
{
|
||||||
if (cache->state == RPKI_CS_ESTABLISHED)
|
if (cache->state == RPKI_CS_ESTABLISHED)
|
||||||
{
|
{
|
||||||
@ -661,11 +661,10 @@ rpki_try_fast_reconnect(struct rpki_cache *cache, struct rpki_config *new, struc
|
|||||||
* protocol. Returns |NEED_TO_RESTART| or |SUCCESSFUL_RECONF|.
|
* protocol. Returns |NEED_TO_RESTART| or |SUCCESSFUL_RECONF|.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
rpki_reconfigure_cache(struct rpki_proto *p, struct rpki_cache *cache, struct rpki_config *new, struct rpki_config *old)
|
rpki_reconfigure_cache(struct rpki_proto *p UNUSED, struct rpki_cache *cache, struct rpki_config *new, struct rpki_config *old)
|
||||||
{
|
{
|
||||||
u8 try_fast_reconnect = 0;
|
u8 try_fast_reconnect = 0;
|
||||||
|
|
||||||
|
|
||||||
if (strcmp(old->hostname, new->hostname) != 0)
|
if (strcmp(old->hostname, new->hostname) != 0)
|
||||||
{
|
{
|
||||||
CACHE_TRACE(D_EVENTS, cache, "Cache server address changed to %s", new->hostname);
|
CACHE_TRACE(D_EVENTS, cache, "Cache server address changed to %s", new->hostname);
|
||||||
@ -710,7 +709,7 @@ rpki_reconfigure_cache(struct rpki_proto *p, struct rpki_cache *cache, struct rp
|
|||||||
#undef TEST_INTERVAL
|
#undef TEST_INTERVAL
|
||||||
|
|
||||||
if (try_fast_reconnect)
|
if (try_fast_reconnect)
|
||||||
return rpki_try_fast_reconnect(cache, new, old);
|
return rpki_try_fast_reconnect(cache);
|
||||||
|
|
||||||
return SUCCESSFUL_RECONF;
|
return SUCCESSFUL_RECONF;
|
||||||
}
|
}
|
||||||
@ -907,7 +906,7 @@ rpki_postconfig(struct proto_config *CF)
|
|||||||
static void
|
static void
|
||||||
rpki_copy_config(struct proto_config *dest, struct proto_config *src)
|
rpki_copy_config(struct proto_config *dest, struct proto_config *src)
|
||||||
{
|
{
|
||||||
/* Just a shallow copy */
|
/* FIXME: Should copy transport */
|
||||||
}
|
}
|
||||||
|
|
||||||
struct protocol proto_rpki = {
|
struct protocol proto_rpki = {
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
#define RPKI_VERSION_0 0
|
#define RPKI_VERSION_0 0
|
||||||
#define RPKI_VERSION_1 1
|
#define RPKI_VERSION_1 1
|
||||||
#define RPKI_MIN_VERSION RPKI_VERSION_0
|
|
||||||
#define RPKI_MAX_VERSION RPKI_VERSION_1
|
#define RPKI_MAX_VERSION RPKI_VERSION_1
|
||||||
|
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ bt_log_result(int result, const char *fmt, va_list argptr)
|
|||||||
vsnprintf(pos, sizeof(msg_buf) - (pos - msg_buf), fmt, argptr);
|
vsnprintf(pos, sizeof(msg_buf) - (pos - msg_buf), fmt, argptr);
|
||||||
|
|
||||||
int chrs = 0;
|
int chrs = 0;
|
||||||
for (int i = 0; i < strlen(msg_buf); i += get_num_terminal_cols())
|
for (uint i = 0; i < strlen(msg_buf); i += get_num_terminal_cols())
|
||||||
{
|
{
|
||||||
if (i)
|
if (i)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user