diff options
| author | 2011-05-05 12:25:51 +0000 | |
|---|---|---|
| committer | 2011-05-05 12:25:51 +0000 | |
| commit | 31330dd0376dd9de584ec5a74ad766838f050db7 (patch) | |
| tree | 782a3158c4a9267333d2613380d7502f085bdc22 /libexec/tftp-proxy/filter.c | |
| parent | rename iked_proc* to privsep_proc*. no functional change. (diff) | |
| download | wireguard-openbsd-31330dd0376dd9de584ec5a74ad766838f050db7.tar.xz wireguard-openbsd-31330dd0376dd9de584ec5a74ad766838f050db7.zip | |
Switch tftp-proxy over to using divert-to. Based on a diff from oga@
with lots of help from claudio@. Earlier version was ok mikeb@ and looks
good to markus@.
Note: tftp-proxy rdr-to rules must be changed to use divert-to and must
specify the address family.
pass in quick on internal proto udp to port tftp rdr-to 127.0.0.1 port 6969
-changes to-
pass in quick on internal inet proto udp to port tftp divert-to 127.0.0.1 port 6969
Diffstat (limited to 'libexec/tftp-proxy/filter.c')
| -rw-r--r-- | libexec/tftp-proxy/filter.c | 78 |
1 files changed, 1 insertions, 77 deletions
diff --git a/libexec/tftp-proxy/filter.c b/libexec/tftp-proxy/filter.c index e9ca970638f..91752d4b771 100644 --- a/libexec/tftp-proxy/filter.c +++ b/libexec/tftp-proxy/filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: filter.c,v 1.8 2010/01/13 01:08:14 claudio Exp $ */ +/* $OpenBSD: filter.c,v 1.9 2011/05/05 12:25:51 sthen Exp $ */ /* * Copyright (c) 2004, 2005 Camiel Dobbelaar, <cd@sentia.nl> @@ -46,10 +46,6 @@ enum { TRANS_FILTER = 0, TRANS_NAT, TRANS_RDR, TRANS_SIZE }; int prepare_rule(u_int32_t, struct sockaddr *, struct sockaddr *, u_int16_t, u_int8_t); -int server_lookup4(struct sockaddr_in *, struct sockaddr_in *, - struct sockaddr_in *, u_int8_t); -int server_lookup6(struct sockaddr_in6 *, struct sockaddr_in6 *, - struct sockaddr_in6 *, u_int8_t); static struct pfioc_rule pfr; static struct pfioc_trans pft; @@ -231,75 +227,3 @@ prepare_rule(u_int32_t id, struct sockaddr *src, return (0); } - -int -server_lookup(struct sockaddr *client, struct sockaddr *proxy, - struct sockaddr *server, u_int8_t proto) -{ - if (client->sa_family == AF_INET) - return (server_lookup4(satosin(client), satosin(proxy), - satosin(server), proto)); - - if (client->sa_family == AF_INET6) - return (server_lookup6(satosin6(client), satosin6(proxy), - satosin6(server), proto)); - - errno = EPROTONOSUPPORT; - return (-1); -} - -int -server_lookup4(struct sockaddr_in *client, struct sockaddr_in *proxy, - struct sockaddr_in *server, u_int8_t proto) -{ - struct pfioc_natlook pnl; - - memset(&pnl, 0, sizeof pnl); - pnl.direction = PF_OUT; - pnl.af = AF_INET; - pnl.proto = proto; - memcpy(&pnl.saddr.v4, &client->sin_addr.s_addr, sizeof pnl.saddr.v4); - memcpy(&pnl.daddr.v4, &proxy->sin_addr.s_addr, sizeof pnl.daddr.v4); - pnl.sport = client->sin_port; - pnl.dport = proxy->sin_port; - - if (ioctl(dev, DIOCNATLOOK, &pnl) == -1) - return (-1); - - memset(server, 0, sizeof(struct sockaddr_in)); - server->sin_len = sizeof(struct sockaddr_in); - server->sin_family = AF_INET; - memcpy(&server->sin_addr.s_addr, &pnl.rdaddr.v4, - sizeof server->sin_addr.s_addr); - server->sin_port = pnl.rdport; - - return (0); -} - -int -server_lookup6(struct sockaddr_in6 *client, struct sockaddr_in6 *proxy, - struct sockaddr_in6 *server, u_int8_t proto) -{ - struct pfioc_natlook pnl; - - memset(&pnl, 0, sizeof pnl); - pnl.direction = PF_OUT; - pnl.af = AF_INET6; - pnl.proto = proto; - memcpy(&pnl.saddr.v6, &client->sin6_addr.s6_addr, sizeof pnl.saddr.v6); - memcpy(&pnl.daddr.v6, &proxy->sin6_addr.s6_addr, sizeof pnl.daddr.v6); - pnl.sport = client->sin6_port; - pnl.dport = proxy->sin6_port; - - if (ioctl(dev, DIOCNATLOOK, &pnl) == -1) - return (-1); - - memset(server, 0, sizeof(struct sockaddr_in6)); - server->sin6_len = sizeof(struct sockaddr_in6); - server->sin6_family = AF_INET6; - memcpy(&server->sin6_addr.s6_addr, &pnl.rdaddr.v6, - sizeof server->sin6_addr); - server->sin6_port = pnl.rdport; - - return (0); -} |
