* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: lwdclient.h,v 1.6 2000/09/07 21:54:39 explorer Exp $ */
+/* $Id: lwdclient.h,v 1.7 2000/10/12 20:45:19 bwelling Exp $ */
#ifndef NAMED_LWDCLIENT_H
#define NAMED_LWDCLIENT_H 1
struct ns_lwdclient {
isc_sockaddr_t address; /* where to reply */
+ struct in6_pktinfo pktinfo;
+ isc_boolean_t pktinfo_valid;
ns_lwdclientmgr_t *clientmgr; /* our parent */
ISC_LINK(ns_lwdclient_t) link;
unsigned int state;
- void *arg; /* packet processing state */
+ void *arg; /* packet processing state */
/*
* Received data info.
void
ns_lwdclient_send(isc_task_t *, isc_event_t *);
+isc_result_t
+ns_lwdclient_sendreply(ns_lwdclient_t *client, isc_region_t *r);
+
/*
* Processing functions of various types.
*/
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: lwdclient.c,v 1.8 2000/10/04 23:18:51 bwelling Exp $ */
+/* $Id: lwdclient.c,v 1.9 2000/10/12 20:45:11 bwelling Exp $ */
#include <config.h>
return;
}
- /*
- * XXXMLG If we wanted to run on ipv6 as well, we'd need the pktinfo
- * bits. Right now we don't, so don't remember them.
- */
client->recvlength = dev->n;
client->address = dev->address;
+ if ((dev->attributes & ISC_SOCKEVENTATTR_PKTINFO) != 0) {
+ client->pktinfo = dev->pktinfo;
+ client->pktinfo_valid = ISC_TRUE;
+ } else
+ client->pktinfo_valid = ISC_FALSE;
isc_event_free(&ev);
dev = NULL;
isc_event_free(&ev);
}
+isc_result_t
+ns_lwdclient_sendreply(ns_lwdclient_t *client, isc_region_t *r) {
+ struct in6_pktinfo *pktinfo;
+ ns_lwdclientmgr_t *cm = client->clientmgr;
+
+ if (client->pktinfo_valid)
+ pktinfo = &client->pktinfo;
+ else
+ pktinfo = NULL;
+ return (isc_socket_sendto(cm->sock, r, cm->task, ns_lwdclient_send,
+ client, &client->address, pktinfo));
+}
+
void
ns_lwdclient_initialize(ns_lwdclient_t *client, ns_lwdclientmgr_t *cmgr) {
client->clientmgr = cmgr;
client->byaddr = NULL;
client->addrinfo = NULL;
+ client->pktinfo_valid = ISC_FALSE;
+
ISC_LIST_APPEND(cmgr->idle, client, link);
}
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: lwderror.c,v 1.4 2000/08/01 01:11:46 tale Exp $ */
+/* $Id: lwderror.c,v 1.5 2000/10/12 20:45:13 bwelling Exp $ */
#include <config.h>
r.base = client->buffer;
r.length = b.used;
client->sendbuf = client->buffer;
- result = isc_socket_sendto(cm->sock, &r, cm->task, ns_lwdclient_send,
- client, &client->address, NULL);
+ result = ns_lwdclient_sendreply(client, &r);
if (result != ISC_R_SUCCESS) {
ns_lwdclient_stateidle(client);
return;
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: lwdgabn.c,v 1.6 2000/08/01 01:11:47 tale Exp $ */
+/* $Id: lwdgabn.c,v 1.7 2000/10/12 20:45:14 bwelling Exp $ */
#include <config.h>
r.length = lwb.used;
client->sendbuf = r.base;
client->sendlength = r.length;
- result = isc_socket_sendto(cm->sock, &r, cm->task, ns_lwdclient_send,
- client, &client->address, NULL);
+ result = ns_lwdclient_sendreply(client, &r);
if (result != ISC_R_SUCCESS)
goto out;
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: lwdgnba.c,v 1.6 2000/08/01 01:11:48 tale Exp $ */
+/* $Id: lwdgnba.c,v 1.7 2000/10/12 20:45:17 bwelling Exp $ */
#include <config.h>
r.length = lwb.used;
client->sendbuf = r.base;
client->sendlength = r.length;
- result = isc_socket_sendto(cm->sock, &r,
- cm->task, ns_lwdclient_send,
- client, &client->address, NULL);
+ result = ns_lwdclient_sendreply(client, &r);
if (result != ISC_R_SUCCESS)
goto out;
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: lwdnoop.c,v 1.4 2000/08/01 01:11:49 tale Exp $ */
+/* $Id: lwdnoop.c,v 1.5 2000/10/12 20:45:18 bwelling Exp $ */
#include <config.h>
r.length = lwb.used;
client->sendbuf = r.base;
client->sendlength = r.length;
- result = isc_socket_sendto(client->clientmgr->sock, &r,
- client->clientmgr->task, ns_lwdclient_send,
- client, &client->address, NULL);
+ result = ns_lwdclient_sendreply(client, &r);
if (result != ISC_R_SUCCESS)
goto out;