eal/x86: add more CPU flags
[dpdk.git] / lib / librte_cmdline / cmdline_parse_ipaddr.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation.
3  * Copyright (c) 2009, Olivier MATZ <zer0@droids-corp.org>
4  * All rights reserved.
5  */
6
7 #ifndef _PARSE_IPADDR_H_
8 #define _PARSE_IPADDR_H_
9
10 #include <cmdline_parse.h>
11 #include <netinet/in.h>
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 #define CMDLINE_IPADDR_V4      0x01
18 #define CMDLINE_IPADDR_V6      0x02
19 #define CMDLINE_IPADDR_NETWORK 0x04
20
21 struct cmdline_ipaddr {
22         uint8_t family;
23         union {
24                 struct in_addr ipv4;
25                 struct in6_addr ipv6;
26         } addr;
27         unsigned int prefixlen; /* in case of network only */
28 };
29 typedef struct cmdline_ipaddr cmdline_ipaddr_t;
30
31 struct cmdline_token_ipaddr_data {
32         uint8_t flags;
33 };
34
35 struct cmdline_token_ipaddr {
36         struct cmdline_token_hdr hdr;
37         struct cmdline_token_ipaddr_data ipaddr_data;
38 };
39 typedef struct cmdline_token_ipaddr cmdline_parse_token_ipaddr_t;
40
41 extern struct cmdline_token_ops cmdline_token_ipaddr_ops;
42
43 int cmdline_parse_ipaddr(cmdline_parse_token_hdr_t *tk, const char *srcbuf,
44         void *res, unsigned ressize);
45 int cmdline_get_help_ipaddr(cmdline_parse_token_hdr_t *tk, char *dstbuf,
46         unsigned int size);
47
48 #define TOKEN_IPADDR_INITIALIZER(structure, field)      \
49 {                                                       \
50         /* hdr */                                           \
51         {                                                   \
52                 &cmdline_token_ipaddr_ops,      /* ops */       \
53                 offsetof(structure, field),     /* offset */    \
54         },                                                  \
55         /* ipaddr_data */                                   \
56         {                                                   \
57                 CMDLINE_IPADDR_V4 |             /* flags */     \
58                 CMDLINE_IPADDR_V6,                              \
59         },                                                  \
60 }
61
62 #define TOKEN_IPV4_INITIALIZER(structure, field)        \
63 {                                                       \
64         /* hdr */                                           \
65         {                                                   \
66                 &cmdline_token_ipaddr_ops,      /* ops */       \
67                 offsetof(structure, field),     /* offset */    \
68         },                                                  \
69         /* ipaddr_data */                                   \
70         {                                                   \
71                 CMDLINE_IPADDR_V4,              /* flags */     \
72         },                                                  \
73 }
74
75 #define TOKEN_IPV6_INITIALIZER(structure, field)        \
76 {                                                       \
77         /* hdr */                                           \
78         {                                                   \
79                 &cmdline_token_ipaddr_ops,      /* ops */       \
80                 offsetof(structure, field),     /* offset */    \
81         },                                                  \
82         /* ipaddr_data */                                   \
83         {                                                   \
84                 CMDLINE_IPADDR_V6,              /* flags */     \
85         },                                                  \
86 }
87
88 #define TOKEN_IPNET_INITIALIZER(structure, field)       \
89 {                                                       \
90         /* hdr */                                           \
91         {                                                   \
92                 &cmdline_token_ipaddr_ops,      /* ops */       \
93                 offsetof(structure, field),     /* offset */    \
94         },                                                  \
95         /* ipaddr_data */                                   \
96         {                                                   \
97                 CMDLINE_IPADDR_V4 |             /* flags */     \
98                 CMDLINE_IPADDR_V6 |                             \
99                 CMDLINE_IPADDR_NETWORK,                         \
100         },                                                  \
101 }
102
103 #define TOKEN_IPV4NET_INITIALIZER(structure, field)     \
104 {                                                       \
105         /* hdr */                                           \
106         {                                                   \
107                 &cmdline_token_ipaddr_ops,      /* ops */       \
108                 offsetof(structure, field),     /* offset */    \
109         },                                                  \
110         /* ipaddr_data */                                   \
111         {                                                   \
112                 CMDLINE_IPADDR_V4 |             /* flags */     \
113                 CMDLINE_IPADDR_NETWORK,                         \
114         },                                                  \
115 }
116
117 #define TOKEN_IPV6NET_INITIALIZER(structure, field)     \
118 {                                                       \
119         /* hdr */                                           \
120         {                                                   \
121                 &cmdline_token_ipaddr_ops,      /* ops */       \
122                 offsetof(structure, field),     /* offset */    \
123         },                                                  \
124         /* ipaddr_data */                                   \
125         {                                                   \
126                 CMDLINE_IPADDR_V4 |             /* flags */     \
127                 CMDLINE_IPADDR_NETWORK,                         \
128         },                                                  \
129 }
130
131 #ifdef __cplusplus
132 }
133 #endif
134
135 #endif /* _PARSE_IPADDR_H_ */