From fda873ef776cc8b568f562a0cbbe49bc6f9b836e Mon Sep 17 00:00:00 2001 From: Michael Blizek Date: Sat, 24 May 2014 16:29:44 +0200 Subject: [PATCH] neigh_list resp: remove duplicate addrlen, neigh list req: remove offset+limit --- libcor.c | 60 +++++++++++++++++++---------------------------------------- libcor.h | 5 ++--- test_neigh.c | 2 +- test_route.c | 2 +- test_routed.c | 2 +- 5 files changed, 24 insertions(+), 47 deletions(-) diff --git a/libcor.c b/libcor.c index 6439298..6ece2fa 100644 --- a/libcor.c +++ b/libcor.c @@ -140,7 +140,7 @@ state_1: if (maxread != 0) { if (len > (*maxread)) { - printf("error in read_fully: maxread reached/n"); + printf("error in read_fully: maxread reached\n"); rc = RC_CONNBROKEN; goto out; } @@ -153,7 +153,6 @@ state_1: int u; if (rcvd == 0) { - printf("non-blocking read not supported"); rc = RC_WOULDBLOCK; goto out; } @@ -182,7 +181,7 @@ out: sizeof(nr->data.read.read_fully)); } - return RC_OK; + return rc; } static int read_discard(int fd, struct libcor_nonblock_resumeinfo *nr, @@ -436,8 +435,10 @@ static int send_cmd(int fd, struct libcor_nonblock_resumeinfo *nr, if (unlikely(WRITE_BUF_SIZE < len)) LIBCOR_ASSERT_ERR(); - memcpy(&(nr->data.write.buf[0]), buf, len); - nr->data.write.len = len; + if (len != 0) { + memcpy(&(nr->data.write.buf[0]), buf, len); + nr->data.write.len = len; + } return _send_cmd(fd, nr, cmd); } @@ -622,35 +623,18 @@ int send_connect_port(int fd, __u64 port) return rc; } -int send_list_neigh_nonblock(int fd, struct libcor_nonblock_resumeinfo *nr, - __u32 limit, __u32 offset) +int send_list_neigh_nonblock(int fd, struct libcor_nonblock_resumeinfo *nr) { - char buf[8]; - __u32 len = 0; - int rc; - - rc = encode_len(buf, 4, limit); - if (unlikely(rc <= 0)) - return RC_CONNBROKEN; - - len += rc; - - rc = encode_len(buf + len, 4, offset); - if (unlikely(rc <= 0)) - return RC_CONNBROKEN; - - len += rc; - - return send_cmd(fd, nr, CD_LIST_NEIGH, buf, len); + return send_cmd(fd, nr, CD_LIST_NEIGH, 0, 0); } -int send_list_neigh(int fd, __u32 limit, __u32 offset) +int send_list_neigh(int fd) { int rc = RC_WOULDBLOCK; struct libcor_nonblock_resumeinfo nr; bzero(&nr, sizeof(struct libcor_nonblock_resumeinfo)); - rc = send_list_neigh_nonblock(fd, &nr, limit, offset); + rc = send_list_neigh_nonblock(fd, &nr); if (unlikely(rc == RC_WOULDBLOCK)) { LIBCOR_ASSERT_ERR(); return bzero_nr_iffinished(&nr, RC_CONNBROKEN); @@ -715,10 +699,8 @@ int read_neigh_list_nonblock(int fd, struct libcor_nonblock_resumeinfo *nr, goto state_8; } else if (state == 9) { goto state_9; - } else if (state ==10) { + } else if (state == 10) { goto state_10; - } else if (state == 11) { - goto state_11; } else if (unlikely(state != 0)) { LIBCOR_ASSERT_ERR(); } @@ -819,12 +801,8 @@ state_7: goto discard_field; } else if (nr_nl->fields[nr_nl->v].field == LIST_NEIGH_FIELD_ADDR) { - nr_nl->state = 8; -state_8: - rc = read_len(fd, nr, &(nr_nl->addrlen), - &(nr_nl->fieldlen)); - if (rc != RC_OK) - return bzero_nr_iffinished(nr, rc); + + nr_nl->addrlen = nr_nl->fieldlen; if (unlikely(nr_nl->addrlen > ADDR_MAX_LEN)) goto discard_field; @@ -834,8 +812,8 @@ state_8: bzero(&(nr_nl->addr[0]), ADDR_MAX_LEN); - nr_nl->state = 9; -state_9: + nr_nl->state = 8; +state_8: rc = read_fully(fd, nr, &(nr_nl->addr[0]), nr_nl->addrlen, &(nr_nl->fieldlen)); @@ -845,8 +823,8 @@ state_9: LIST_NEIGH_FIELD_LATENCY) { nr_nl->latency = 0; - nr_nl->state = 10; -state_10: + nr_nl->state = 9; +state_9: rc = read_fully(fd, nr, &nr_nl->latency, 1, &(nr_nl->fieldlen)); if (rc != RC_OK) @@ -857,8 +835,8 @@ state_10: discard_field: if (nr_nl->fieldlen > 0) { - nr_nl->state = 11; -state_11: + nr_nl->state = 10; +state_10: rc = read_discard(fd, nr, nr_nl->fieldlen); if (rc != RC_OK) return bzero_nr_iffinished(nr, rc); diff --git a/libcor.h b/libcor.h index 7ea9e07..229aa26 100644 --- a/libcor.h +++ b/libcor.h @@ -265,10 +265,9 @@ extern int send_connect_port_nonblock(int fd, extern int send_connect_port(int fd, __u64 port); extern int send_list_neigh_nonblock(int fd, - struct libcor_nonblock_resumeinfo *nr, - __u32 limit, __u32 offset); + struct libcor_nonblock_resumeinfo *nr); -extern int send_list_neigh(int fd, __u32 limit, __u32 offset); +extern int send_list_neigh(int fd); extern int read_neigh_list_nonblock(int fd, struct libcor_nonblock_resumeinfo *nr, diff --git a/test_neigh.c b/test_neigh.c index d4c8cf6..2b62cbb 100644 --- a/test_neigh.c +++ b/test_neigh.c @@ -67,7 +67,7 @@ int main(void) goto out; } - rc = send_list_neigh(fd, 100, 0); + rc = send_list_neigh(fd); printf("readresp %d\n", rc); rc = read_resp(fd); diff --git a/test_route.c b/test_route.c index 27cb12e..13e6135 100644 --- a/test_route.c +++ b/test_route.c @@ -264,7 +264,7 @@ void load_neigh_list(struct e2e_route *route) goto out; } } - rc = send_list_neigh(fd, 100, 0); + rc = send_list_neigh(fd); if (rc != RC_OK) { printf("send_list_neigh error\n"); goto out; diff --git a/test_routed.c b/test_routed.c index 9a98f84..31e842e 100644 --- a/test_routed.c +++ b/test_routed.c @@ -291,7 +291,7 @@ void load_neigh_list(struct e2e_route *route) } } - rc = send_list_neigh(fd, 100, 0); + rc = send_list_neigh(fd); if (rc != RC_OK) { printf("load_neigh_list: send_list_neigh error\n"); goto out; -- 2.11.4.GIT