- /* XXX fix error reporting */
- sendto(st->fd, buf->start, buf->size, 0,
- (struct sockaddr *)dest, sizeof(*dest));
+ if (st->use_proxy) {
+ sa=buf_prepend(buf,8);
+ if (dest->ia.sa.sa_family != AF_INET) {
+ Message(M_INFO,
+ "udp: proxy means dropping outgoing non-IPv4 packet to %s\n",
+ iaddr_to_string(&dest->ia));
+ return False;
+ }
+ memcpy(sa,&dest->ia.sin.sin_addr,4);
+ memset(sa+4,0,4);
+ memcpy(sa+6,&dest->ia.sin.sin_port,2);
+ sendto(st->fd,sa,buf->size+8,0,&st->proxy.sa,
+ iaddr_socklen(&st->proxy));
+ buf_unprepend(buf,8);
+ } else {
+ sendto(st->fd, buf->start, buf->size, 0,
+ &dest->ia.sa, iaddr_socklen(&dest->ia));
+ }