summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/client.c151
-rw-r--r--lib/birdlib.h2
-rw-r--r--lib/mempool.c1
-rw-r--r--lib/printf.c15
-rw-r--r--lib/resource.c1
-rw-r--r--lib/slab.c1
-rw-r--r--nest/a-set.c4
-rw-r--r--nest/cli.c36
-rw-r--r--nest/cli.h2
-rw-r--r--nest/cmds.c1
-rw-r--r--nest/rt-attr.c6
-rw-r--r--proto/bgp/bgp.c5
-rw-r--r--proto/ospf/dbdes.c3
-rw-r--r--proto/ospf/iface.c13
-rw-r--r--proto/ospf/lsack.c8
-rw-r--r--proto/ospf/lsalib.c10
-rw-r--r--proto/ospf/lsreq.c8
-rw-r--r--proto/ospf/lsupd.c36
-rw-r--r--proto/ospf/neighbor.c6
-rw-r--r--proto/ospf/ospf.c23
-rw-r--r--proto/ospf/ospf.h10
-rw-r--r--proto/ospf/rt.c41
-rw-r--r--proto/ospf/topology.c18
-rw-r--r--sysdep/unix/main.c47
24 files changed, 271 insertions, 177 deletions
diff --git a/client/client.c b/client/client.c
index 6a217c7..ea8f8d3 100644
--- a/client/client.c
+++ b/client/client.c
@@ -17,6 +17,7 @@
#include <sys/types.h>
#include <readline/readline.h>
#include <readline/history.h>
+#include <curses.h>
#include "nest/bird.h"
#include "lib/resource.h"
@@ -29,13 +30,19 @@ static int verbose;
static char *server_path = PATH_CONTROL_SOCKET;
static int server_fd;
-static int server_reply;
static byte server_read_buf[4096];
static byte *server_read_pos = server_read_buf;
+#define STATE_PROMPT 0
+#define STATE_CMD_SERVER 1
+#define STATE_CMD_USER 2
+
static int input_initialized;
-static int input_hidden;
static int input_hidden_end;
+static int cstate = STATE_CMD_SERVER;
+static int nstate = STATE_CMD_SERVER;
+
+static int num_lines, skip_input, interactive;
/*** Parsing of arguments ***/
@@ -70,7 +77,6 @@ parse_args(int argc, char **argv)
/*** Input ***/
static void server_send(char *);
-static void select_loop(int);
/* HACK: libreadline internals we need to access */
extern int _rl_vis_botlin;
@@ -93,6 +99,15 @@ handle_internal_command(char *cmd)
return 0;
}
+void
+submit_server_command(char *cmd)
+{
+ server_send(cmd);
+ nstate = STATE_CMD_SERVER;
+ num_lines = 2;
+}
+
+
static void
got_line(char *cmd_buffer)
{
@@ -109,13 +124,10 @@ got_line(char *cmd_buffer)
if (cmd)
{
add_history(cmd);
+
if (!handle_internal_command(cmd))
- {
- server_send(cmd);
- input_hidden = -1;
- select_loop(0);
- input_hidden = 0;
- }
+ submit_server_command(cmd);
+
free(cmd);
}
else
@@ -219,27 +231,23 @@ input_init(void)
static void
input_hide(void)
{
- if (input_hidden)
- return;
- if (rl_line_buffer)
- {
- input_hidden_end = rl_end;
- rl_end = 0;
- rl_expand_prompt("");
- rl_redisplay();
- input_hidden = 1;
- }
+ input_hidden_end = rl_end;
+ rl_end = 0;
+ rl_expand_prompt("");
+ rl_redisplay();
}
static void
input_reveal(void)
{
- if (input_hidden <= 0)
- return;
+ /* need this, otherwise some lib seems to eat pending output when
+ the prompt is displayed */
+ fflush(stdout);
+ tcdrain(fileno(stdout));
+
rl_end = input_hidden_end;
rl_expand_prompt("bird> ");
rl_forced_update_display();
- input_hidden = 0;
}
void
@@ -253,6 +261,51 @@ cleanup(void)
}
}
+void
+update_state(void)
+{
+ if (nstate == cstate)
+ return;
+
+ if (nstate == STATE_PROMPT)
+ if (input_initialized)
+ input_reveal();
+ else
+ input_init();
+
+ if (nstate != STATE_PROMPT)
+ input_hide();
+
+ cstate = nstate;
+}
+
+void
+more(void)
+{
+ printf("--More--\015");
+ fflush(stdout);
+
+ redo:
+ switch (getchar())
+ {
+ case 32:
+ num_lines = 2;
+ break;
+ case 13:
+ num_lines--;
+ break;
+ case 'q':
+ skip_input = 1;
+ break;
+ default:
+ goto redo;
+ }
+
+ printf(" \015");
+ fflush(stdout);
+}
+
+
/*** Communication with server ***/
static void
@@ -281,26 +334,32 @@ server_got_reply(char *x)
{
int code;
- input_hide();
if (*x == '+') /* Async reply */
- printf(">>> %s\n", x+1);
+ skip_input || printf(">>> %s\n", x+1);
else if (x[0] == ' ') /* Continuation */
- printf("%s%s\n", verbose ? " " : "", x+1);
+ skip_input || printf("%s%s\n", verbose ? " " : "", x+1);
else if (strlen(x) > 4 &&
sscanf(x, "%d", &code) == 1 && code >= 0 && code < 10000 &&
(x[4] == ' ' || x[4] == '-'))
{
if (code)
- printf("%s\n", verbose ? x : x+5);
+ skip_input || printf("%s\n", verbose ? x : x+5);
if (x[4] == ' ')
- server_reply = code;
+ {
+ nstate = STATE_PROMPT;
+ skip_input = 0;
+ return;
+ }
}
else
- printf("??? <%s>\n", x);
- /* need this, otherwise some lib seems to eat pending output when
- the prompt is displayed */
- fflush(stdout);
- tcdrain(fileno(stdout));
+ skip_input || printf("??? <%s>\n", x);
+
+ if (skip_input)
+ return;
+
+ num_lines++;
+ if (interactive && input_initialized && (num_lines >= LINES) && (cstate == STATE_CMD_SERVER))
+ more();
}
static void
@@ -347,15 +406,16 @@ server_read(void)
static fd_set select_fds;
static void
-select_loop(int mode)
+select_loop(void)
{
int rv;
- server_reply = -1;
- while (mode || server_reply < 0)
+ while (1)
{
FD_ZERO(&select_fds);
- FD_SET(server_fd, &select_fds);
- if (mode)
+
+ if (cstate != STATE_CMD_USER)
+ FD_SET(server_fd, &select_fds);
+ if (cstate != STATE_CMD_SERVER)
FD_SET(0, &select_fds);
rv = select(server_fd+1, &select_fds, NULL, NULL, NULL);
@@ -370,13 +430,15 @@ select_loop(int mode)
if (FD_ISSET(server_fd, &select_fds))
{
server_read();
- if (mode)
- input_reveal();
+ update_state();
}
+
if (FD_ISSET(0, &select_fds))
- rl_callback_read_char();
+ {
+ rl_callback_read_char();
+ update_state();
+ }
}
- input_reveal();
}
static void
@@ -440,13 +502,10 @@ main(int argc, char **argv)
dmalloc_debug(0x2f03d00);
#endif
+ interactive = isatty(0);
parse_args(argc, argv);
cmd_build_tree();
server_connect();
- select_loop(0);
-
- input_init();
-
- select_loop(1);
+ select_loop();
return 0;
}
diff --git a/lib/birdlib.h b/lib/birdlib.h
index b7cd6b4..12a581b 100644
--- a/lib/birdlib.h
+++ b/lib/birdlib.h
@@ -13,7 +13,7 @@
/* Ugly structure offset handling macros */
-#define OFFSETOF(s, i) ((unsigned int)&((s *)0)->i)
+#define OFFSETOF(s, i) ((size_t) &((s *)0)->i)
#define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i)))
#define BIRD_ALIGN(s, a) (((s)+a-1)&~(a-1))
diff --git a/lib/mempool.c b/lib/mempool.c
index bb6dcff..e6f277b 100644
--- a/lib/mempool.c
+++ b/lib/mempool.c
@@ -27,6 +27,7 @@
struct lp_chunk {
struct lp_chunk *next;
unsigned int size;
+ uintptr_t data_align[0];
byte data[0];
};
diff --git a/lib/printf.c b/lib/printf.c
index 0e3b4d9..c3f7074 100644
--- a/lib/printf.c
+++ b/lib/printf.c
@@ -120,7 +120,8 @@ static char * number(char * str, long num, int base, int size, int precision,
* available space to avoid buffer overflows and it allows some more
* format specifiers: |%I| for formatting of IP addresses (any non-zero
* width is automatically replaced by standard IP address width which
- * depends on whether we use IPv4 or IPv6; |%#I| gives hexadecimal format)
+ * depends on whether we use IPv4 or IPv6; |%#I| gives hexadecimal format),
+ * |%R| for Router / Network ID (u32 value printed as IPv4 address)
* and |%m| resp. |%M| for error messages (uses strerror() to translate @errno code to
* message text). On the other hand, it doesn't support floating
* point numbers.
@@ -133,6 +134,7 @@ int bvsnprintf(char *buf, int size, const char *fmt, va_list args)
int len;
unsigned long num;
int i, base;
+ u32 x;
char *str, *start;
const char *s;
char ipbuf[STD_ADDRESS_P_LENGTH+1];
@@ -277,6 +279,17 @@ int bvsnprintf(char *buf, int size, const char *fmt, va_list args)
s = ipbuf;
goto str;
+ /* Router/Network ID - essentially IPv4 address in u32 value */
+ case 'R':
+ x = va_arg(args, u32);
+ bsprintf(ipbuf, "%d.%d.%d.%d",
+ ((x >> 24) & 0xff),
+ ((x >> 16) & 0xff),
+ ((x >> 8) & 0xff),
+ (x & 0xff));
+ s = ipbuf;
+ goto str;
+
/* integer number formats - set up the flags and "break" */
case 'o':
base = 8;
diff --git a/lib/resource.c b/lib/resource.c
index 289af93..8f91450 100644
--- a/lib/resource.c
+++ b/lib/resource.c
@@ -250,6 +250,7 @@ resource_init(void)
struct mblock {
resource r;
unsigned size;
+ uintptr_t data_align[0];
byte data[0];
};
diff --git a/lib/slab.c b/lib/slab.c
index 568f01a..17511d2 100644
--- a/lib/slab.c
+++ b/lib/slab.c
@@ -62,6 +62,7 @@ static struct resclass sl_class = {
struct sl_obj {
node n;
+ uintptr_t data_align[0];
byte data[0];
};
diff --git a/nest/a-set.c b/nest/a-set.c
index 505c0e5..fad4481 100644
--- a/nest/a-set.c
+++ b/nest/a-set.c
@@ -34,9 +34,7 @@ int_set_format(struct adata *set, int way, byte *buf, unsigned int size)
if (way)
buf += bsprintf(buf, "(%d,%d)", *z >> 16, *z & 0xffff);
else
- buf += bsprintf(buf, "%d.%d.%d.%d",
- (*z >> 24) & 0xff, (*z >> 16) & 0xff,
- (*z >> 8) & 0xff, *z & 0xff);
+ buf += bsprintf(buf, "%R", *z);
z++;
sp = 0;
diff --git a/nest/cli.c b/nest/cli.c
index bd487d8..ace97be 100644
--- a/nest/cli.c
+++ b/nest/cli.c
@@ -47,6 +47,20 @@
* The @this_cli variable points to a &cli structure of the session being
* currently parsed, but it's of course available only in command handlers
* not entered using the @cont hook.
+ *
+ * TX buffer management works as follows: At cli.tx_buf there is a
+ * list of TX buffers (struct cli_out), cli.tx_write is the buffer
+ * currently used by the producer (cli_printf(), cli_alloc_out()) and
+ * cli.tx_pos is the buffer currently used by the consumer
+ * (cli_write(), in system dependent code). The producer uses
+ * cli_out.wpos ptr as the current write position and the consumer
+ * uses cli_out.outpos ptr as the current read position. When the
+ * producer produces something, it calls cli_write_trigger(). If there
+ * is not enough space in the current buffer, the producer allocates
+ * the new one. When the consumer processes everything in the buffer
+ * queue, it calls cli_written(), tha frees all buffers (except the
+ * first one) and schedules cli.event .
+ *
*/
#include "nest/bird.h"
@@ -196,6 +210,14 @@ cli_free_out(cli *c)
c->async_msg_size = 0;
}
+void
+cli_written(cli *c)
+{
+ cli_free_out(c);
+ ev_schedule(c->event);
+}
+
+
static byte *cli_rh_pos;
static unsigned int cli_rh_len;
static int cli_rh_trick_flag;
@@ -263,11 +285,8 @@ cli_event(void *data)
else
cli_command(c);
}
- if (cli_write(c))
- {
- cli_free_out(c);
- ev_schedule(c->event);
- }
+
+ cli_write_trigger(c);
}
cli *
@@ -296,13 +315,6 @@ cli_kick(cli *c)
ev_schedule(c->event);
}
-void
-cli_written(cli *c)
-{
- cli_free_out(c);
- ev_schedule(c->event);
-}
-
static list cli_log_hooks;
static int cli_log_inited;
diff --git a/nest/cli.h b/nest/cli.h
index 2e76db7..f816ef1 100644
--- a/nest/cli.h
+++ b/nest/cli.h
@@ -62,7 +62,7 @@ void cli_echo(unsigned int class, byte *msg);
/* Functions provided by sysdep layer */
-int cli_write(cli *);
+void cli_write_trigger(cli *);
int cli_get_command(cli *);
#endif
diff --git a/nest/cmds.c b/nest/cmds.c
index ac537c8..faed870 100644
--- a/nest/cmds.c
+++ b/nest/cmds.c
@@ -19,6 +19,7 @@ cmd_show_status(void)
cli_msg(-1000, "BIRD " BIRD_VERSION);
tm_format_datetime(tim, now);
+ cli_msg(-1011, "Router ID is %R", config->router_id);
cli_msg(-1011, "Current server time is %s", tim);
tm_format_datetime(tim, boot_time);
cli_msg(-1011, "Last reboot on %s", tim);
diff --git a/nest/rt-attr.c b/nest/rt-attr.c
index 2318f80..de63198 100644
--- a/nest/rt-attr.c
+++ b/nest/rt-attr.c
@@ -419,11 +419,7 @@ ea_format(eattr *e, byte *buf)
bsprintf(buf, "%I", *(ip_addr *) ad->data);
break;
case EAF_TYPE_ROUTER_ID:
- bsprintf(buf, "%d.%d.%d.%d",
- (e->u.data >> 24) & 0xff,
- (e->u.data >> 16) & 0xff,
- (e->u.data >> 8) & 0xff,
- e->u.data & 0xff);
+ bsprintf(buf, "%R", e->u.data);
break;
case EAF_TYPE_AS_PATH:
as_path_format(ad, buf, end - buf);
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index a6b9d57..0c8ee6d 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -927,7 +927,10 @@ bgp_reconfigure(struct proto *P, struct proto_config *C)
int same = !memcmp(((byte *) old) + sizeof(struct proto_config),
((byte *) new) + sizeof(struct proto_config),
- sizeof(struct bgp_config) - sizeof(struct proto_config));
+ // password item is last and must be checked separately
+ OFFSETOF(struct bgp_config, password) - sizeof(struct proto_config))
+ && ((!old->password && !new->password)
+ || (old->password && new->password && !strcmp(old->password, new->password)));
/* We should update our copy of configuration ptr as old configuration will be freed */
if (same)
diff --git a/proto/ospf/dbdes.c b/proto/ospf/dbdes.c
index c190fe7..adc0276 100644
--- a/proto/ospf/dbdes.c
+++ b/proto/ospf/dbdes.c
@@ -115,8 +115,7 @@ ospf_dbdes_send(struct ospf_neighbor *n, int next)
{
htonlsah(&(en->lsa), lsa);
DBG("Working on: %d\n", i);
- DBG("\tX%01x %-1I %-1I %p\n", en->lsa.type, en->lsa.id,
- en->lsa.rt, en->lsa_body);
+ DBG("\tX%01x %-1R %-1R %p\n", en->lsa.type, en->lsa.id, en->lsa.rt, en->lsa_body);
lsa++;
}
diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c
index 5162f9f..ea38461 100644
--- a/proto/ospf/iface.c
+++ b/proto/ospf/iface.c
@@ -112,7 +112,7 @@ ospf_iface_chstate(struct ospf_iface *ifa, u8 state)
if (ifa->type == OSPF_IT_VLINK)
{
OSPF_TRACE(D_EVENTS,
- "Changing state of virtual link %I from \"%s\" into \"%s\".",
+ "Changing state of virtual link %R from \"%s\" into \"%s\".",
ifa->vid, ospf_is[oldstate], ospf_is[state]);
if (state == OSPF_IS_PTP)
{
@@ -586,8 +586,8 @@ ospf_iface_info(struct ospf_iface *ifa)
strict = "";
if (ifa->type == OSPF_IT_VLINK)
{
- cli_msg(-1015, "Virtual link to %I:", ifa->vid);
- cli_msg(-1015, "\tTransit area: %I (%u)", ifa->voa->areaid,
+ cli_msg(-1015, "Virtual link to %R:", ifa->vid);
+ cli_msg(-1015, "\tTransit area: %R (%u)", ifa->voa->areaid,
ifa->voa->areaid);
}
else
@@ -595,13 +595,14 @@ ospf_iface_info(struct ospf_iface *ifa)
cli_msg(-1015, "Interface \"%s\":",
(ifa->iface ? ifa->iface->name : "(none)"));
cli_msg(-1015, "\tType: %s %s", ospf_it[ifa->type], strict);
- cli_msg(-1015, "\tArea: %I (%u)", ifa->oa->areaid, ifa->oa->areaid);
+ cli_msg(-1015, "\tArea: %R (%u)", ifa->oa->areaid, ifa->oa->areaid);
}
cli_msg(-1015, "\tState: %s %s", ospf_is[ifa->state],
ifa->stub ? "(stub)" : "");
cli_msg(-1015, "\tPriority: %u", ifa->priority);
cli_msg(-1015, "\tCost: %u", ifa->cost);
cli_msg(-1015, "\tHello timer: %u", ifa->helloint);
+
if (ifa->type == OSPF_IT_NBMA)
{
cli_msg(-1015, "\tPoll timer: %u", ifa->pollint);
@@ -611,9 +612,9 @@ ospf_iface_info(struct ospf_iface *ifa)
cli_msg(-1015, "\tRetransmit timer: %u", ifa->rxmtint);
if ((ifa->type == OSPF_IT_BCAST) || (ifa->type == OSPF_IT_NBMA))
{
- cli_msg(-1015, "\tDesigned router (ID): %I", ifa->drid);
+ cli_msg(-1015, "\tDesigned router (ID): %R", ifa->drid);
cli_msg(-1015, "\tDesigned router (IP): %I", ifa->drip);
- cli_msg(-1015, "\tBackup designed router (ID): %I", ifa->bdrid);
+ cli_msg(-1015, "\tBackup designed router (ID): %R", ifa->bdrid);
cli_msg(-1015, "\tBackup designed router (IP): %I", ifa->bdrip);
}
}
diff --git a/proto/ospf/lsack.c b/proto/ospf/lsack.c
index 4652825..824767a 100644
--- a/proto/ospf/lsack.c
+++ b/proto/ospf/lsack.c
@@ -42,7 +42,7 @@ ospf_lsack_enqueue(struct ospf_neighbor *n, struct ospf_lsa_header *h,
struct lsah_n *no = mb_alloc(n->pool, sizeof(struct lsah_n));
memcpy(&no->lsa, h, sizeof(struct ospf_lsa_header));
add_tail(&n->ackl[queue], NODE no);
- DBG("Adding (%s) ack for %I, ID: %I, RT: %I, Type: %u\n", s_queue[queue],
+ DBG("Adding (%s) ack for %R, ID: %R, RT: %R, Type: %u\n", s_queue[queue],
n->rid, ntohl(h->id), ntohl(h->rt), h->type);
}
@@ -77,7 +77,7 @@ ospf_lsack_send(struct ospf_neighbor *n, int queue)
no = (struct lsah_n *) HEAD(n->ackl[queue]);
memcpy(h + i, &no->lsa, sizeof(struct ospf_lsa_header));
i++;
- DBG("Iter %u ID: %I, RT: %I, Type: %u\n", i, ntohl((h + i)->id),
+ DBG("Iter %u ID: %R, RT: %R, Type: %u\n", i, ntohl((h + i)->id),
ntohl((h + i)->rt), (h + i)->type);
rem_node(NODE no);
mb_free(no);
@@ -181,7 +181,7 @@ ospf_lsack_receive(struct ospf_lsack_packet *ps,
continue;
OSPF_TRACE(D_PACKETS, "Strange LS acknoledgement from %I", n->ip);
- OSPF_TRACE(D_PACKETS, "Id: %I, Rt: %I, Type: %u",
+ OSPF_TRACE(D_PACKETS, "Id: %R, Rt: %R, Type: %u",
lsa.id, lsa.rt, lsa.type);
OSPF_TRACE(D_PACKETS, "I have: Age: %4u, Seqno: 0x%08x, Sum: %u",
en->lsa.age, en->lsa.sn, en->lsa.checksum);
@@ -190,7 +190,7 @@ ospf_lsack_receive(struct ospf_lsack_packet *ps,
continue;
}
- DBG("Deleting LS Id: %I RT: %I Type: %u from LS Retl for neighbor %I\n",
+ DBG("Deleting LS Id: %R RT: %R Type: %u from LS Retl for neighbor %R\n",
lsa.id, lsa.rt, lsa.type, n->rid);
s_rem_node(SNODE en);
if (en->lsa_body != NULL)
diff --git a/proto/ospf/lsalib.c b/proto/ospf/lsalib.c
index 567942d..e624b6c 100644
--- a/proto/ospf/lsalib.c
+++ b/proto/ospf/lsalib.c
@@ -14,7 +14,7 @@ flush_lsa(struct top_hash_entry *en, struct proto_ospf *po)
struct proto *p = &po->proto;
OSPF_TRACE(D_EVENTS,
- "Going to remove node Type: %u, Id: %I, Rt: %I, Age: %u, SN: 0x%x",
+ "Going to remove node Type: %u, Id: %R, Rt: %R, Age: %u, SN: 0x%x",
en->lsa.type, en->lsa.id, en->lsa.rt, en->lsa.age, en->lsa.sn);
s_rem_node(SNODE en);
if (en->lsa_body != NULL)
@@ -56,8 +56,8 @@ ospf_age(struct proto_ospf *po)
en->nhi = NULL;
en->nh = IPA_NONE;
en->lb = IPA_NONE;
- DBG("Infinitying Type: %u, Id: %I, Rt: %I\n", en->lsa.type, en->lsa.id,
- en->lsa.rt);
+ DBG("Infinitying Type: %u, Id: %R, Rt: %R\n", en->lsa.type,
+ en->lsa.id, en->lsa.rt);
}
if (en->lsa.age == LSA_MAXAGE)
{
@@ -68,7 +68,7 @@ ospf_age(struct proto_ospf *po)
if ((en->lsa.rt == p->cf->global->router_id) &&(en->lsa.age >=
LSREFRESHTIME))
{
- OSPF_TRACE(D_EVENTS, "Refreshing my LSA: Type: %u, Id: %I, Rt: %I",
+ OSPF_TRACE(D_EVENTS, "Refreshing my LSA: Type: %u, Id: %R, Rt: %R",
en->lsa.type, en->lsa.id, en->lsa.rt);
en->lsa.sn++;
en->lsa.age = 0;
@@ -459,7 +459,7 @@ lsa_install_new(struct ospf_lsa_header *lsa, void *body, struct ospf_area *oa)
s_rem_node(SNODE en);
}
- DBG("Inst lsa: Id: %I, Rt: %I, Type: %u, Age: %u, Sum: %u, Sn: 0x%x\n",
+ DBG("Inst lsa: Id: %R, Rt: %R, Type: %u, Age: %u, Sum: %u, Sn: 0x%x\n",
lsa->id, lsa->rt, lsa->type, lsa->age, lsa->checksum, lsa->sn);
s_add_tail(&po->lsal, SNODE en);
diff --git a/proto/ospf/lsreq.c b/proto/ospf/lsreq.c
index e179189..5eeb06f 100644
--- a/proto/ospf/lsreq.c
+++ b/proto/ospf/lsreq.c
@@ -22,7 +22,7 @@ static void ospf_dump_lsreq(struct proto *p, struct ospf_lsreq_packet *pkt)
sizeof(struct ospf_lsreq_header);
for (i = 0; i < j; i++)
- log(L_TRACE "%s: LSR Id: %I, Rt: %I, Type: %u",
+ log(L_TRACE "%s: LSR Id: %R, Rt: %R, Type: %u",
p->name, htonl(plsr[i].id), htonl(plsr[i].rt), plsr[i].type);
}
@@ -63,7 +63,7 @@ ospf_lsreq_send(struct ospf_neighbor *n)
lsh->type = en->lsa.type;
lsh->rt = htonl(en->lsa.rt);
lsh->id = htonl(en->lsa.id);
- DBG("Requesting %uth LSA: Type: %u, ID: %I, RT: %I, SN: 0x%x, Age %u\n",
+ DBG("Requesting %uth LSA: Type: %u, ID: %R, RT: %R, SN: 0x%x, Age %u\n",
i, en->lsa.type, en->lsa.id, en->lsa.rt, en->lsa.sn, en->lsa.age);
lsh++;
if (sn == STAIL(n->lsrql))
@@ -114,7 +114,7 @@ ospf_lsreq_receive(struct ospf_lsreq_packet *ps,
{
u32 hid = ntohl(lsh->id);
u32 hrt = ntohl(lsh->rt);
- DBG("Processing requested LSA: Type: %u, ID: %I, RT: %I\n", lsh->type, hid, hrt);
+ DBG("Processing requested LSA: Type: %u, ID: %R, RT: %R\n", lsh->type, hid, hrt);
llsh = sl_alloc(upslab);
llsh->lsh.id = hid;
llsh->lsh.rt = hrt;
@@ -124,7 +124,7 @@ ospf_lsreq_receive(struct ospf_lsreq_packet *ps,
llsh->lsh.type) == NULL)
{
log(L_WARN
- "Received bad LS req from: %I looking: Type: %u, ID: %I, RT: %I",
+ "Received bad LS req from: %I looking: Type: %u, ID: %R, RT: %R",
n->ip, lsh->type, hid, hrt);
ospf_neigh_sm(n, INM_BADLSREQ);
rfree(upslab);
diff --git a/proto/ospf/lsupd.c b/proto/ospf/lsupd.c
index 6b99728..ba09fec 100644
--- a/proto/ospf/lsupd.c
+++ b/proto/ospf/lsupd.c
@@ -14,14 +14,14 @@ void ospf_dump_lsahdr(struct proto *p, struct ospf_lsa_header *lsa_n)
struct ospf_lsa_header lsa;
ntohlsah(lsa_n, &lsa);
- log(L_TRACE "%s: LSA Id: %I, Rt: %I, Type: %u, Age: %u, Seqno: 0x%08x, Sum: %u",
+ log(L_TRACE "%s: LSA Id: %R, Rt: %R, Type: %u, Age: %u, Seqno: 0x%08x, Sum: %u",
p->name, lsa.id, lsa.rt, lsa.type, lsa.age, lsa.sn, lsa.checksum);
}
void ospf_dump_common(struct proto *p, struct ospf_packet *op)
{
log(L_TRACE "%s: length %d", p->name, ntohs(op->length));
- log(L_TRACE "%s: router %I", p->name, _MI(ntohl(op->routerid)));
+ log(L_TRACE "%s: router %R", p->name, ntohl(op->routerid));
}
static void ospf_dump_lsupd(struct proto *p, struct ospf_lsupd_packet *pkt)
@@ -94,7 +94,7 @@ ospf_lsupd_flood(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
continue;
}
- DBG("Wanted to flood LSA: Type: %u, ID: %I, RT: %I, SN: 0x%x, Age %u\n",
+ DBG("Wanted to flood LSA: Type: %u, ID: %R, RT: %R, SN: 0x%x, Age %u\n",
hh->type, hh->id, hh->rt, hh->sn, hh->age);
ret = 0;
@@ -106,7 +106,7 @@ ospf_lsupd_flood(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
{
if ((en = ospf_hash_find_header(nn->lsrqh, nn->ifa->oa->areaid, hh)) != NULL)
{
- DBG("That LSA found in lsreq list for neigh %I\n", nn->rid);
+ DBG("That LSA found in lsreq list for neigh %R\n", nn->rid);
switch (lsa_comp(hh, &en->lsa))
{
@@ -118,7 +118,7 @@ ospf_lsupd_flood(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
if (en->lsa_body != NULL)
mb_free(en->lsa_body);
en->lsa_body = NULL;
- DBG("Removing from lsreq list for neigh %I\n", nn->rid);
+ DBG("Removing from lsreq list for neigh %R\n", nn->rid);
ospf_hash_delete(nn->lsrqh, en);
if (EMPTY_SLIST(nn->lsrql))
ospf_neigh_sm(nn, INM_LOADDONE);
@@ -129,7 +129,7 @@ ospf_lsupd_flood(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
if (en->lsa_body != NULL)
mb_free(en->lsa_body);
en->lsa_body = NULL;
- DBG("Removing from lsreq list for neigh %I\n", nn->rid);
+ DBG("Removing from lsreq list for neigh %R\n", nn->rid);
ospf_hash_delete(nn->lsrqh, en);
if (EMPTY_SLIST(nn->lsrql))
ospf_neigh_sm(nn, INM_LOADDONE);
@@ -293,7 +293,7 @@ ospf_lsupd_send_list(struct ospf_neighbor *n, list * l)
continue; /* Probably flushed LSA */
/* FIXME This is a bug! I cannot flush LSA that is in lsrt */
- DBG("Sending LSA: Type=%u, ID=%I, RT=%I, SN: 0x%x, Age: %u\n",
+ DBG("Sending LSA: Type=%u, ID=%R, RT=%R, SN: 0x%x, Age: %u\n",
llsh->lsh.type, llsh->lsh.id, llsh->lsh.rt, en->lsa.sn, en->lsa.age);
if (((u32) (len + en->lsa.length)) > ospf_pkt_maxsize(n->ifa))
{
@@ -345,9 +345,7 @@ ospf_lsupd_receive(struct ospf_lsupd_packet *ps,
if (n->state < NEIGHBOR_EXCHANGE)
{
- OSPF_TRACE(D_PACKETS,
- "Received lsupd in lesser state than EXCHANGE from (%I)",
- n->ip);
+ OSPF_TRACE(D_PACKETS, "Received lsupd in lesser state than EXCHANGE from (%I)", n->ip);
return;
}
@@ -412,17 +410,16 @@ ospf_lsupd_receive(struct ospf_lsupd_packet *ps,
ntohlsah(lsa, &lsatmp);
- DBG("Update Type: %u ID: %I RT: %I, Sn: 0x%08x Age: %u, Sum: %u\n",
- lsatmp.type, lsatmp.id, lsatmp.rt, lsatmp.sn, lsatmp.age,
- lsatmp.checksum);
+ DBG("Update Type: %u ID: %R RT: %R, Sn: 0x%08x Age: %u, Sum: %u\n",
+ lsatmp.type, lsatmp.id, lsatmp.rt, lsatmp.sn, lsatmp.age, lsatmp.checksum);
lsadb = ospf_hash_find_header(po->gr, oa->areaid, &lsatmp);
#ifdef LOCAL_DEBUG
if (lsadb)
- DBG("I have Type: %u ID: %I RT: %I, Sn: 0x%08x Age: %u, Sum: %u\n",
- lsadb->lsa.type, lsadb->lsa.id, lsadb->lsa.rt, lsadb->lsa.sn,
- lsadb->lsa.age, lsadb->lsa.checksum);
+ DBG("I have Type: %u ID: %R RT: %R, Sn: 0x%08x Age: %u, Sum: %u\n",
+ lsadb->lsa.type, lsadb->lsa.id, lsadb->lsa.rt,
+ lsadb->lsa.sn, lsadb->lsa.age, lsadb->lsa.checksum);
#endif
/* pg 143 (4) */
@@ -472,8 +469,8 @@ ospf_lsupd_receive(struct ospf_lsupd_packet *ps,
lsa->age = htons(LSA_MAXAGE);
lsa->sn = htonl(LSA_MAXSEQNO);
OSPF_TRACE(D_EVENTS, "Premature aging self originated lsa.");
- OSPF_TRACE(D_EVENTS, "Type: %d, Id: %I, Rt: %I", lsatmp.type,
- lsatmp.id, lsatmp.rt);
+ OSPF_TRACE(D_EVENTS, "Type: %d, Id: %R, Rt: %R",
+ lsatmp.type, lsatmp.id, lsatmp.rt);
lsasum_check(lsa, (lsa + 1)); /* It also calculates chsum! */
lsatmp.checksum = ntohs(lsa->checksum);
ospf_lsupd_flood(NULL, lsa, &lsatmp, NULL, oa, 0);
@@ -609,7 +606,6 @@ ospf_lsupd_flush_nlsa(struct top_hash_entry *en, struct ospf_area *oa)
lsa->sn = LSA_MAXSEQNO;
lsasum_calculate(lsa, en->lsa_body);
OSPF_TRACE(D_EVENTS, "Premature aging self originated lsa!");
- OSPF_TRACE(D_EVENTS, "Type: %d, Id: %I, Rt: %I", lsa->type,
- lsa->id, lsa->rt);
+ OSPF_TRACE(D_EVENTS, "Type: %d, Id: %R, Rt: %R", lsa->type, lsa->id, lsa->rt);
ospf_lsupd_flood(NULL, NULL, lsa, NULL, oa, 0);
}
diff --git a/proto/ospf/neighbor.c b/proto/ospf/neighbor.c
index 6e72764..bb681c2 100644
--- a/proto/ospf/neighbor.c
+++ b/proto/ospf/neighbor.c
@@ -506,7 +506,7 @@ bdr_election(struct ospf_iface *ifa)
ifa->bdrip = nbdr->ip;
}
- DBG("DR=%I, BDR=%I\n", ifa->drid, ifa->bdrid);
+ DBG("DR=%R, BDR=%R\n", ifa->drid, ifa->bdrid);
if (myid == ifa->drid)
ospf_iface_chstate(ifa, OSPF_IS_DR);
@@ -624,7 +624,7 @@ ospf_sh_neigh_info(struct ospf_neighbor *n)
if ((n->ifa->type == OSPF_IT_PTP) || (n->ifa->type == OSPF_IT_VLINK))
pos = "ptp ";
- cli_msg(-1013, "%-1I\t%3u\t%s/%s\t%-5s\t%-1I\t%-10s", n->rid, n->priority,
+ cli_msg(-1013, "%-1R\t%3u\t%s/%s\t%-5s\t%-1I\t%-10s", n->rid, n->priority,
ospf_ns[n->state], pos, etime, n->ip,
(ifa->type == OSPF_IT_VLINK ? "vlink" : ifa->iface->name));
}
@@ -672,7 +672,7 @@ rxmt_timer_hook(timer * timer)
llsh->lsh.id = en->lsa.id;
llsh->lsh.rt = en->lsa.rt;
llsh->lsh.type = en->lsa.type;
- DBG("Working on ID: %I, RT: %I, Type: %u\n",
+ DBG("Working on ID: %R, RT: %R, Type: %u\n",
en->lsa.id, en->lsa.rt, en->lsa.type);
add_tail(&uplist, NODE llsh);
}
diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c
index c9b5f43..d4bcbed 100644
--- a/proto/ospf/ospf.c
+++ b/proto/ospf/ospf.c
@@ -209,11 +209,11 @@ ospf_dump(struct proto *p)
{
OSPF_TRACE(D_EVENTS, "Interface: %s", (ifa->iface ? ifa->iface->name : "(null)"));
OSPF_TRACE(D_EVENTS, "state: %u", ifa->state);
- OSPF_TRACE(D_EVENTS, "DR: %I", ifa->drid);
- OSPF_TRACE(D_EVENTS, "BDR: %I", ifa->bdrid);
+ OSPF_TRACE(D_EVENTS, "DR: %R", ifa->drid);
+ OSPF_TRACE(D_EVENTS, "BDR: %R", ifa->bdrid);
WALK_LIST(n, ifa->neigh_list)
{
- OSPF_TRACE(D_EVENTS, " neighbor %I in state %u", n->rid, n->state);
+ OSPF_TRACE(D_EVENTS, " neighbor %R in state %u", n->rid, n->state);
}
}
@@ -309,8 +309,7 @@ schedule_rt_lsa(struct ospf_area *oa)
{
struct proto *p = &oa->po->proto;
- OSPF_TRACE(D_EVENTS, "Scheduling RT lsa origination for area %I.",
- oa->areaid);
+ OSPF_TRACE(D_EVENTS, "Scheduling RT lsa origination for area %R.", oa->areaid);
oa->origrt = 1;
}
@@ -953,7 +952,7 @@ ospf_sh(struct proto *p)
WALK_LIST(oa, po->area_list)
{
- cli_msg(-1014, "\tArea: %I (%u) %s", oa->areaid, oa->areaid,
+ cli_msg(-1014, "\tArea: %R (%u) %s", oa->areaid, oa->areaid,
oa->areaid == 0 ? "[BACKBONE]" : "");
ifano = 0;
nno = 0;
@@ -1088,7 +1087,7 @@ show_lsa_router(struct top_hash_entry *he)
for (i = 0; i < rt->links; i++)
if (rr[i].type == LSART_PTP)
- cli_msg(-1016, "\t\trouter %I metric %u ", rr[i].id, rr[i].metric);
+ cli_msg(-1016, "\t\trouter %R metric %u ", rr[i].id, rr[i].metric);
for (i = 0; i < rt->links; i++)
if (rr[i].type == LSART_NET)
@@ -1125,10 +1124,10 @@ show_lsa_network(struct top_hash_entry *he)
cli_msg(-1016, "");
cli_msg(-1016, "\tnetwork %I/%d", ipa_and(ipa_from_u32(lsa->id), ln->netmask), ipa_mklen(ln->netmask));
- cli_msg(-1016, "\t\tdr %I", lsa->rt);
+ cli_msg(-1016, "\t\tdr %R", lsa->rt);
for (i = 0; i < max; i++)
- cli_msg(-1016, "\t\trouter %I", rts[i]);
+ cli_msg(-1016, "\t\trouter %R", rts[i]);
}
static inline void
@@ -1143,7 +1142,7 @@ show_lsa_sum_net(struct top_hash_entry *he)
static inline void
show_lsa_sum_rt(struct top_hash_entry *he)
{
- cli_msg(-1016, "\t\txrouter %I", he->lsa.id);
+ cli_msg(-1016, "\t\txrouter %R", he->lsa.id);
}
@@ -1207,7 +1206,7 @@ ospf_sh_state(struct proto *p, int verbose)
if (last_area != hea[i]->oa->areaid)
{
cli_msg(-1016, "");
- cli_msg(-1016, "area %I", hea[i]->oa->areaid);
+ cli_msg(-1016, "area %R", hea[i]->oa->areaid);
last_area = hea[i]->oa->areaid;
last_rt = 0xFFFFFFFF;
}
@@ -1215,7 +1214,7 @@ ospf_sh_state(struct proto *p, int verbose)
if ((hea[i]->lsa.rt != last_rt) && (hea[i]->lsa.type != LSA_T_NET))
{
cli_msg(-1016, "");
- cli_msg(-1016, (hea[i]->lsa.type != LSA_T_EXT) ? "\trouter %I" : "\txrouter %I", hea[i]->lsa.rt);
+ cli_msg(-1016, (hea[i]->lsa.type != LSA_T_EXT) ? "\trouter %R" : "\txrouter %R", hea[i]->lsa.rt);
last_rt = hea[i]->lsa.rt;
}
diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h
index 23f21b8..2279089 100644
--- a/proto/ospf/ospf.h
+++ b/proto/ospf/ospf.h
@@ -120,7 +120,7 @@ struct ospf_area_config
struct obits
{
-#ifdef _BIG_ENDIAN
+#ifdef CPU_BIG_ENDIAN
u8 unused2:2;
u8 dc:1;
u8 ea:1;
@@ -264,7 +264,7 @@ struct ospf_hello_packet
struct immsb
{
-#ifdef _BIG_ENDIAN
+#ifdef CPU_BIG_ENDIAN
u8 padding:5;
u8 i:1;
u8 m:1;
@@ -320,7 +320,7 @@ struct ospf_lsa_header
struct vebb
{
-#ifdef _BIG_ENDIAN
+#ifdef CPU_BIG_ENDIAN
u8 padding:5;
u8 v:1;
u8 e:1;
@@ -384,7 +384,7 @@ struct ospf_lsa_ext
struct ospf_lsa_ext_etos
{
-#ifdef _BIG_ENDIAN
+#ifdef CPU_BIG_ENDIAN
u8 ebit:1;
u8 tos:7;
u8 padding1;
@@ -400,7 +400,7 @@ struct ospf_lsa_ext_etos
#define METRIC_MASK 0x00FFFFFF
struct ospf_lsa_sum_tos
{
-#ifdef _BIG_ENDIAN
+#ifdef CPU_BIG_ENDIAN
u8 tos;
u8 padding1;
u16 padding2;
diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c
index 79b21e6..a230d38 100644
--- a/proto/ospf/rt.c
+++ b/proto/ospf/rt.c
@@ -154,8 +154,7 @@ ospf_rt_spfa(struct ospf_area *oa)
if (oa->rt == NULL)
return;
- OSPF_TRACE(D_EVENTS, "Starting routing table calculation for area %I",
- oa->areaid);
+ OSPF_TRACE(D_EVENTS, "Starting routing table calculation for area %R", oa->areaid);
if (oa->rt->dist != LSINFINITY)
bug("Aging was not processed.");
@@ -168,8 +167,8 @@ ospf_rt_spfa(struct ospf_area *oa)
oa->rt->dist = 0;
oa->rt->color = CANDIDATE;
add_head(&oa->cand, &oa->rt->cn);
- DBG("RT LSA: rt: %I, id: %I, type: %u\n", oa->rt->lsa.rt,
- oa->rt->lsa.id, oa->rt->lsa.type);
+ DBG("RT LSA: rt: %R, id: %R, type: %u\n",
+ oa->rt->lsa.rt, oa->rt->lsa.id, oa->rt->lsa.type);
while (!EMPTY_LIST(oa->cand))
{
@@ -177,8 +176,8 @@ ospf_rt_spfa(struct ospf_area *oa)
act = SKIP_BACK(struct top_hash_entry, cn, n);
rem_node(n);
- DBG("Working on LSA: rt: %I, id: %I, type: %u\n", act->lsa.rt,
- act->lsa.id, act->lsa.type);
+ DBG("Working on LSA: rt: %R, id: %R, type: %u\n",
+ act->lsa.rt, act->lsa.id, act->lsa.type);
act->color = INSPF;
switch (act->lsa.type)
@@ -208,7 +207,7 @@ ospf_rt_spfa(struct ospf_area *oa)
{
tmp = NULL;
rtl = (rr + i);
- DBG(" Working on link: %I (type: %u) ", rtl->id, rtl->type);
+ DBG(" Working on link: %R (type: %u) ", rtl->id, rtl->type);
switch (rtl->type)
{
case LSART_STUB:
@@ -265,7 +264,7 @@ ospf_rt_spfa(struct ospf_area *oa)
DBG("PTP found.\n");
break;
default:
- log("Unknown link type in router lsa. (rid = %I)", act->lsa.id);
+ log("Unknown link type in router lsa. (rid = %R)", act->lsa.id);
break;
}
if (tmp)
@@ -292,8 +291,8 @@ ospf_rt_spfa(struct ospf_area *oa)
for (i = 0; i < (act->lsa.length - sizeof(struct ospf_lsa_header) -
sizeof(struct ospf_lsa_net)) / sizeof(u32); i++)
{
- DBG(" Working on router %I ", *(rts + i));
- tmp = ospf_hash_find(po->gr, oa->areaid, *(rts + i), *(rts + i), LSA_T_RT);
+ DBG(" Working on router %R ", rts[i]);
+ tmp = ospf_hash_find(po->gr, oa->areaid, rts[i], rts[i], LSA_T_RT);
if (tmp != NULL)
DBG("Found :-)\n");
else
@@ -314,7 +313,7 @@ ospf_rt_spfa(struct ospf_area *oa)
{
if ((iface->state != OSPF_IS_PTP) || (iface->iface != tmp->nhi->iface) || (!ipa_equal(iface->vip, tmp->lb)))
{
- OSPF_TRACE(D_EVENTS, "Vlink peer %I found", tmp->lsa.id);
+ OSPF_TRACE(D_EVENTS, "Vlink peer %R found", tmp->lsa.id);
ospf_iface_sm(iface, ISM_DOWN);
iface->iface = tmp->nhi->iface;
iface->vip = tmp->lb;
@@ -325,7 +324,7 @@ ospf_rt_spfa(struct ospf_area *oa)
{
if (iface->state > OSPF_IS_DOWN)
{
- OSPF_TRACE(D_EVENTS, "Vlink peer %I lost", iface->vid);
+ OSPF_TRACE(D_EVENTS, "Vlink peer %R lost", iface->vid);
ospf_iface_sm(iface, ISM_DOWN);
}
}
@@ -372,7 +371,7 @@ link_back(struct ospf_area *oa, struct top_hash_entry *fol, struct top_hash_entr
}
break;
default:
- log("Unknown link type in router lsa. (rid = %I)", fol->lsa.id);
+ log("Unknown link type in router lsa. (rid = %R)", fol->lsa.id);
break;
}
}
@@ -390,7 +389,7 @@ link_back(struct ospf_area *oa, struct top_hash_entry *fol, struct top_hash_entr
}
break;
default:
- bug("Unknown lsa type. (id = %I)", fol->lsa.id);
+ bug("Unknown lsa type. (id = %R)", fol->lsa.id);
}
return 0;
}
@@ -480,7 +479,7 @@ ospf_rt_sum(struct ospf_area *oa)
int mlen = -1, type = -1;
union ospf_lsa_sum_tm *tm;
- OSPF_TRACE(D_EVENTS, "Starting routing table calculation for inter-area (area %I)", oa->areaid);
+ OSPF_TRACE(D_EVENTS, "Starting routing table calculation for inter-area (area %R)", oa->areaid);
WALK_SLIST(en, po->lsal)
{
@@ -663,7 +662,7 @@ ospf_ext_spf(struct proto_ospf *po)
le = en->lsa_body;
lt = (struct ospf_lsa_ext_tos *) (le + 1);
- DBG("%s: Working on LSA. ID: %I, RT: %I, Type: %u, Mask %I\n",
+ DBG("%s: Working on LSA. ID: %R, RT: %R, Type: %u, Mask %I\n",
p->name, en->lsa.id, en->lsa.rt, en->lsa.type, le->netmask);
if ((lt->etm.metric & METRIC_MASK) == LSINFINITY)
@@ -672,7 +671,7 @@ ospf_ext_spf(struct proto_ospf *po)
mlen = ipa_mklen(le->netmask);
if ((mlen < 0) || (mlen > 32))
{
- log("%s: Invalid mask in LSA. ID: %I, RT: %I, Type: %u, Mask %I",
+ log("%s: Invalid mask in LSA. ID: %R, RT: %R, Type: %u, Mask %I",
p->name, en->lsa.id, en->lsa.rt, en->lsa.type, le->netmask);
continue;
}
@@ -796,8 +795,8 @@ add_cand(list * l, struct top_hash_entry *en, struct top_hash_entry *par,
if (!link_back(oa, en, par))
return;
- DBG(" Adding candidate: rt: %I, id: %I, type: %u\n", en->lsa.rt,
- en->lsa.id, en->lsa.type);
+ DBG(" Adding candidate: rt: %R, id: %R, type: %u\n",
+ en->lsa.rt, en->lsa.id, en->lsa.type);
en->nhi = NULL;
en->nh = IPA_NONE;
@@ -859,7 +858,7 @@ calc_next_hop(struct top_hash_entry *en, struct top_hash_entry *par,
if (ipa_equal(par->nh, IPA_NONE))
{
neighbor *nn;
- DBG(" Next hop calculating for id: %I rt: %I type: %u\n",
+ DBG(" Next hop calculating for id: %R rt: %R type: %u\n",
en->lsa.id, en->lsa.rt, en->lsa.type);
if (par == oa->rt)
@@ -914,7 +913,7 @@ calc_next_hop(struct top_hash_entry *en, struct top_hash_entry *par,
}
else
{ /* Parent is some RT neighbor */
- log(L_ERR "Router's parent has no next hop. (EN=%I, PAR=%I)",
+ log(L_ERR "Router's parent has no next hop. (EN=%R, PAR=%R)",
en->lsa.id, par->lsa.id);
/* I hope this would never happen */
return;
diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c
index 371856f..5d8c7a9 100644
--- a/proto/ospf/topology.c
+++ b/proto/ospf/topology.c
@@ -82,7 +82,7 @@ originate_rt_lsa_body(struct ospf_area *oa, u16 * length)
struct ospf_lsa_rt_link *ln;
struct ospf_neighbor *neigh;
- DBG("%s: Originating RT_lsa body for area \"%I\".\n", po->proto.name,
+ DBG("%s: Originating RT_lsa body for area %R.\n", po->proto.name,
oa->areaid);
ASSERT(po->lsab_used == 0);
@@ -244,7 +244,7 @@ originate_rt_lsa(struct ospf_area *oa)
* try to do it next tick.
*/
- OSPF_TRACE(D_EVENTS, "Originating RT_lsa for area \"%I\".", oa->areaid);
+ OSPF_TRACE(D_EVENTS, "Originating RT_lsa for area %R.", oa->areaid);
lsa.age = 0;
lsa.id = rtid;
@@ -464,7 +464,8 @@ flush_sum_lsa(struct ospf_area *oa, struct fib_node *fn, int type)
en->lsa.age = LSA_MAXAGE;
en->lsa.sn = LSA_MAXSEQNO;
lsasum_calculate(&en->lsa, sum);
- OSPF_TRACE(D_EVENTS, "Flushing summary lsa. (id=%I, type=%d)", en->lsa.id, en->lsa.type);
+ OSPF_TRACE(D_EVENTS, "Flushing summary lsa. (id=%R, type=%d)",
+ en->lsa.id, en->lsa.type);
ospf_lsupd_flood(NULL, NULL, &en->lsa, NULL, oa, 1);
if (can_flush_lsa(po)) flush_lsa(en, po);
break;
@@ -913,9 +914,9 @@ ospf_dump_lsa(struct top_hash_entry *he, struct proto *p)
u32 *rts = NULL;
u32 i, max;
- OSPF_TRACE(D_EVENTS, "- %1x %-1I %-1I %4u 0x%08x 0x%04x %-1I",
- he->lsa.type, he->lsa.id, he->lsa.rt, he->lsa.age,
- he->lsa.sn, he->lsa.checksum, he->oa ? he->oa->areaid : 0 );
+ OSPF_TRACE(D_EVENTS, "- %1x %-1R %-1R %4u 0x%08x 0x%04x %-1R",
+ he->lsa.type, he->lsa.id, he->lsa.rt, he->lsa.age, he->lsa.sn,
+ he->lsa.checksum, he->oa ? he->oa->areaid : 0 );
switch (he->lsa.type)
{
@@ -924,7 +925,8 @@ ospf_dump_lsa(struct top_hash_entry *he, struct proto *p)
rr = (struct ospf_lsa_rt_link *) (rt + 1);
for (i = 0; i < rt->links; i++)
- OSPF_TRACE(D_EVENTS, " - %1x %-1I %-1I %5u", rr[i].type, rr[i].id, rr[i].data, rr[i].metric);
+ OSPF_TRACE(D_EVENTS, " - %1x %-1R %-1R %5u",
+ rr[i].type, rr[i].id, rr[i].data, rr[i].metric);
break;
case LSA_T_NET:
@@ -934,7 +936,7 @@ ospf_dump_lsa(struct top_hash_entry *he, struct proto *p)
sizeof(struct ospf_lsa_net)) / sizeof(u32);
for (i = 0; i < max; i++)
- OSPF_TRACE(D_EVENTS, " - %-1I", rts[i]);
+ OSPF_TRACE(D_EVENTS, " - %-1R", rts[i]);
break;
default:
diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c
index 5f5b165..17845d2 100644
--- a/sysdep/unix/main.c
+++ b/sysdep/unix/main.c
@@ -178,22 +178,44 @@ cmd_reconfig(char *name, int type)
static sock *cli_sk;
static char *path_control_socket = PATH_CONTROL_SOCKET;
-int
+
+static void
cli_write(cli *c)
{
sock *s = c->priv;
- if (c->tx_pos)
+ while (c->tx_pos)
{
struct cli_out *o = c->tx_pos;
+
+ int len = o->wpos - o->outpos;
s->tbuf = o->outpos;
- if (sk_send(s, o->wpos - o->outpos) > 0)
- {
- c->tx_pos = o->next;
- ev_schedule(c->event);
- }
+ o->outpos = o->wpos;
+
+ if (sk_send(s, len) <= 0)
+ return;
+
+ c->tx_pos = o->next;
}
- return !c->tx_pos;
+
+ /* Everything is written */
+ s->tbuf = NULL;
+ cli_written(c);
+}
+
+void
+cli_write_trigger(cli *c)
+{
+ sock *s = c->priv;
+
+ if (s->tbuf == NULL)
+ cli_write(c);
+}
+
+static void
+cli_tx(sock *s)
+{
+ cli_write(s->data);
}
int
@@ -233,15 +255,6 @@ cli_rx(sock *s, int size UNUSED)
}
static void
-cli_tx(sock *s)
-{
- cli *c = s->data;
-
- if (cli_write(c))
- cli_written(c);
-}
-
-static void
cli_err(sock *s, int err)
{
if (config->cli_debug)