/*--------------------------------------------------------------------------
  Rejects a packet sent by a WAN protocol by indicating an LCP
  protocol reject packet back to the protocol.
  --------------------------------------------------------------------------*/
static void
ssh_wan_reject_protocol_send(SshNdisIMAdapter adapter, 
                             SshUInt32 protocol,
                             PUCHAR buffer, 
                             ULONG length)
{
  PUCHAR reject_buf;
  ULONG reject_len;

  /* Allocate a buffer large enough to contain:
     - PPP header (max 4 octets)
     - LCP header (4 octets)
     - rejected protocol (2 octets)
     - original packet (length octets) */
  reject_len = 4 + 4 + 2 + length;
  reject_buf = ssh_wan_alloc_buffer_receive(adapter, reject_len);
  if (reject_buf == NULL)
    {
      SSH_DEBUG(SSH_D_FAIL, ("Cannot allocate buffer for protocol reject"));
      return;
    }

  reject_len =
    ssh_wan_encode_lcp_protocol_reject(reject_buf, reject_len,
                                       adapter->ppp_receive_flags,
                                       adapter->ppp_receive_lcp_id++,
                                       protocol,
                                       buffer,
                                       length);

  ssh_wan_receive_buffer(adapter, reject_buf, reject_len);
  NdisMWanIndicateReceiveComplete(adapter->handle,adapter->wan_link_context);
}
Beispiel #2
0
//
// this function checks all of the mtl's on this adapter to see if
// the protocols need to be given a chance to do some work
//
VOID
MtlRecvCompleteFunction(
	ADAPTER *Adapter
	)
{
	ULONG	n;

	for ( n = 0; n < MAX_MTL_PER_ADAPTER; n++)
	{
		MTL	*mtl = Adapter->MtlTbl[n] ;

		//
		// if this is a valid mtl
		//
		if (mtl)
		{
			//
			// get lock for this mtl
			//
			NdisAcquireSpinLock(&mtl->lock);

			//
			// is a receive complete scheduled on a valid link?
			//
			if (mtl->RecvCompleteScheduled && mtl->LinkHandle)
			{
				//
				// release the lock
				//
				NdisReleaseSpinLock(&mtl->lock);
	
				NdisMWanIndicateReceiveComplete(Adapter->Handle,
													mtl->LinkHandle);
	
				//
				// reaquire the lock
				//
				NdisAcquireSpinLock(&mtl->lock);

				//
				// clear the schedule flag
				//
				mtl->RecvCompleteScheduled = 0;
			}

			//
			// release the lock
			//
			NdisReleaseSpinLock(&mtl->lock);
		}
	}
}
/*--------------------------------------------------------------------------
  Inspects an IPCP packet sent to a WAN adapter. If it is a
  Configure-Request containing unwanted options, rejects it by
  indicating an IPCP Configure-Reject to the WAN protocol and returns
  TRUE. Returns TRUE also if the IPCP packet is invalid or another
  error occurs. Returns FALSE if the IPCP packet is valid and was not
  intercepted.
 --------------------------------------------------------------------------*/
static Boolean
ssh_wan_intercept_ipcp_send(SshNdisIMAdapter adapter, 
                            PUCHAR buffer, 
                            ULONG length)
{
  PUCHAR reject_buf, dpos = buffer, epos;
  ULONG reject_len, dlen = length, elen;

  /* Allocate a buffer large enough to contain:
     - PPP header (max 4 octets)
     - IPCP packet as large as the received one (length octets) */
  reject_len = 4 + length;
  reject_buf = ssh_wan_alloc_buffer_receive(adapter, reject_len);
  if (reject_buf == NULL)
    goto fail;

  epos = reject_buf;
  elen = reject_len;

  /* Encode PPP header. */
  if (!ssh_wan_encode_ppp_header(&epos, &elen, SSH_PPP_PROTOCOL_IPCP4,
                                 adapter->ppp_receive_flags))
    goto fail;

  /* Scan the packet for any options that should be rejected and build
     a reject packet. Return FALSE if nothing rejected. */
  if (!ssh_wan_ipcp_reject(&dpos, &dlen, &epos, &elen))
    {
      ssh_wan_free_buffer_receive(reject_buf);
      return FALSE;
    }

  /* Send reject. */
  SSH_DEBUG(SSH_D_HIGHSTART, ("Sending IPCP Configure-Reject to protocol"));
  ssh_wan_receive_buffer(adapter, reject_buf, epos - reject_buf);
  NdisMWanIndicateReceiveComplete(adapter->handle,adapter->wan_link_context);
  return TRUE;

 fail:
  SSH_DEBUG(SSH_D_FAIL, ("Cannot send IPCP Configure-Reject"));
  if (reject_buf)
    ssh_wan_free_buffer_receive(reject_buf);
  return TRUE;
}