2015-03-11 15:33:57 +01:00
|
|
|
/****************************************************************************
|
2021-06-16 10:26:22 +02:00
|
|
|
* apps/netutils/pppd/ppp.c
|
2015-03-11 15:33:57 +01:00
|
|
|
* PPP Processor/Handler
|
2015-03-11 14:53:04 +01:00
|
|
|
*
|
2015-03-11 15:33:57 +01:00
|
|
|
* Version: 0.1 Original Version Jun 3, 2000
|
|
|
|
* Copyright (c) 2003, Mike Johnson, Mycal Labs, www.mycal.net
|
|
|
|
* All rights reserved.
|
2015-03-11 14:53:04 +01:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
2015-03-11 15:33:57 +01:00
|
|
|
*
|
2015-03-11 14:53:04 +01:00
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Mike Johnson/Mycal Labs
|
|
|
|
* www.mycal.net.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote
|
|
|
|
* products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
|
|
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
|
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
|
|
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2015-03-11 15:33:57 +01:00
|
|
|
****************************************************************************/
|
2015-03-11 14:53:04 +01:00
|
|
|
|
2015-03-11 15:33:57 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
2015-03-11 14:53:04 +01:00
|
|
|
|
2015-04-14 14:45:17 +02:00
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2015-03-11 14:53:04 +01:00
|
|
|
#include "ppp_conf.h"
|
|
|
|
#include "ppp_arch.h"
|
|
|
|
#include "ppp.h"
|
|
|
|
#include "ahdlc.h"
|
|
|
|
#include "ipcp.h"
|
|
|
|
#include "lcp.h"
|
2015-04-14 14:45:17 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_NETUTILS_PPPD_PAP
|
2018-11-07 19:43:42 +01:00
|
|
|
# include "pap.h"
|
|
|
|
#endif
|
2015-03-11 14:53:04 +01:00
|
|
|
|
2015-03-11 15:33:57 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-03-11 14:53:04 +01:00
|
|
|
#if PPP_DEBUG
|
|
|
|
# define DEBUG1(x) debug_printf x
|
|
|
|
#else
|
|
|
|
# define DEBUG1(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Set the debug message level */
|
|
|
|
|
2018-11-07 19:43:42 +01:00
|
|
|
#define PACKET_RX_DEBUG PPP_DEBUG
|
2015-03-11 14:53:04 +01:00
|
|
|
|
2015-03-11 15:33:57 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-03-12 01:47:04 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Unknown Protocol Handler, sends reject
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2015-03-11 14:53:04 +01:00
|
|
|
|
2018-11-07 19:43:42 +01:00
|
|
|
static void ppp_reject_protocol(FAR struct ppp_context_s *ctx,
|
|
|
|
uint16_t protocol, FAR uint8_t * buffer,
|
|
|
|
uint16_t count)
|
2015-03-11 14:53:04 +01:00
|
|
|
{
|
2018-11-07 19:43:42 +01:00
|
|
|
uint16_t i;
|
|
|
|
FAR uint8_t *dptr;
|
|
|
|
FAR uint8_t *sptr;
|
|
|
|
FAR LCPPKT *pkt;
|
2015-03-11 14:53:04 +01:00
|
|
|
|
2022-04-04 12:36:53 +02:00
|
|
|
/* First copy rejected packet back, start from end and work forward, +++
|
|
|
|
* Pay attention to buffer management when updated. Assumes fixed PPP
|
|
|
|
* blocks.
|
2018-11-07 19:43:42 +01:00
|
|
|
*/
|
2015-03-11 14:53:04 +01:00
|
|
|
|
|
|
|
DEBUG1(("Rejecting Protocol\n"));
|
|
|
|
if ((count + 6) > PPP_RX_BUFFER_SIZE)
|
|
|
|
{
|
|
|
|
/* This is a fatal error +++ do something about it. */
|
|
|
|
|
|
|
|
DEBUG1(("Cannot Reject Protocol, PKT to big\n"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dptr = buffer + count + 6;
|
|
|
|
sptr = buffer + count;
|
2015-09-02 01:28:17 +02:00
|
|
|
for (i = 0; i < count; ++i)
|
2015-03-11 14:53:04 +01:00
|
|
|
{
|
2018-11-07 19:43:42 +01:00
|
|
|
*--dptr = *--sptr;
|
2015-03-11 14:53:04 +01:00
|
|
|
}
|
|
|
|
|
2022-10-03 19:48:15 +02:00
|
|
|
pkt = (LCPPKT *)buffer;
|
2018-11-07 19:43:42 +01:00
|
|
|
pkt->code = PROT_REJ; /* Write Conf_rej */
|
|
|
|
|
|
|
|
/* pkt->id = tid++; write tid */
|
|
|
|
|
2015-03-11 14:53:04 +01:00
|
|
|
pkt->len = htons(count + 6);
|
2022-10-08 10:31:21 +02:00
|
|
|
*((FAR uint16_t *)(&pkt->data[0])) = htons(protocol);
|
2015-03-11 14:53:04 +01:00
|
|
|
|
2018-11-07 20:43:51 +01:00
|
|
|
ahdlc_tx(ctx, LCP, buffer, 0, (uint16_t)(count + 6), 0);
|
2015-03-11 14:53:04 +01:00
|
|
|
}
|
|
|
|
|
2015-03-12 01:47:04 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: dump_ppp_packet
|
|
|
|
****************************************************************************/
|
2015-03-11 14:53:04 +01:00
|
|
|
|
|
|
|
#if PACKET_RX_DEBUG
|
2018-11-07 19:43:42 +01:00
|
|
|
void dump_ppp_packet(FAR uint8_t * buffer, uint16_t len)
|
2015-03-11 14:53:04 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
DEBUG1(("\n"));
|
2018-11-07 19:43:42 +01:00
|
|
|
for (i = 0; i < len; ++i)
|
2015-03-11 14:53:04 +01:00
|
|
|
{
|
|
|
|
if ((i & 0x1f) == 0x10)
|
|
|
|
{
|
|
|
|
DEBUG1(("\n"));
|
|
|
|
}
|
|
|
|
|
2018-11-07 19:43:42 +01:00
|
|
|
DEBUG1(("0x%02x ", buffer[i]));
|
2015-03-11 14:53:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG1(("\n\n"));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-03-12 01:47:04 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Initialize and start PPP engine. This just sets things up to
|
2015-03-11 14:53:04 +01:00
|
|
|
* starting values. This can stay a private method.
|
2015-03-12 01:47:04 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2015-03-11 14:53:04 +01:00
|
|
|
|
2018-11-07 19:43:42 +01:00
|
|
|
void ppp_init(FAR struct ppp_context_s *ctx)
|
2015-03-11 14:53:04 +01:00
|
|
|
{
|
|
|
|
#ifdef PPP_STATISTICS
|
|
|
|
ctx->ppp_rx_frame_count = 0;
|
2018-11-07 19:43:42 +01:00
|
|
|
ctx->ppp_tx_frame_count = 0;
|
2015-03-11 14:53:04 +01:00
|
|
|
#endif
|
|
|
|
ctx->ppp_flags = 0;
|
2018-11-07 19:43:42 +01:00
|
|
|
ctx->ppp_tx_mru = PPP_RX_BUFFER_SIZE;
|
2015-03-11 14:53:04 +01:00
|
|
|
ctx->ip_no_data_time = 0;
|
|
|
|
ctx->ppp_id = 0;
|
|
|
|
|
2015-04-14 14:45:17 +02:00
|
|
|
#ifdef CONFIG_NETUTILS_PPPD_PAP
|
2015-03-11 14:53:04 +01:00
|
|
|
pap_init(ctx);
|
2018-11-07 19:43:42 +01:00
|
|
|
#endif
|
2015-03-11 14:53:04 +01:00
|
|
|
ipcp_init(ctx);
|
|
|
|
lcp_init(ctx);
|
|
|
|
|
|
|
|
ahdlc_init(ctx);
|
|
|
|
ahdlc_rx_ready(ctx);
|
|
|
|
}
|
|
|
|
|
2015-03-12 01:47:04 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: ppp_connect
|
|
|
|
****************************************************************************/
|
2015-03-11 14:53:04 +01:00
|
|
|
|
2018-11-07 19:43:42 +01:00
|
|
|
void ppp_connect(FAR struct ppp_context_s *ctx)
|
2015-03-11 14:53:04 +01:00
|
|
|
{
|
|
|
|
/* Initialize PPP engine */
|
|
|
|
|
|
|
|
/* init_ppp(); */
|
2015-04-14 14:45:17 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_NETUTILS_PPPD_PAP
|
2015-03-11 14:53:04 +01:00
|
|
|
pap_init(ctx);
|
2018-11-07 19:43:42 +01:00
|
|
|
#endif
|
2015-03-11 14:53:04 +01:00
|
|
|
ipcp_init(ctx);
|
|
|
|
lcp_init(ctx);
|
|
|
|
|
|
|
|
/* Enable PPP */
|
|
|
|
|
|
|
|
ctx->ppp_flags = PPP_RX_READY;
|
|
|
|
}
|
|
|
|
|
2015-03-12 01:47:04 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: ppp_send
|
|
|
|
****************************************************************************/
|
2015-03-11 14:53:04 +01:00
|
|
|
|
2018-11-07 19:43:42 +01:00
|
|
|
void ppp_send(FAR struct ppp_context_s *ctx)
|
2015-03-11 14:53:04 +01:00
|
|
|
{
|
|
|
|
/* If IPCP came up then our link should be up. */
|
|
|
|
|
|
|
|
if ((ctx->ipcp_state & IPCP_TX_UP) && (ctx->ipcp_state & IPCP_RX_UP))
|
|
|
|
{
|
|
|
|
ahdlc_tx(ctx, IPV4, 0, ctx->ip_buf, 0, ctx->ip_len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-12 01:47:04 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: ppp_poll
|
|
|
|
****************************************************************************/
|
2015-03-11 14:53:04 +01:00
|
|
|
|
2018-11-07 19:43:42 +01:00
|
|
|
void ppp_poll(FAR struct ppp_context_s *ctx)
|
2015-03-11 14:53:04 +01:00
|
|
|
{
|
2018-11-07 19:43:42 +01:00
|
|
|
uint8_t c;
|
2015-03-11 14:53:04 +01:00
|
|
|
|
|
|
|
ctx->ip_len = 0;
|
|
|
|
|
|
|
|
++ctx->ip_no_data_time;
|
|
|
|
if (ctx->ip_no_data_time > PPP_IP_TIMEOUT)
|
|
|
|
{
|
|
|
|
ppp_reconnect(ctx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(ctx->ppp_flags & PPP_RX_READY))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (ctx->ip_len == 0 && ppp_arch_getchar(ctx, &c))
|
|
|
|
{
|
|
|
|
ahdlc_rx(ctx, c);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If IPCP came up then our link should be up. */
|
|
|
|
|
|
|
|
if ((ctx->ipcp_state & IPCP_TX_UP) && (ctx->ipcp_state & IPCP_RX_UP))
|
|
|
|
{
|
2018-11-07 19:43:42 +01:00
|
|
|
lcp_echo_request(ctx);
|
2015-03-11 14:53:04 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the lcp task to bring up the LCP layer */
|
|
|
|
|
|
|
|
lcp_task(ctx, ctx->ip_buf);
|
|
|
|
|
|
|
|
/* If LCP is up, neg next layer */
|
|
|
|
|
|
|
|
if ((ctx->lcp_state & LCP_TX_UP) && (ctx->lcp_state & LCP_RX_UP))
|
|
|
|
{
|
|
|
|
/* If LCP wants PAP, try to authenticate, else bring up IPCP */
|
2018-11-07 19:43:42 +01:00
|
|
|
|
2015-04-14 14:45:17 +02:00
|
|
|
#ifdef CONFIG_NETUTILS_PPPD_PAP
|
2015-03-11 14:53:04 +01:00
|
|
|
if ((ctx->lcp_state & LCP_RX_AUTH) && (!(ctx->pap_state & PAP_TX_UP)))
|
|
|
|
{
|
|
|
|
pap_task(ctx, ctx->ip_buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ipcp_task(ctx, ctx->ip_buf);
|
|
|
|
}
|
2015-04-14 14:45:17 +02:00
|
|
|
#else
|
|
|
|
if (ctx->lcp_state & LCP_RX_AUTH)
|
|
|
|
{
|
2022-04-04 12:36:53 +02:00
|
|
|
/* lcp is asking for authentication but we do not support this.
|
|
|
|
* This should be communicated upstream but we do not have an
|
|
|
|
* interface for that right now, so just ignore it; nothing can be
|
|
|
|
* done. This also should not have been hit because upcall does
|
|
|
|
* not know about the pap message type.
|
2015-04-14 14:45:17 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
DEBUG1(("Asking for PAP, but we do not know PAP\n"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ipcp_task(ctx, ctx->ip_buf);
|
|
|
|
}
|
2018-11-07 19:43:42 +01:00
|
|
|
#endif
|
2015-03-11 14:53:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-12 01:47:04 +01:00
|
|
|
/****************************************************************************
|
2015-04-14 14:45:17 +02:00
|
|
|
* Name: ppp_upcall
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This is where valid PPP frames from the ahdlc layer are sent to be
|
|
|
|
* processed and demuxed.
|
2015-03-12 01:47:04 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2015-03-11 14:53:04 +01:00
|
|
|
|
2018-11-07 19:43:42 +01:00
|
|
|
void ppp_upcall(FAR struct ppp_context_s *ctx, uint16_t protocol,
|
|
|
|
FAR uint8_t * buffer, uint16_t len)
|
2015-03-11 14:53:04 +01:00
|
|
|
{
|
2018-11-07 19:43:42 +01:00
|
|
|
#if PPP_DEBUG
|
2015-03-11 14:53:04 +01:00
|
|
|
dump_ppp_packet(buffer, len);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Check to see if we have a packet waiting to be processed */
|
|
|
|
|
|
|
|
if (ctx->ppp_flags & PPP_RX_READY)
|
|
|
|
{
|
|
|
|
/* Demux on protocol field */
|
|
|
|
|
2015-09-02 01:28:17 +02:00
|
|
|
switch (protocol)
|
|
|
|
{
|
2018-11-07 19:43:42 +01:00
|
|
|
case LCP: /* We must support some level of LCP */
|
2015-09-02 01:28:17 +02:00
|
|
|
DEBUG1(("LCP Packet - "));
|
|
|
|
lcp_rx(ctx, buffer, len);
|
|
|
|
DEBUG1(("\n"));
|
|
|
|
break;
|
2015-03-11 14:53:04 +01:00
|
|
|
|
2015-04-14 14:45:17 +02:00
|
|
|
#ifdef CONFIG_NETUTILS_PPPD_PAP
|
2018-11-07 19:43:42 +01:00
|
|
|
case PAP: /* PAP should be compile in optional */
|
2015-09-02 01:28:17 +02:00
|
|
|
DEBUG1(("PAP Packet - "));
|
|
|
|
pap_rx(ctx, buffer, len);
|
|
|
|
DEBUG1(("\n"));
|
|
|
|
break;
|
2018-11-07 19:43:42 +01:00
|
|
|
#endif
|
2015-03-11 14:53:04 +01:00
|
|
|
|
2018-11-07 19:43:42 +01:00
|
|
|
case IPCP: /* IPCP should be compile in optional. */
|
2015-09-02 01:28:17 +02:00
|
|
|
DEBUG1(("IPCP Packet - "));
|
|
|
|
ipcp_rx(ctx, buffer, len);
|
|
|
|
DEBUG1(("\n"));
|
|
|
|
break;
|
|
|
|
|
2018-11-07 19:43:42 +01:00
|
|
|
case IPV4: /* We must support IPV4 */
|
2015-09-02 01:28:17 +02:00
|
|
|
DEBUG1(("IPV4 Packet---\n"));
|
|
|
|
memcpy(ctx->ip_buf, buffer, len);
|
|
|
|
ctx->ip_len = len;
|
|
|
|
ctx->ip_no_data_time = 0;
|
|
|
|
DEBUG1(("\n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-11-07 19:43:42 +01:00
|
|
|
DEBUG1(("Unknown PPP Packet Type 0x%04x - ", protocol));
|
2015-09-02 01:28:17 +02:00
|
|
|
ppp_reject_protocol(ctx, protocol, buffer, len);
|
|
|
|
DEBUG1(("\n"));
|
|
|
|
break;
|
|
|
|
}
|
2015-03-11 14:53:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-12 01:47:04 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* scan_packet(list,buffer,len)
|
2015-03-11 14:53:04 +01:00
|
|
|
*
|
|
|
|
* list = list of supported ID's
|
|
|
|
* *buffer pointer to the first code in the packet
|
|
|
|
* length of the codespace
|
2015-03-12 01:47:04 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2015-10-03 19:03:42 +02:00
|
|
|
|
2018-11-07 19:43:42 +01:00
|
|
|
uint16_t scan_packet(FAR struct ppp_context_s *ctx, uint16_t protocol,
|
2022-04-04 12:36:53 +02:00
|
|
|
FAR const uint8_t * list, FAR uint8_t * buffer,
|
2018-11-07 19:43:42 +01:00
|
|
|
FAR uint8_t * options, uint16_t len)
|
2015-03-11 14:53:04 +01:00
|
|
|
{
|
2022-04-04 12:36:53 +02:00
|
|
|
FAR const uint8_t *tlist;
|
2018-11-07 19:43:42 +01:00
|
|
|
FAR uint8_t *bptr;
|
|
|
|
FAR uint8_t *tptr;
|
|
|
|
uint8_t bad = 0;
|
|
|
|
uint8_t good;
|
|
|
|
uint8_t i;
|
|
|
|
uint8_t j;
|
2015-03-11 14:53:04 +01:00
|
|
|
|
|
|
|
bptr = tptr = options;
|
|
|
|
|
|
|
|
/* Scan through the packet and see if it has any unsupported codes */
|
|
|
|
|
|
|
|
while (bptr < options + len)
|
|
|
|
{
|
2022-04-04 12:36:53 +02:00
|
|
|
/* Get code and see if it matches somewhere in the list, if not we
|
|
|
|
* don't support it.
|
2018-11-07 19:43:42 +01:00
|
|
|
*/
|
2015-03-11 14:53:04 +01:00
|
|
|
|
|
|
|
i = *bptr++;
|
|
|
|
|
|
|
|
/* DEBUG2("%x - ",i); */
|
|
|
|
|
|
|
|
tlist = list;
|
|
|
|
good = 0;
|
|
|
|
while (*tlist)
|
|
|
|
{
|
|
|
|
/* DEBUG2("%x ",*tlist); */
|
2018-11-07 19:43:42 +01:00
|
|
|
|
2015-03-11 14:53:04 +01:00
|
|
|
if (i == *tlist++)
|
|
|
|
{
|
|
|
|
good = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!good)
|
|
|
|
{
|
|
|
|
/* We don't understand it, write it back */
|
|
|
|
|
2018-11-07 19:43:42 +01:00
|
|
|
DEBUG1(("We don't understand option 0x%02x\n", i));
|
2015-03-11 14:53:04 +01:00
|
|
|
bad = 1;
|
|
|
|
*tptr++ = i;
|
|
|
|
j = *tptr++ = *bptr++;
|
2015-09-02 01:28:17 +02:00
|
|
|
for (i = 0; i < j - 2; ++i)
|
2015-03-11 14:53:04 +01:00
|
|
|
{
|
|
|
|
*tptr++ = *bptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Advance over to next option */
|
|
|
|
|
|
|
|
bptr += *bptr - 1;
|
|
|
|
}
|
2018-11-07 19:43:42 +01:00
|
|
|
}
|
2015-03-11 14:53:04 +01:00
|
|
|
|
|
|
|
/* Bad? if we we need to send a config Reject */
|
|
|
|
|
|
|
|
if (bad)
|
|
|
|
{
|
|
|
|
/* Write the config Rej packet we've built above, take on the header */
|
|
|
|
|
|
|
|
bptr = buffer;
|
2018-11-07 19:43:42 +01:00
|
|
|
*bptr++ = CONF_REJ; /* Write Conf_rej */
|
|
|
|
bptr++; /* skip over ID */
|
2015-03-11 14:53:04 +01:00
|
|
|
*bptr++ = 0;
|
|
|
|
*bptr = tptr - buffer;
|
|
|
|
|
|
|
|
/* Length right here? */
|
|
|
|
|
|
|
|
/* Write the reject frame */
|
|
|
|
|
|
|
|
DEBUG1(("Writing Reject frame --\n"));
|
2018-11-07 20:43:51 +01:00
|
|
|
ahdlc_tx(ctx, protocol, buffer, 0, (uint16_t)(tptr - buffer), 0);
|
2021-12-26 23:10:48 +01:00
|
|
|
DEBUG1(("\nEnd writing reject\n"));
|
2015-03-11 14:53:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return bad;
|
|
|
|
}
|