3 * Common definitions for YAID
5 * (c) 2012 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Yet Another Ident Daemon (YAID).
12 * YAID is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * YAID is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with YAID; if not, write to the Free Software Foundation,
24 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 /*----- Header files ------------------------------------------------------*/
45 #include <sys/types.h>
51 #include <sys/socket.h>
52 #include <netinet/in.h>
53 #include <arpa/inet.h>
55 #include <linux/netlink.h>
56 #include <linux/rtnetlink.h>
60 #include <mLib/bits.h>
61 #include <mLib/conn.h>
62 #include <mLib/darray.h>
63 #include <mLib/dstr.h>
64 #include <mLib/fwatch.h>
65 #include <mLib/quis.h>
66 #include <mLib/report.h>
68 #include <mLib/selbuf.h>
70 /*----- Data structures ---------------------------------------------------*/
87 _(ERROR, U(error, unsigned)) \
88 _(UID, U(uid, uid_t)) \
89 _(NAT, U(nat, struct socket))
92 _(INVPORT, "INVALID-PORT") \
93 _(NOUSER, "NO-USER") \
94 _(HIDDEN, "HIDDEN-USER") \
95 _(UNKNOWN, "UNKNOWN-ERROR")
96 extern const char *const errtok[];
99 #define DEFENUM(err, tok) E_##err,
106 #define DEFENUM(what, branch) R_##what,
114 struct socket s[NDIR];
117 #define DEFBRANCH(WHAT, branch) branch
118 #define U(memb, ty) ty memb;
157 #define DEFENUM(tag, word) A_##tag,
173 struct sockpat sp[NDIR];
176 #define POLICY_INIT(a) { 0, { { { 0 } } }, { a } }
180 const struct query *q;
188 DA_DECL(policy_v, struct policy);
190 /*----- Functions provided ------------------------------------------------*/
192 void logmsg(const struct query *q, int prio, const char *msg, ...);
194 void identify(struct query *q);
196 void init_policy(struct policy *p);
197 void free_policy(struct policy *p);
198 void print_policy(const struct policy *p);
199 int match_policy(const struct policy *p, const struct query *q);
200 int parse_policy(FILE *fp, struct policy *p);
201 int open_policy_file(struct policy_file *pf, const char *name,
202 const char *what, const struct query *q);
203 int read_policy_file(struct policy_file *pf);
204 void close_policy_file(struct policy_file *pf);
205 int load_policy_file(const char *file, policy_v *pv);
207 /*----- That's all, folks -------------------------------------------------*/