2017-07-05 19:01:16 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* net/devif/devif_forward.c
|
|
|
|
*
|
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
|
2017-07-05 19:01:16 +02:00
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2017-07-05 19:01: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.
|
2017-07-05 19:01:16 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
2017-07-08 05:32:10 +02:00
|
|
|
#include <nuttx/mm/iob.h>
|
2017-07-05 19:01:16 +02:00
|
|
|
#include <nuttx/net/netdev.h>
|
|
|
|
|
2017-07-08 02:45:58 +02:00
|
|
|
#include "ipforward/ipforward.h"
|
2017-07-05 19:01:16 +02:00
|
|
|
#include "devif/devif.h"
|
|
|
|
|
2017-08-08 22:24:12 +02:00
|
|
|
#ifdef CONFIG_NET_IPFORWARD
|
2017-07-05 19:01:16 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: devif_forward
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called from protocol-specific IP forwarding logic to re-send a packet.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* fwd - An initialized instance of the common forwarding structure that
|
|
|
|
* includes everything needed to perform the forwarding operation.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* The network is locked.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void devif_forward(FAR struct forward_s *fwd)
|
|
|
|
{
|
|
|
|
unsigned int offset;
|
|
|
|
int ret;
|
|
|
|
|
2017-07-07 00:19:10 +02:00
|
|
|
DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL);
|
2017-07-05 19:01:16 +02:00
|
|
|
offset = NET_LL_HDRLEN(fwd->f_dev);
|
|
|
|
|
2017-07-07 00:19:10 +02:00
|
|
|
/* Copy the IOB chain that contains the L3L3 headers and any data payload */
|
2017-07-05 19:01:16 +02:00
|
|
|
|
2018-07-04 22:10:40 +02:00
|
|
|
DEBUGASSERT(offset + fwd->f_iob->io_pktlen <= NETDEV_PKTSIZE(fwd->f_dev));
|
2017-07-07 00:19:10 +02:00
|
|
|
ret = iob_copyout(&fwd->f_dev->d_buf[offset], fwd->f_iob,
|
|
|
|
fwd->f_iob->io_pktlen, 0);
|
2017-07-05 19:01:16 +02:00
|
|
|
|
2017-07-07 00:19:10 +02:00
|
|
|
DEBUGASSERT(ret == fwd->f_iob->io_pktlen);
|
2017-07-05 19:01:16 +02:00
|
|
|
|
2017-07-08 04:19:26 +02:00
|
|
|
fwd->f_dev->d_sndlen = 0;
|
2017-11-29 01:54:17 +01:00
|
|
|
fwd->f_dev->d_len = fwd->f_iob->io_pktlen;
|
2017-08-12 18:27:55 +02:00
|
|
|
|
|
|
|
UNUSED(ret);
|
2017-07-05 19:01:16 +02:00
|
|
|
}
|
|
|
|
|
2017-08-08 22:24:12 +02:00
|
|
|
#endif /* CONFIG_NET_IPFORWARD */
|