1NN_CMSG(3)                       nanomsg 1.1.5                      NN_CMSG(3)
2
3
4

NAME

6       nn_cmsg - access control information
7

SYNOPSIS

9       #include <nanomsg/nn.h>
10
11       struct nn_cmsghdr *NN_CMSG_FIRSTHDR(struct nn_msghdr *hdr);
12
13       struct nn_cmsghdr *NN_CMSG_NXTHDR(struct nn_msghdr *hdr, struct
14       nn_cmsghdr *cmsg);
15
16       unsigned char *NN_CMSG_DATA(struct nn_cmsghdr *cmsg);
17
18       size_t NN_CMSG_SPACE(size_t len);
19
20       size_t NN_CMSG_LEN(size_t len);
21

DESCRIPTION

23       These functions can be used to iterate over ancillary data attached to
24       a message.
25
26       Structure nn_cmsghdr represents a single ancillary property and
27       contains following members:
28
29           size_t cmsg_len;
30           int cmsg_level;
31           int cmsg_type;
32
33       cmsg_len is the size of the property data, including the preceding
34       nn_cmsghdr structure. cmsg_level is the level of the property; same
35       values can be used as with nn_getsockopt(3) and nn_setsockopt(3).
36       cmsg_type is the name of the property. These names are specific for
37       each level.
38
39       NN_CMSG_FIRSTHDR returns a pointer to the first nn_cmsghdr in the
40       control buffer in the supplied nn_msghdr structure.
41
42       NN_CMSG_NXTHDR returns the next nn_cmsghdr after the supplied
43       nn_cmsghdr. Returns NULL if there isn’t enough space in the buffer.
44
45       NN_CMSG_DATA returns a pointer to the data associated with supplied
46       nn_cmsghdr.
47
48       NN_CMSG_SPACE returns the number of bytes occupied by nn_cmsghdr with
49       payload of the specified length.
50
51       NN_CMSG_LEN returns the value to store in the cmsg_len member of the
52       cmsghdr structure, taking into account any  necessary  alignment.
53

EXAMPLE

55       Iterating over ancillary properties:
56
57           struct nn_cmsghdr *hdr = NN_CMSG_FIRSTHDR (&msg);
58           while (hdr != NULL) {
59               size_t len = hdr->cmsg_len - sizeof (nn_cmsghdr);
60               printf ("level: %d property: %d length: %dB data: ",
61                   (int) hdr->cmsg_level,
62                   (int) hdr->cmsg_type,
63                   (int) len);
64               unsigned char *data = NN_CMSG_DATA(hdr);
65               while (len) {
66                   printf ("%02X", *data);
67                   ++data;
68                   --len;
69               }
70               printf ("\n");
71               hdr = NN_CMSG_NXTHDR (&msg, hdr);
72           }
73

SEE ALSO

75       nn_sendmsg(3) nn_recvmsg(3) nn_getsockopt(3) nn_setsockopt(3)
76       nanomsg(7)
77

AUTHORS

79       Martin Sustrik <sustrik@250bpm.com>
80
81
82
83                                  2020-01-29                        NN_CMSG(3)
Impressum