linux/include/linux/drbd_tag_magic.h
<<
>>
Prefs
   1#ifndef DRBD_TAG_MAGIC_H
   2#define DRBD_TAG_MAGIC_H
   3
   4#define TT_END     0
   5#define TT_REMOVED 0xE000
   6
   7/* declare packet_type enums */
   8enum packet_types {
   9#define NL_PACKET(name, number, fields) P_ ## name = number,
  10#define NL_RESPONSE(name, number) P_ ## name = number,
  11#define NL_INTEGER(pn, pr, member)
  12#define NL_INT64(pn, pr, member)
  13#define NL_BIT(pn, pr, member)
  14#define NL_STRING(pn, pr, member, len)
  15#include "drbd_nl.h"
  16        P_nl_after_last_packet,
  17};
  18
  19/* These struct are used to deduce the size of the tag lists: */
  20#define NL_PACKET(name, number, fields) \
  21        struct name ## _tag_len_struct { fields };
  22#define NL_INTEGER(pn, pr, member)              \
  23        int member; int tag_and_len ## member;
  24#define NL_INT64(pn, pr, member)                \
  25        __u64 member; int tag_and_len ## member;
  26#define NL_BIT(pn, pr, member)          \
  27        unsigned char member:1; int tag_and_len ## member;
  28#define NL_STRING(pn, pr, member, len)  \
  29        unsigned char member[len]; int member ## _len; \
  30        int tag_and_len ## member;
  31#include <linux/drbd_nl.h>
  32
  33/* declare tag-list-sizes */
  34static const int tag_list_sizes[] = {
  35#define NL_PACKET(name, number, fields) 2 fields ,
  36#define NL_INTEGER(pn, pr, member)      + 4 + 4
  37#define NL_INT64(pn, pr, member)        + 4 + 8
  38#define NL_BIT(pn, pr, member)          + 4 + 1
  39#define NL_STRING(pn, pr, member, len)  + 4 + (len)
  40#include "drbd_nl.h"
  41};
  42
  43/* The two highest bits are used for the tag type */
  44#define TT_MASK      0xC000
  45#define TT_INTEGER   0x0000
  46#define TT_INT64     0x4000
  47#define TT_BIT       0x8000
  48#define TT_STRING    0xC000
  49/* The next bit indicates if processing of the tag is mandatory */
  50#define T_MANDATORY  0x2000
  51#define T_MAY_IGNORE 0x0000
  52#define TN_MASK      0x1fff
  53/* The remaining 13 bits are used to enumerate the tags */
  54
  55#define tag_type(T)   ((T) & TT_MASK)
  56#define tag_number(T) ((T) & TN_MASK)
  57
  58/* declare tag enums */
  59#define NL_PACKET(name, number, fields) fields
  60enum drbd_tags {
  61#define NL_INTEGER(pn, pr, member)     T_ ## member = pn | TT_INTEGER | pr ,
  62#define NL_INT64(pn, pr, member)       T_ ## member = pn | TT_INT64   | pr ,
  63#define NL_BIT(pn, pr, member)         T_ ## member = pn | TT_BIT     | pr ,
  64#define NL_STRING(pn, pr, member, len) T_ ## member = pn | TT_STRING  | pr ,
  65#include "drbd_nl.h"
  66};
  67
  68struct tag {
  69        const char *name;
  70        int type_n_flags;
  71        int max_len;
  72};
  73
  74/* declare tag names */
  75#define NL_PACKET(name, number, fields) fields
  76static const struct tag tag_descriptions[] = {
  77#define NL_INTEGER(pn, pr, member)     [ pn ] = { #member, TT_INTEGER | pr, sizeof(int)   },
  78#define NL_INT64(pn, pr, member)       [ pn ] = { #member, TT_INT64   | pr, sizeof(__u64) },
  79#define NL_BIT(pn, pr, member)         [ pn ] = { #member, TT_BIT     | pr, sizeof(int)   },
  80#define NL_STRING(pn, pr, member, len) [ pn ] = { #member, TT_STRING  | pr, (len)         },
  81#include "drbd_nl.h"
  82};
  83
  84#endif
  85
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.