pkt.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright (C) 2000, 2003 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* ident "@(#)$Id: pkt.c,v 1.8 2003/07/28 05:13:58 darrenr Exp $"
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef __hpux
#pragma ident "%Z%%M% %I% %E% SMI"
#endif
#include <netinet/in_systm.h>
#if SOLARIS2 >= 8
#endif
#include "compat.h"
#include "qif.h"
#if 1
/* ------------------------------------------------------------------------ */
/* Function: pfil_make_dl_packet (mb, ip, dst, ifname, output_q) */
/* Returns: On success, datalink msg block. */
/* On failure, NULL. */
/* Parameters: */
/* mblk_t *mb: IP message block */
/* struct ip *ip: ip header start pointer */
/* void *dst: destination address. */
/* if it is null, destination address is in ip */
/* for IPV4, the parameter should be an instance of in_addr */
/* for IPV6, the parameter should be an instance of in6_addr */
/* char *ifname: output interface name */
/* if neither of dst and ifname is NULL, the routing for dst */
/* should have same interface name as ifname; */
/* If ifname is NULL, output interface name is not specified */
/* so it is decided by routing table. */
/* if dst is NULL(ifname is not NULL), destination address */
/* in IP packet will be used for routing lookup, and the packet */
/* will be send out to interface ifname */
/* queue_t **output_q: the write queue of pfil module where the */
/* returned message block can be putnext */
/* */
/* This function is called to make a datalink message based on the IP */
/* message block mb, If the function successfully returns, output_q */
/* is set to the pfil module's write queue of output interface. Please use */
/* pfil_send_dl_packet to putnext the returned packet to output_q. */
/* */
/* This function will return with a 'lock' held on the qif structure via */
/* the PT_ENTER_READ() macro if qif_iflookup succeeds. This lock is then */
/* intended to be released when the queue returned is no longer referenced. */
/* */
/* fr_fastroute, fr_send_icmp_err, fr_send_reset will call this func to */
/* prepare packet. */
/* */
/* ip_nexthop[_route] is called to search routing info in this func. */
/* ------------------------------------------------------------------------ */
void *dst;
char *ifname;
{
int ip_inf_bind = 0;
char out_ifname_buf[LIFNAMSIZ];
struct sockaddr_storage target;
int sap;
else
{
ip_inf_bind = 1;
}
}
#ifdef USE_INET6
sap = IP6_DL_SAP;
/* To do: add code for IPV6 */
return NULL;
}
#endif
if (ip_inf_bind)
else {
}
return NULL;
/* look for output queue */
return NULL;
}
/* OK, by now, we can link the IP message to lay2 header */
return mb;
}
/* ------------------------------------------------------------------------ */
/* Function: pfil_send_dl_packet (output_q, mb) */
/* Returns: void */
/* Parameters: */
/* queue_t *output_q: pfil module's write queue */
/* mblk_t *mb: Lay2 message block. This parameter should be the return */
/* value of pfil_make_layer2_packet */
/* This function is called to send the packet returned by */
/* pfil_make_dl_packet. */
/* In this function, PT_EXIT_READ is used after the putnext call to release */
/* the qif structure held by function pfil_make_layer2_packet. */
/* ------------------------------------------------------------------------ */
{
/*
* NOTE: It is not permitted to hold a lock across putnext() so we
* use a semaphore-like operation to signal when it is ok to delete
* the qif structure. With the current locking structure, putnext()
* may be called here after qprocsoff() has been called on output_q,
* but before the queue was completely closed. See pfilmodclose().
*/
/*
* If pfil_make_dl_packet() returned an M_PROTO message it's
* probably an ARP AR_ENTRY_QUERY message, which we can't
* handle, so we just send the IP packet up to pfild to
* transmit it via a raw socket.
*/
} else {
}
}
#else /* pfil_sendbuf implementation for no IRE_ILL_CN definition */
/* ------------------------------------------------------------------------ */
/* Function: pfil_sendbuf */
/* Returns: int - 0 == success, 1 == failure */
/* Parameters: m(I) - pointer to streams message */
/* v - indicated v4 or v6 */
/* */
/* Output an IPv4 packet to whichever interface has the correct route. */
/* ------------------------------------------------------------------------ */
int pfil_sendbuf(m)
mblk_t *m;
{
u_char *s;
#ifdef MATCH_IRE_DSTONLY
#else
#endif
if (dir) {
#if SOLARIS2 >= 8
#else
#endif
return 2;
}
if (dir) {
if (!il)
return (2);
#if SOLARIS2 < 8
#else
#endif
if (hlen &&
#ifdef ICK_M_CTL_MAGIC
#endif
s -= hlen;
} else {
if (!mp2)
goto bad_nexthop;
m = mp2;
}
if (q)
q = q->q_next;
if (q) {
putnext(q, m);
return 0;
}
}
freemsg(m);
return 1;
}
#endif /* 1 */