2017-07-06 01:01:16 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* net/devif/devif_forward.c
|
|
|
|
*
|
2024-09-11 20:39:39 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2021-02-19 19:45:37 +08: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-06 01:01:16 +08:00
|
|
|
*
|
2021-02-19 19:45:37 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2017-07-06 01:01:16 +08:00
|
|
|
*
|
2021-02-19 19:45:37 +08: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-06 01:01:16 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
2017-07-08 11:32:10 +08:00
|
|
|
#include <nuttx/mm/iob.h>
|
2017-07-06 01:01:16 +08:00
|
|
|
#include <nuttx/net/netdev.h>
|
|
|
|
|
2017-07-08 08:45:58 +08:00
|
|
|
#include "ipforward/ipforward.h"
|
2017-07-06 01:01:16 +08:00
|
|
|
#include "devif/devif.h"
|
|
|
|
|
2017-08-09 04:24:12 +08:00
|
|
|
#ifdef CONFIG_NET_IPFORWARD
|
2017-07-06 01:01:16 +08: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)
|
|
|
|
{
|
2017-07-07 06:19:10 +08:00
|
|
|
DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL);
|
2017-07-06 01:01:16 +08:00
|
|
|
|
2022-12-06 14:34:41 +08:00
|
|
|
/* Move the IOB chain that contains the L3 header and any data payload */
|
2017-07-06 01:01:16 +08:00
|
|
|
|
2022-12-06 14:34:41 +08:00
|
|
|
netdev_iob_replace(fwd->f_dev, fwd->f_iob);
|
2017-07-06 01:01:16 +08:00
|
|
|
|
2017-07-08 10:19:26 +08:00
|
|
|
fwd->f_dev->d_sndlen = 0;
|
2022-12-06 14:34:41 +08:00
|
|
|
fwd->f_iob = NULL;
|
2017-07-06 01:01:16 +08:00
|
|
|
}
|
|
|
|
|
2017-08-09 04:24:12 +08:00
|
|
|
#endif /* CONFIG_NET_IPFORWARD */
|