| ofs | hex dump | ascii |
|---|
| 0000 | 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 02 3c 00 00 01 46 08 06 00 00 00 6e 5e 45 | .PNG........IHDR...<...F.....n^E |
| 0020 | a0 00 00 00 09 70 48 59 73 00 00 0b 13 00 00 0b 13 01 00 9a 9c 18 00 00 01 d5 69 54 58 74 58 4d | .....pHYs.................iTXtXM |
| 0040 | 4c 3a 63 6f 6d 2e 61 64 6f 62 65 2e 78 6d 70 00 00 00 00 00 3c 78 3a 78 6d 70 6d 65 74 61 20 78 | L:com.adobe.xmp.....<x:xmpmeta.x |
| 0060 | 6d 6c 6e 73 3a 78 3d 22 61 64 6f 62 65 3a 6e 73 3a 6d 65 74 61 2f 22 20 78 3a 78 6d 70 74 6b 3d | mlns:x="adobe:ns:meta/".x:xmptk= |
| 0080 | 22 58 4d 50 20 43 6f 72 65 20 35 2e 31 2e 32 22 3e 0a 20 20 20 3c 72 64 66 3a 52 44 46 20 78 6d | "XMP.Core.5.1.2">....<rdf:RDF.xm |
| 00a0 | 6c 6e 73 3a 72 64 66 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 77 33 2e 6f 72 67 2f 31 39 39 39 2f | lns:rdf="http://www.w3.org/1999/ |
| 00c0 | 30 32 2f 32 32 2d 72 64 66 2d 73 79 6e 74 61 78 2d 6e 73 23 22 3e 0a 20 20 20 20 20 20 3c 72 64 | 02/22-rdf-syntax-ns#">.......<rd |
| 00e0 | 66 3a 44 65 73 63 72 69 70 74 69 6f 6e 20 72 64 66 3a 61 62 6f 75 74 3d 22 22 0a 20 20 20 20 20 | f:Description.rdf:about=""...... |
| 0100 | 20 20 20 20 20 20 20 78 6d 6c 6e 73 3a 74 69 66 66 3d 22 68 74 74 70 3a 2f 2f 6e 73 2e 61 64 6f | .......xmlns:tiff="http://ns.ado |
| 0120 | 62 65 2e 63 6f 6d 2f 74 69 66 66 2f 31 2e 30 2f 22 3e 0a 20 20 20 20 20 20 20 20 20 3c 74 69 66 | be.com/tiff/1.0/">..........<tif |
| 0140 | 66 3a 43 6f 6d 70 72 65 73 73 69 6f 6e 3e 35 3c 2f 74 69 66 66 3a 43 6f 6d 70 72 65 73 73 69 6f | f:Compression>5</tiff:Compressio |
| 0160 | 6e 3e 0a 20 20 20 20 20 20 20 20 20 3c 74 69 66 66 3a 50 68 6f 74 6f 6d 65 74 72 69 63 49 6e 74 | n>..........<tiff:PhotometricInt |
| 0180 | 65 72 70 72 65 74 61 74 69 6f 6e 3e 32 3c 2f 74 69 66 66 3a 50 68 6f 74 6f 6d 65 74 72 69 63 49 | erpretation>2</tiff:PhotometricI |
| 01a0 | 6e 74 65 72 70 72 65 74 61 74 69 6f 6e 3e 0a 20 20 20 20 20 20 20 20 20 3c 74 69 66 66 3a 4f 72 | nterpretation>..........<tiff:Or |
| 01c0 | 69 65 6e 74 61 74 69 6f 6e 3e 31 3c 2f 74 69 66 66 3a 4f 72 69 65 6e 74 61 74 69 6f 6e 3e 0a 20 | ientation>1</tiff:Orientation>.. |
| 01e0 | 20 20 20 20 20 3c 2f 72 64 66 3a 44 65 73 63 72 69 70 74 69 6f 6e 3e 0a 20 20 20 3c 2f 72 64 66 | .....</rdf:Description>....</rdf |
| 0200 | 3a 52 44 46 3e 0a 3c 2f 78 3a 78 6d 70 6d 65 74 61 3e 0a 6d 05 0b 9e 00 00 40 00 49 44 41 54 78 | :RDF>.</x:xmpmeta>.m.....@.IDATx |
| 0220 | 01 ec 7d 07 60 15 55 f6 fe 49 ef 01 92 40 e8 24 a1 f7 10 22 5d a4 f7 22 45 04 14 b1 af 65 d7 ed | ..}.`.U..I...@.$..."].."E....e.. |
| 0240 | ae ba ff dd 75 fb ee 6f 57 d7 b5 eb aa d8 51 29 82 f4 26 88 20 bd f7 de 21 94 84 84 f4 fe ff be | ....u..oW.....Q)..&.....!....... |
| 0260 | f3 72 c3 e3 f1 12 8a 20 29 f7 c2 cb cc dc b9 73 e7 ce 99 f7 e6 7e 73 ce 77 ce f1 28 44 11 5b ac | .r......)......s.....~s.w..(D.[. |
| 0280 | 04 ac 04 ac 04 ac 04 ac 04 ac 04 ac 04 2a b0 04 3c 2b f0 b5 d9 4b b3 12 b0 12 b0 12 b0 12 b0 12 | .............*..<+...K.......... |
| 02a0 | b0 12 b0 12 50 09 58 c0 63 bf 08 56 02 56 02 56 02 56 02 56 02 56 02 15 5e 02 16 f0 54 f8 5b 6c | ....P.X.c..V.V.V.V.V.V..^...T.[l |
| 02c0 | 2f d0 4a c0 4a c0 4a c0 4a c0 4a c0 4a c0 02 1e fb 1d b0 12 b0 12 b0 12 b0 12 b0 12 b0 12 a8 f0 | /.J.J.J.J.J.J................... |
| 02e0 | 12 f0 ae f0 57 58 09 2e f0 c8 91 23 72 f6 ec 59 89 8f 8f bf aa ab 2d 28 28 90 97 5f 7e 59 16 2f | ....WX.....#r..Y......-((.._~Y./ |
| 0300 | 5e 2c 67 ce 9c 91 96 2d 5b ca b3 cf 3e 2b 4d 9a 34 29 3e fe f4 e9 d3 f2 e2 8b 2f ca ba 75 eb b4 | ^,g....-[...>+M.4)>......./..u.. |
| 0320 | 2e 36 36 56 7e f6 b3 9f 49 fd fa f5 75 7b e9 d2 a5 f2 e9 a7 9f ca 5f fe f2 17 89 8c 8c 2c 3e ee | .66V~...I...u{........_......,>. |
| 0340 | d5 57 5f 95 56 ad 5a 49 8f 1e 3d e4 5f ff fa 97 64 66 66 ca ef 7f ff fb e2 fd 79 79 79 f2 f8 e3 | .W_.V.ZI..=._...dff.......yyy... |
| 0360 | 8f cb 7f fe f3 1f 09 0e 0e d6 75 d6 b9 96 9f fc e4 27 d2 a6 4d 1b ad fe fa eb af 65 d2 a4 49 b2 | ..........u......'..M......e..I. |
| 0380 | 6b d7 2e a9 55 ab 96 dc 7f ff fd 32 6a d4 28 bd e6 e7 9e 7b ce f5 50 dd ae 59 b3 a6 fc f9 cf 7f | k...U......2j.(....{..P..Y...... |
| 03a0 | 76 bb af b2 54 3a fb 23 38 af 57 96 eb bf 99 d7 e9 e1 e1 51 dc bd f3 7a 71 a5 5d b1 12 b0 12 28 | v...T:.#8.W........Q...zq.]....( |
| 03c0 | 73 12 b0 80 a7 cc dd 92 6b 1b 50 6e 6e ae 3c fa e8 a3 d2 b8 71 e3 ab 02 3c 9c f8 86 0c 19 a2 60 | s.......k.Pnn.<.....q...<......` |
| 03e0 | e1 b7 bf fd ad 82 8e 99 33 67 4a fb f6 ed 15 dc 34 6b d6 4c f6 ef df 2f 7d fa f4 91 8e 1d 3b ca | ........3gJ.....4k.L.../}.....;. |
| 0400 | 2f 7f f9 4b f1 f2 f2 92 2f be f8 42 db cc 9b 37 4f cf b3 73 e7 4e 79 e7 9d 77 24 3d 3d 5d 81 8f | /..K..../..B...7O..s.Ny..w$==].. |
| 0420 | 19 f5 a2 45 8b b4 3d 01 cf 9c 39 73 e4 9b 6f be 51 e0 72 e7 9d 77 6a 93 fc fc 7c 3d ee ef 7f ff | ...E..=...9s..o.Q.r..wj...|=.... |
| 0440 | bb 9e fb bd f7 de 53 20 e5 0c 9a d8 90 60 88 e5 7f ff fb 9f 3c f3 cc 33 f2 a7 3f fd 49 1e 7b ec | ......S......`......<..3..?.I.{. |
| 0460 | 31 59 b5 6a 95 10 0c 1d 3d 7a 54 1e 7a e8 21 69 d7 ae 9d b6 e3 98 df 78 e3 0d 79 e1 85 17 74 bb | 1Y.j....=zT.z.!i.......x..y...t. |
| 0480 | 6a d5 aa ba ac c8 7f 0c 88 21 80 35 85 75 a6 de d4 d9 e5 0f 23 01 02 1f 67 f0 e3 e9 e9 50 a0 3b | j........!.5.u......#...g....P.; |
| 04a0 | d7 fd 30 23 b1 67 b1 12 b0 12 70 27 01 0f 3c 1c ad 5b ba 3b c9 94 83 ba d7 5e 7b 4d 7e fd eb 5f | ..0#.g....p'..<..[.;.....^{M~.._ |
| 04c0 | ab 16 e5 c9 27 9f 14 6a 57 4c 39 74 e8 90 f8 fa fa 4a 9d 3a 75 4c 95 2e 27 4f 9e ac 20 86 00 21 | ....'..jWL9t.....J.:uL..'O.....! |
| 04e0 | 30 30 b0 78 df d8 b1 63 a5 5a b5 6a 0a 1a 46 8c 18 21 41 41 41 f2 f1 c7 1f 17 ef e7 ca c8 91 23 | 00.x...c.Z.j..F..!AAA..........# |
| 0500 | 55 23 b4 62 c5 0a e1 b9 b9 7f df be 7d c2 3e fb f6 ed ab 6d 87 0f 1f 2e 03 06 0c 50 cd 0d 41 0f | U#.b........}.>....m.......P..A. |
| 0520 | 81 cb 96 2d 5b 54 3b c3 f5 ec ec 6c f1 f7 f7 57 c0 15 11 11 21 7e 7e 7e b2 79 f3 66 69 de bc f9 | ...-[T;....l...W....!~~~.y.fi... |
| 0540 | 25 e7 e2 46 52 52 92 c4 c4 c4 28 d8 ea d7 af 5f f1 fe 29 53 a6 c8 53 4f 3d 25 27 4e 9c 10 33 a9 | %..FRR....(...._..)S..SO=%'N..3. |
| 0560 | 7c fb ed b7 0a e4 52 52 52 8a db 55 d4 15 fe 64 0d c8 29 69 dd 5c bb 69 67 b6 ed f2 c6 4a c0 7c | |.....RRR..U...d..)i.\.ig....J.| |
| 0580 | ff 4c af 04 37 ac 33 e0 c7 75 69 da d9 a5 95 80 95 c0 0f 2f 01 ab e1 f9 e1 65 7e c3 ce f8 f0 c3 | .L..7.3..ui......../.....e~..... |
| 05a0 | 0f cb 84 09 13 e4 77 bf fb 9d 50 73 e2 5c 9e 7e fa 69 35 3f 19 8d 87 d9 37 7b f6 6c 19 3f 7e fc | ......w...Ps.\.~.i5?....7{.l.?~. |
| 05c0 | 25 60 87 fb 3e fb ec 33 6d 42 13 14 35 3e eb d7 af 37 87 14 2f ef ba eb 2e 3d f6 c2 85 0b 5a 57 | %`..>..3mB..5>...7../....=....ZW |
| 05e0 | a3 46 0d f9 d1 8f 7e a4 e0 66 fb f6 ed 0a 64 8a 1b 17 ad 10 48 71 52 e6 18 69 c6 ba 96 42 10 53 | .F....~..f....d.....HqR..i...B.S |
| 0600 | a5 4a 15 71 06 3b 3c 9e e3 e0 a7 b2 15 ca d1 f9 43 30 c3 6d 9a 23 69 62 34 85 75 b6 fc f0 12 30 | .J.q.;<.........C0.m.#ib4.u....0 |
| 0620 | 9a 1c 03 7a fe fd ef 7f 4b d7 ae 5d 8b c1 8f 01 42 3f fc c8 ec 19 ad 04 ac 04 28 01 0b 78 ca f1 | ...z....K..]....B?........(..x.. |
pre { line-height: 125%; margin: 0; }
td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight { background: #ffffff; }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long *//*
* netlink/msg.c Netlink Messages Interface
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
*/
#ifndef NETLINK_MSG_H_
#define NETLINK_MSG_H_
#include <netlink/netlink.h>
#include <netlink/object.h>
#ifdef __cplusplus
extern "C" {
#endif
struct nla_policy;
#define NL_DONTPAD 0
/**
* @ingroup msg
* @brief
* Will cause the netlink pid to be set to the pid assigned to
* the netlink handle (socket) just before sending the message off.
* @note Requires the use of nl_send_auto_complete()!
*/
#define NL_AUTO_PID 0
/**
* @ingroup msg
* @brief
* May be used to refer to a sequence number which should be
* automatically set just before sending the message off.
* @note Requires the use of nl_send_auto_complete()!
*/
#define NL_AUTO_SEQ 0
#define NL_MSG_CRED_PRESENT 1
struct nl_msg
{
int nm_protocol;
int nm_flags;
struct sockaddr_nl nm_src;
struct sockaddr_nl nm_dst;
struct ucred nm_creds;
struct nlmsghdr * nm_nlh;
size_t nm_size;
int nm_refcnt;
};
struct nl_msg;
struct nl_tree;
struct ucred;
/* message parsing */
extern int nlmsg_ok(const struct nlmsghdr *, int);
extern struct nlmsghdr * nlmsg_next(struct nlmsghdr *, int *);
extern int nlmsg_parse(struct nlmsghdr *, int, struct nlattr **,
int, struct nla_policy *);
extern int nlmsg_validate(struct nlmsghdr *, int, int,
struct nla_policy *);
extern struct nl_msg * nlmsg_alloc(void);
extern struct nl_msg * nlmsg_alloc_size(size_t);
extern struct nl_msg * nlmsg_alloc_simple(int, int);
extern void nlmsg_set_default_size(size_t);
extern struct nl_msg * nlmsg_inherit(struct nlmsghdr *);
extern struct nl_msg * nlmsg_convert(struct nlmsghdr *);
extern void * nlmsg_reserve(struct nl_msg *, size_t, int);
extern int nlmsg_append(struct nl_msg *, void *, size_t, int);
extern struct nlmsghdr * nlmsg_put(struct nl_msg *, uint32_t, uint32_t,
int, int, int);
extern void nlmsg_free(struct nl_msg *);
extern int nl_msg_parse(struct nl_msg *,
void (*cb)(struct nl_object *, void *),
void *);
extern void nl_msg_dump(struct nl_msg *, FILE *);
/**
* length of netlink message not including padding
* @arg payload length of message payload
*/
static inline int nlmsg_msg_size(int payload)
{
return NLMSG_HDRLEN + payload;
}
/**
* length of netlink message including padding
* @arg payload length of message payload
*/
static inline int nlmsg_total_size(int payload)
{
return NLMSG_ALIGN(nlmsg_msg_size(payload));
}
/**
* length of padding at the message's tail
* @arg payload length of message payload
*/
static inline int nlmsg_padlen(int payload)
{
return nlmsg_total_size(payload) - nlmsg_msg_size(payload);
}
/**
* head of message payload
* @arg nlh netlink messsage header
*/
static inline void *nlmsg_data(const struct nlmsghdr *nlh)
{
return (unsigned char *) nlh + NLMSG_HDRLEN;
}
static inline void *nlmsg_tail(const struct nlmsghdr *nlh)
{
return (unsigned char *) nlh + NLMSG_ALIGN(nlh->nlmsg_len);
}
/**
* length of message payload
* @arg nlh netlink message header
*/
static inline int nlmsg_len(const struct nlmsghdr *nlh)
{
return nlh->nlmsg_len - NLMSG_HDRLEN;
}
/**
* head of attributes data
* @arg nlh netlink message header
* @arg hdrlen length of family specific header
*/
static inline struct nlattr *nlmsg_attrdata(const struct nlmsghdr *nlh, int hdrlen)
{
unsigned char *data = (unsigned char*)nlmsg_data(nlh);
return (struct nlattr *) (data + NLMSG_ALIGN(hdrlen));
}
/**
* length of attributes data
* @arg nlh netlink message header
* @arg hdrlen length of family specific header
*/
static inline int nlmsg_attrlen(const struct nlmsghdr *nlh, int hdrlen)
{
return nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen);
}
static inline int nlmsg_valid_hdr(const struct nlmsghdr *nlh, int hdrlen)
{
if (nlh->nlmsg_len < (uint)nlmsg_msg_size(hdrlen))
return 0;
return 1;
}
static inline void nlmsg_set_proto(struct nl_msg *msg, int protocol)
{
msg->nm_protocol = protocol;
}
static inline int nlmsg_get_proto(struct nl_msg *msg)
{
return msg->nm_protocol;
}
static inline size_t nlmsg_get_max_size(struct nl_msg *msg)
{
return msg->nm_size;
}
static inline void nlmsg_set_src(struct nl_msg *msg, struct sockaddr_nl *addr)
{
memcpy(&msg->nm_src, addr, sizeof(*addr));
}
static inline struct sockaddr_nl *nlmsg_get_src(struct nl_msg *msg)
{
return &msg->nm_src;
}
static inline void nlmsg_set_dst(struct nl_msg *msg, struct sockaddr_nl *addr)
{
memcpy(&msg->nm_dst, addr, sizeof(*addr));
}
static inline struct sockaddr_nl *nlmsg_get_dst(struct nl_msg *msg)
{
return &msg->nm_dst;
}
static inline void nlmsg_set_creds(struct nl_msg *msg, struct ucred *creds)
{
memcpy(&msg->nm_creds, creds, sizeof(*creds));
msg->nm_flags |= NL_MSG_CRED_PRESENT;
}
static inline struct ucred *nlmsg_get_creds(struct nl_msg *msg)
{
if (msg->nm_flags & NL_MSG_CRED_PRESENT)
return &msg->nm_creds;
return NULL;
}
/**
* Return actual netlink message
* @arg n netlink message
*
* Returns the actual netlink message casted to the type of the netlink
* message header.
*
* @return A pointer to the netlink message.
*/
static inline struct nlmsghdr *nlmsg_hdr(struct nl_msg *n)
{
return n->nm_nlh;
}
/**
* Acquire a reference on a netlink message
* @arg msg message to acquire reference from
*/
static inline void nlmsg_get(struct nl_msg *msg)
{
msg->nm_refcnt++;
}
/**
* Expand maximum payload size of a netlink message
* @arg n Netlink message.
* @arg newlen New maximum payload size.
*
* Reallocates the payload section of a netlink message and increases
* the maximum payload size of the message.
*
* @note Any pointers pointing to old payload block will be stale and
* need to be refetched. Therfore, do not expand while constructing
* nested attributes or while reserved data blocks are held.
*
* @return 0 on success or a negative error code.
*/
static inline int nlmsg_expand(struct nl_msg *n, size_t newlen)
{
void *tmp;
if (newlen <= n->nm_size)
return -NLE_INVAL;
tmp = realloc(n->nm_nlh, newlen);
if (tmp == NULL)
return -NLE_NOMEM;
n->nm_nlh = (struct nlmsghdr*)tmp;
n->nm_size = newlen;
return 0;
}
/**
* @name Iterators
* @{
*/
/**
* @ingroup msg
* Iterate over a stream of attributes in a message
* @arg pos loop counter, set to current attribute
* @arg nlh netlink message header
* @arg hdrlen length of family header
* @arg rem initialized to len, holds bytes currently remaining in stream
*/
#define nlmsg_for_each_attr(pos, nlh, hdrlen, rem) \
nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \
nlmsg_attrlen(nlh, hdrlen), rem)
/**
* Iterate over a stream of messages
* @arg pos loop counter, set to current message
* @arg head head of message stream
* @arg len length of message stream
* @arg rem initialized to len, holds bytes currently remaining in stream
*/
#define nlmsg_for_each_msg(pos, head, len, rem) \
for (pos = head, rem = len; \
nlmsg_ok(pos, rem); \
pos = nlmsg_next(pos, &(rem)))
/** @} */
#ifdef __cplusplus
}
#endif
#endif
|