xref: /openbsd/usr.sbin/rpki-client/rrdp.h (revision 097a140d)
1 #ifndef _RRDPH_
2 #define _RRDPH_
3 
4 #define MAX_VERSION 1
5 
6 #define log_debuginfo(format, ...) logx(format, ##__VA_ARGS__)
7 
8 /* save everyone doing this code over and over */
9 #define PARSE_FAIL(p, ...) do {		\
10 	XML_StopParser(p, XML_FALSE);	\
11 	warnx(__VA_ARGS__);		\
12 	return;				\
13 } while (0)
14 
15 enum rrdp_task {
16 	NOTIFICATION,
17 	SNAPSHOT,
18 	DELTA,
19 };
20 
21 /* rrdp generic */
22 char 	*xstrdup(const char *);
23 int	 hex_decode(const char *, char *, size_t);
24 
25 /* publish or withdraw element */
26 struct rrdp;
27 struct publish_xml;
28 
29 struct publish_xml	*new_publish_xml(enum publish_type, char *,
30 			    char *, size_t);
31 void			 free_publish_xml(struct publish_xml *);
32 void			 publish_add_content(struct publish_xml *,
33 			    const char *, int);
34 int			 publish_done(struct rrdp *, struct publish_xml *);
35 
36 /* notification */
37 struct notification_xml;
38 
39 struct notification_xml	*new_notification_xml(XML_Parser,
40 			    struct rrdp_session *, struct rrdp_session *);
41 void		 	 free_notification_xml(struct notification_xml *);
42 enum rrdp_task		 notification_done(struct notification_xml *,
43 			    char *);
44 const char		*notification_get_next(struct notification_xml *,
45 			    char *, size_t, enum rrdp_task);
46 int			 notification_delta_done(struct notification_xml *);
47 void			 log_notification_xml(struct notification_xml *);
48 
49 /* snapshot */
50 struct snapshot_xml;
51 
52 struct snapshot_xml	*new_snapshot_xml(XML_Parser, struct rrdp_session *,
53 			    struct rrdp *);
54 void			 free_snapshot_xml(struct snapshot_xml *);
55 void			 log_snapshot_xml(struct snapshot_xml *);
56 
57 /* delta */
58 struct delta_xml;
59 
60 struct delta_xml	*new_delta_xml(XML_Parser, struct rrdp_session *,
61 			    struct rrdp *);
62 void			 free_delta_xml(struct delta_xml *);
63 void			 log_delta_xml(struct delta_xml *);
64 
65 #endif /* _RRDPH_ */
66