-/* $OpenBSD: extern.h,v 1.98 2021/11/25 14:03:40 job Exp $ */
+/* $OpenBSD: extern.h,v 1.99 2021/12/22 09:35:14 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
*/
struct roa_ip {
enum afi afi; /* AFI value */
- size_t maxlength; /* max length or zero */
+ struct ip_addr addr; /* the address prefix itself */
unsigned char min[16]; /* full range minimum */
unsigned char max[16]; /* full range maximum */
- struct ip_addr addr; /* the address prefix itself */
+ unsigned char maxlength; /* max length or zero */
};
/*
/* Repository handling */
int filepath_add(struct filepath_tree *, char *);
-void rrdp_save_state(size_t, struct rrdp_session *);
-int rrdp_handle_file(size_t, enum publish_type, char *,
+void rrdp_save_state(unsigned int, struct rrdp_session *);
+int rrdp_handle_file(unsigned int, enum publish_type, char *,
char *, size_t, char *, size_t);
char *repo_filename(const struct repo *, const char *);
struct repo *ta_lookup(int, struct tal *);
void repo_cleanup(struct filepath_tree *);
void repo_free(void);
-void rsync_finish(size_t, int);
-void http_finish(size_t, enum http_result, const char *);
-void rrdp_finish(size_t, int);
+void rsync_finish(unsigned int, int);
+void http_finish(unsigned int, enum http_result, const char *);
+void rrdp_finish(unsigned int, int);
-void rsync_fetch(size_t, const char *, const char *);
-void http_fetch(size_t, const char *, const char *, int);
-void rrdp_fetch(size_t, const char *, const char *,
+void rsync_fetch(unsigned int, const char *, const char *);
+void http_fetch(unsigned int, const char *, const char *, int);
+void rrdp_fetch(unsigned int, const char *, const char *,
struct rrdp_session *);
-void rrdp_http_done(size_t, enum http_result, const char *);
+void rrdp_http_done(unsigned int, enum http_result, const char *);
int repo_next_timeout(int);
void repo_check_timeout(void);
-/* $OpenBSD: http.c,v 1.50 2021/11/10 09:13:30 claudio Exp $ */
+/* $OpenBSD: http.c,v 1.51 2021/12/22 09:35:14 claudio Exp $ */
/*
* Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
char *host;
char *port;
const char *path; /* points into uri */
- size_t id;
+ unsigned int id;
int outfd;
int redirect_loop;
};
static struct http_conn_list active = LIST_HEAD_INITIALIZER(active);
static struct http_conn_list idle = LIST_HEAD_INITIALIZER(idle);
static struct http_req_queue queue = TAILQ_HEAD_INITIALIZER(queue);
-static size_t http_conn_count;
+static unsigned int http_conn_count;
static struct msgbuf msgq;
static struct sockaddr_storage http_bindaddr;
static size_t tls_ca_size;
/* HTTP request API */
-static void http_req_new(size_t, char *, char *, int, int);
+static void http_req_new(unsigned int, char *, char *, int, int);
static void http_req_free(struct http_request *);
-static void http_req_done(size_t, enum http_result, const char *);
-static void http_req_fail(size_t);
+static void http_req_done(unsigned int, enum http_result, const char *);
+static void http_req_fail(unsigned int);
static int http_req_schedule(struct http_request *);
/* HTTP connection API */
* Create and queue a new request.
*/
static void
-http_req_new(size_t id, char *uri, char *modified_since, int count, int outfd)
+http_req_new(unsigned int id, char *uri, char *modified_since, int count,
+ int outfd)
{
struct http_request *req;
char *host, *port, *path;
* Enqueue request response
*/
static void
-http_req_done(size_t id, enum http_result res, const char *last_modified)
+http_req_done(unsigned int id, enum http_result res, const char *last_modified)
{
struct ibuf *b;
* Enqueue request failure response
*/
static void
-http_req_fail(size_t id)
+http_req_fail(unsigned int id)
{
struct ibuf *b;
enum http_result res = HTTP_FAILED;
if (pfds[0].revents & POLLIN) {
b = io_buf_recvfd(fd, &inbuf);
if (b != NULL) {
- size_t id;
+ unsigned int id;
char *uri;
char *mod;
-/* $OpenBSD: main.c,v 1.168 2021/12/21 17:50:27 claudio Exp $ */
+/* $OpenBSD: main.c,v 1.169 2021/12/22 09:35:14 claudio Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
}
static void
-rrdp_file_resp(size_t id, int ok)
+rrdp_file_resp(unsigned int id, int ok)
{
enum rrdp_msg type = RRDP_FILE;
struct ibuf *b;
}
void
-rrdp_fetch(size_t id, const char *uri, const char *local,
+rrdp_fetch(unsigned int id, const char *uri, const char *local,
struct rrdp_session *s)
{
enum rrdp_msg type = RRDP_START;
* Request a repository sync via rsync URI to directory local.
*/
void
-rsync_fetch(size_t id, const char *uri, const char *local)
+rsync_fetch(unsigned int id, const char *uri, const char *local)
{
struct ibuf *b;
* Request a file from a https uri, data is written to the file descriptor fd.
*/
void
-http_fetch(size_t id, const char *uri, const char *last_mod, int fd)
+http_fetch(unsigned int id, const char *uri, const char *last_mod, int fd)
{
struct ibuf *b;
* Create a pipe and pass the pipe endpoints to the http and rrdp process.
*/
static void
-rrdp_http_fetch(size_t id, const char *uri, const char *last_mod)
+rrdp_http_fetch(unsigned int id, const char *uri, const char *last_mod)
{
enum rrdp_msg type = RRDP_HTTP_INI;
struct ibuf *b;
}
void
-rrdp_http_done(size_t id, enum http_result res, const char *last_mod)
+rrdp_http_done(unsigned int id, enum http_result res, const char *last_mod)
{
enum rrdp_msg type = RRDP_HTTP_FIN;
struct ibuf *b;
struct rrdp_session s;
char *uri, *last_mod, *data;
char hash[SHA256_DIGEST_LENGTH];
- size_t dsz, id;
+ size_t dsz;
+ unsigned int id;
int ok;
io_read_buf(b, &type, sizeof(type));
int
main(int argc, char *argv[])
{
- int rc, c, st, proc, rsync, http, rrdp, ok, hangup = 0;
+ int rc, c, st, proc, rsync, http, rrdp, hangup = 0;
int fl = SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK;
- size_t i, id;
+ size_t i;
pid_t pid, procpid, rsyncpid, httppid, rrdppid;
int fd[2];
struct pollfd pfd[NPFD];
if ((pfd[1].revents & POLLIN)) {
b = io_buf_read(rsync, &rsyncbuf);
if (b != NULL) {
+ unsigned int id;
+ int ok;
+
io_read_buf(b, &id, sizeof(id));
io_read_buf(b, &ok, sizeof(ok));
rsync_finish(id, ok);
if ((pfd[2].revents & POLLIN)) {
b = io_buf_read(http, &httpbuf);
if (b != NULL) {
+ unsigned int id;
enum http_result res;
char *last_mod;
-/* $OpenBSD: print.c,v 1.2 2021/10/25 14:07:56 claudio Exp $ */
+/* $OpenBSD: print.c,v 1.3 2021/12/22 09:35:14 claudio Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
for (i = 0; i < p->ipsz; i++) {
ip_addr_print(&p->ips[i].addr,
p->ips[i].afi, buf, sizeof(buf));
- printf("%5zu: %s maxlen: %zu\n", i + 1,
+ printf("%5zu: %s maxlen: %hhu\n", i + 1,
buf, p->ips[i].maxlength);
}
}
-/* $OpenBSD: repo.c,v 1.16 2021/12/21 16:16:15 claudio Exp $ */
+/* $OpenBSD: repo.c,v 1.17 2021/12/22 09:35:14 claudio Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
char *temp;
struct filepath_tree added;
struct filepath_tree deleted;
- size_t id;
+ unsigned int id;
enum repo_state state;
};
SLIST_HEAD(, rrdprepo) rrdprepos = SLIST_HEAD_INITIALIZER(rrdprepos);
SLIST_ENTRY(rsyncrepo) entry;
char *repouri;
char *basedir;
- size_t id;
+ unsigned int id;
enum repo_state state;
};
SLIST_HEAD(, rsyncrepo) rsyncrepos = SLIST_HEAD_INITIALIZER(rsyncrepos);
char **uri;
size_t urisz;
size_t uriidx;
- size_t id;
+ unsigned int id;
enum repo_state state;
};
SLIST_HEAD(, tarepo) tarepos = SLIST_HEAD_INITIALIZER(tarepos);
struct entityq queue; /* files waiting for repo */
time_t alarm; /* sync timeout */
int talid;
- size_t id; /* identifier */
+ unsigned int id; /* identifier */
};
SLIST_HEAD(, repo) repos = SLIST_HEAD_INITIALIZER(repos);
/* counter for unique repo id */
-size_t repoid;
+unsigned int repoid;
/*
* Database of all file path accessed during a run.
}
static struct tarepo *
-ta_find(size_t id)
+ta_find(unsigned int id)
{
struct tarepo *tr;
}
static struct rsyncrepo *
-rsync_find(size_t id)
+rsync_find(unsigned int id)
{
struct rsyncrepo *rr;
}
static struct rrdprepo *
-rrdp_find(size_t id)
+rrdp_find(unsigned int id)
{
struct rrdprepo *rr;
* Carefully write the RRDP session state file back.
*/
void
-rrdp_save_state(size_t id, struct rrdp_session *state)
+rrdp_save_state(unsigned int id, struct rrdp_session *state)
{
struct rrdprepo *rr;
char *temp, *file;
rr = rrdp_find(id);
if (rr == NULL)
- errx(1, "non-existant rrdp repo %zu", id);
+ errx(1, "non-existant rrdp repo %u", id);
file = rrdp_state_filename(rr, 0);
temp = rrdp_state_filename(rr, 1);
* Returns 1 on success, 0 if the repo is corrupt, -1 on IO error
*/
int
-rrdp_handle_file(size_t id, enum publish_type pt, char *uri,
+rrdp_handle_file(unsigned int id, enum publish_type pt, char *uri,
char *hash, size_t hlen, char *data, size_t dlen)
{
struct rrdprepo *rr;
rr = rrdp_find(id);
if (rr == NULL)
- errx(1, "non-existant rrdp repo %zu", id);
+ errx(1, "non-existant rrdp repo %u", id);
if (rr->state == REPO_FAILED)
return -1;
* RSYNC sync finished, either with or without success.
*/
void
-rsync_finish(size_t id, int ok)
+rsync_finish(unsigned int id, int ok)
{
struct rsyncrepo *rr;
struct tarepo *tr;
rr = rsync_find(id);
if (rr == NULL)
- errx(1, "unknown rsync repo %zu", id);
+ errx(1, "unknown rsync repo %u", id);
/* repository changed state already, ignore request */
if (rr->state != REPO_LOADING)
* RRDP sync finshed, either with or without success.
*/
void
-rrdp_finish(size_t id, int ok)
+rrdp_finish(unsigned int id, int ok)
{
struct rrdprepo *rr;
struct repo *rp;
rr = rrdp_find(id);
if (rr == NULL)
- errx(1, "unknown RRDP repo %zu", id);
+ errx(1, "unknown RRDP repo %u", id);
/* repository changed state already, ignore request */
if (rr->state != REPO_LOADING)
return;
* over to the rrdp process.
*/
void
-http_finish(size_t id, enum http_result res, const char *last_mod)
+http_finish(unsigned int id, enum http_result res, const char *last_mod)
{
struct tarepo *tr;
struct repo *rp;
-/* $OpenBSD: rrdp.c,v 1.18 2021/11/24 15:24:16 claudio Exp $ */
+/* $OpenBSD: rrdp.c,v 1.19 2021/12/22 09:35:14 claudio Exp $ */
/*
* Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
struct rrdp {
TAILQ_ENTRY(rrdp) entry;
- size_t id;
+ unsigned int id;
char *notifyuri;
char *local;
char *last_mod;
* ok should only be set to 1 if the cache is now up-to-date.
*/
static void
-rrdp_done(size_t id, int ok)
+rrdp_done(unsigned int id, int ok)
{
enum rrdp_msg type = RRDP_END;
struct ibuf *b;
* should be set to NULL, else it should point to a proper date string.
*/
static void
-rrdp_http_req(size_t id, const char *uri, const char *last_mod)
+rrdp_http_req(unsigned int id, const char *uri, const char *last_mod)
{
enum rrdp_msg type = RRDP_HTTP_REQ;
struct ibuf *b;
}
static struct rrdp *
-rrdp_new(size_t id, char *local, char *notify, char *session_id,
+rrdp_new(unsigned int id, char *local, char *notify, char *session_id,
long long serial, char *last_mod)
{
struct rrdp *s;
}
static struct rrdp *
-rrdp_get(size_t id)
+rrdp_get(unsigned int id)
{
struct rrdp *s;
static void
rrdp_failed(struct rrdp *s)
{
- size_t id = s->id;
+ unsigned int id = s->id;
/* reset file state before retrying */
s->file_failed = 0;
static void
rrdp_finished(struct rrdp *s)
{
- size_t id = s->id;
+ unsigned int id = s->id;
/* check if all parts of the process have finished */
if ((s->state & RRDP_STATE_DONE) != RRDP_STATE_DONE)
enum rrdp_msg type;
enum http_result res;
long long serial;
- size_t id;
+ unsigned int id;
int ok;
b = io_buf_recvfd(fd, &inbuf);
errx(1, "expected fd not received");
s = rrdp_get(id);
if (s == NULL)
- errx(1, "rrdp session %zu does not exist", id);
+ errx(1, "rrdp session %u does not exist", id);
if (s->state != RRDP_STATE_WAIT)
errx(1, "%s: bad internal state", s->local);
s = rrdp_get(id);
if (s == NULL)
- errx(1, "rrdp session %zu does not exist", id);
+ errx(1, "rrdp session %u does not exist", id);
if (!(s->state & RRDP_STATE_PARSE))
errx(1, "%s: bad internal state", s->local);
case RRDP_FILE:
s = rrdp_get(id);
if (s == NULL)
- errx(1, "rrdp session %zu does not exist", id);
+ errx(1, "rrdp session %u does not exist", id);
if (b->fd != -1)
errx(1, "received unexpected fd");
io_read_buf(b, &ok, sizeof(ok));
-/* $OpenBSD: rsync.c,v 1.30 2021/11/03 14:59:37 claudio Exp $ */
+/* $OpenBSD: rsync.c,v 1.31 2021/12/22 09:35:14 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
* of which process maps to which request.
*/
struct rsyncproc {
- char *uri; /* uri of this rsync proc */
- size_t id; /* identity of request */
- pid_t pid; /* pid of process or 0 if unassociated */
+ char *uri; /* uri of this rsync proc */
+ unsigned int id; /* identity of request */
+ pid_t pid; /* pid of process or 0 if unassociated */
};
/*
for (;;) {
char *uri = NULL, *dst = NULL;
- size_t id;
+ unsigned int id;
pid_t pid;
int st;
}
b = io_new_buffer();
- io_simple_buffer(b, &ids[i].id, sizeof(size_t));
+ io_simple_buffer(b, &ids[i].id,
+ sizeof(ids[i].id));
io_simple_buffer(b, &ok, sizeof(ok));
io_close_buffer(&msgq, b);