2014-06-24 03:25:16 +02:00
|
|
|
/****************************************************************************
|
2014-06-29 02:07:02 +02:00
|
|
|
* net/devif/devif_pktsend.c
|
2014-06-24 03:25:16 +02:00
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2014-06-24 03:25:16 +02:00
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-06-24 03:25:16 +02:00
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2014-06-24 03:25:16 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
2014-06-24 17:28:44 +02:00
|
|
|
#include <nuttx/net/netdev.h>
|
2014-06-24 03:25:16 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_NET_PKT
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Type Declarations
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-01-19 23:02:56 +01:00
|
|
|
* Public Constant Data
|
2014-06-24 03:25:16 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-10-03 00:30:35 +02:00
|
|
|
* Public Data
|
2014-06-24 03:25:16 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Constant Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2016-02-22 01:08:58 +01:00
|
|
|
* Private Data
|
2014-06-24 03:25:16 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-01-19 23:02:56 +01:00
|
|
|
* Public Functions
|
2014-06-24 03:25:16 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2014-06-29 02:36:09 +02:00
|
|
|
* Name: devif_pkt_send
|
2014-06-24 03:25:16 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called from socket logic in order to send a raw packet in response to
|
2017-05-11 21:35:56 +02:00
|
|
|
* an xmit or poll request from the network interface driver.
|
2014-06-24 03:25:16 +02:00
|
|
|
*
|
2014-06-29 02:36:09 +02:00
|
|
|
* This is almost identical to calling devif_send() except that the data to
|
2015-01-17 12:59:13 +01:00
|
|
|
* be sent is copied into dev->d_buf (vs. dev->d_appdata), since there is
|
2014-06-24 03:38:10 +02:00
|
|
|
* no header on the data.
|
2014-06-24 03:25:16 +02:00
|
|
|
*
|
|
|
|
* Assumptions:
|
2018-06-23 22:09:06 +02:00
|
|
|
* Called with the network locked.
|
2014-06-24 03:25:16 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-06-29 02:36:09 +02:00
|
|
|
void devif_pkt_send(FAR struct net_driver_s *dev, FAR const void *buf,
|
|
|
|
unsigned int len)
|
2014-06-24 03:25:16 +02:00
|
|
|
{
|
2018-07-04 22:10:40 +02:00
|
|
|
DEBUGASSERT(dev && len > 0 && len < NETDEV_PKTSIZE(dev));
|
2014-06-24 03:25:16 +02:00
|
|
|
|
|
|
|
/* Copy the data into the device packet buffer */
|
|
|
|
|
|
|
|
memcpy(dev->d_buf, buf, len);
|
|
|
|
|
|
|
|
/* Set the number of bytes to send */
|
|
|
|
|
|
|
|
dev->d_len = len;
|
|
|
|
dev->d_sndlen = len;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_NET_PKT */
|