diff options
| author | Mariusz Zaborski <oshogbo@FreeBSD.org> | 2015-05-02 17:45:52 +0000 |
|---|---|---|
| committer | Mariusz Zaborski <oshogbo@FreeBSD.org> | 2015-05-02 17:45:52 +0000 |
| commit | bd1da0a002e9a43cfb5220835c7a42804d90dc56 (patch) | |
| tree | a69b34916c7078793947216a35639f78cd60366e /lib/libnv | |
| parent | 1025d8e679437d2c79aafbdf418c3126a1c2f29e (diff) | |
Notes
Diffstat (limited to 'lib/libnv')
| -rw-r--r-- | lib/libnv/nv.3 | 50 | ||||
| -rw-r--r-- | lib/libnv/tests/nv_tests.cc | 6 | ||||
| -rw-r--r-- | lib/libnv/tests/nvlist_send_recv_test.c | 2 |
3 files changed, 47 insertions, 11 deletions
diff --git a/lib/libnv/nv.3 b/lib/libnv/nv.3 index bbb7b031107c..4c0e236b090a 100644 --- a/lib/libnv/nv.3 +++ b/lib/libnv/nv.3 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 1, 2015 +.Dd May 2, 2015 .Dt NV 3 .Os .Sh NAME @@ -85,14 +85,14 @@ .Ft "void *" .Fn nvlist_pack "const nvlist_t *nvl" "size_t *sizep" .Ft "nvlist_t *" -.Fn nvlist_unpack "const void *buf" "size_t size" +.Fn nvlist_unpack "const void *buf" "size_t size" "int flags" .\" .Ft int .Fn nvlist_send "int sock" "const nvlist_t *nvl" .Ft "nvlist_t *" -.Fn nvlist_recv "int sock" +.Fn nvlist_recv "int sock" "int flags" .Ft "nvlist_t *" -.Fn nvlist_xfer "int sock" "nvlist_t *nvl" +.Fn nvlist_xfer "int sock" "nvlist_t *nvl" "int flags" .\" .Ft "const char *" .Fn nvlist_next "const nvlist_t *nvl" "int *typep" "void **cookiep" @@ -325,6 +325,18 @@ The nvlist must not be in error state. The .Fn nvlist_unpack function converts the given buffer to the nvlist. +The +.Fa flags +argument defines what type of the top level nvlist is expected to be. +Flags are set up using the +.Fn nvlist_create +function. +If the nvlist flags do not match the flags passed to +.Fn nvlist_unpack , +the nvlist will not be returned. +Every nested nvlist list should be checked using +.Fn nvlist_flags +function. The function returns .Dv NULL in case of an error. @@ -343,12 +355,36 @@ The function receives nvlist over the socket given by the .Fa sock argument. +The +.Fa flags +argument defines what type of the top level nvlist is expected to be. +Flags are set up using the +.Fn nvlist_create +function. +If the nvlist flags do not match the flags passed to +.Fn nvlist_recv , +the nvlist will not be returned. +Every nested nvlist list should be checked using +.Fn nvlist_flags +function. .Pp The .Fn nvlist_xfer function sends the given nvlist over the socket given by the .Fa sock argument and receives nvlist over the same socket. +The +.Fa flags +argument defines what type of the top level nvlist is expected to be. +Flags are set up using the +.Fn nvlist_create +function. +If the nvlist flags do not match the flags passed to +.Fn nvlist_xfer , +the nvlist will not be returned. +Every nested nvlist list should be checked using +.Fn nvlist_flags +function. The given nvlist is always destroyed. .Pp The @@ -559,7 +595,7 @@ const char *command; char *filename; int fd; -nvl = nvlist_recv(sock); +nvl = nvlist_recv(sock, 0); if (nvl == NULL) err(1, "nvlist_recv() failed"); @@ -588,7 +624,7 @@ const char *name; void *cookie; int type; -nvl = nvlist_recv(sock); +nvl = nvlist_recv(sock, 0); if (nvl == NULL) err(1, "nvlist_recv() failed"); @@ -617,7 +653,7 @@ const char *name; void *cookie; int type; -nvl = nvlist_recv(sock); +nvl = nvlist_recv(sock, 0); if (nvl == NULL) err(1, "nvlist_recv() failed"); diff --git a/lib/libnv/tests/nv_tests.cc b/lib/libnv/tests/nv_tests.cc index 2d9fd97914d1..1fee182acea0 100644 --- a/lib/libnv/tests/nv_tests.cc +++ b/lib/libnv/tests/nv_tests.cc @@ -440,7 +440,7 @@ ATF_TEST_CASE_BODY(nvlist_pack__empty_nvlist) packed = nvlist_pack(nvl, &packed_size); ATF_REQUIRE(packed != NULL); - unpacked = nvlist_unpack(packed, packed_size); + unpacked = nvlist_unpack(packed, packed_size, 0); ATF_REQUIRE(unpacked != NULL); ATF_REQUIRE(unpacked != nvl); ATF_REQUIRE(nvlist_empty(unpacked)); @@ -534,7 +534,7 @@ ATF_TEST_CASE_BODY(nvlist_pack__multiple_values) packed = nvlist_pack(nvl, &packed_size); ATF_REQUIRE(packed != NULL); - unpacked = nvlist_unpack(packed, packed_size); + unpacked = nvlist_unpack(packed, packed_size, 0); ATF_REQUIRE(unpacked != 0); it = NULL; @@ -614,7 +614,7 @@ ATF_TEST_CASE_BODY(nvlist_unpack__duplicate_key) ATF_REQUIRE(keypos != NULL); memcpy(keypos, key2, keylen); - unpacked = nvlist_unpack(packed, size); + unpacked = nvlist_unpack(packed, size, 0); ATF_REQUIRE(nvlist_error(unpacked) != 0); free(packed); diff --git a/lib/libnv/tests/nvlist_send_recv_test.c b/lib/libnv/tests/nvlist_send_recv_test.c index 1b083c35d339..50222fbb8e39 100644 --- a/lib/libnv/tests/nvlist_send_recv_test.c +++ b/lib/libnv/tests/nvlist_send_recv_test.c @@ -95,7 +95,7 @@ parent(int sock) int type, ctype; size_t size; - nvl = nvlist_recv(sock); + nvl = nvlist_recv(sock, 0); CHECK(nvlist_error(nvl) == 0); if (nvlist_error(nvl) != 0) err(1, "nvlist_recv() failed"); |
