2 * Copyright 2003-2004, Waldemar Kornewald <wkornew@gmx.net>
3 * Distributed under the terms of the MIT License.
6 #include "ACFCHandler.h"
8 #include <KPPPConfigurePacket.h>
11 static const uint8 kACFCType
= 0x8;
14 ACFCHandler::ACFCHandler(uint32 options
, KPPPInterface
& interface
)
15 : KPPPOptionHandler("ACFC Handler", kACFCType
, interface
, NULL
),
17 fLocalState(ACFC_DISABLED
),
18 fPeerState(ACFC_DISABLED
)
24 ACFCHandler::AddToRequest(KPPPConfigurePacket
& request
)
26 // is ACFC not requested or was it rejected?
27 if (fLocalState
== ACFC_REJECTED
28 || (Options() & REQUEST_ACFC
) == 0)
32 ppp_configure_item item
;
33 item
.type
= kACFCType
;
35 return request
.AddItem(&item
) ? B_OK
: B_ERROR
;
40 ACFCHandler::ParseNak(const KPPPConfigurePacket
& nak
)
42 // naks do not contain ACFC items
43 if (nak
.ItemWithType(kACFCType
))
51 ACFCHandler::ParseReject(const KPPPConfigurePacket
& reject
)
53 if (reject
.ItemWithType(kACFCType
)) {
54 fLocalState
= ACFC_REJECTED
;
56 if (Options() & FORCE_ACFC_REQUEST
)
65 ACFCHandler::ParseAck(const KPPPConfigurePacket
& ack
)
67 if (ack
.ItemWithType(kACFCType
))
68 fLocalState
= ACFC_ACCEPTED
;
70 fLocalState
= ACFC_DISABLED
;
72 if (Options() & FORCE_ACFC_REQUEST
)
81 ACFCHandler::ParseRequest(const KPPPConfigurePacket
& request
,
82 int32 index
, KPPPConfigurePacket
& nak
, KPPPConfigurePacket
& reject
)
84 if (!request
.ItemWithType(kACFCType
))
87 if ((Options() & ALLOW_ACFC
) == 0) {
88 ppp_configure_item item
;
89 item
.type
= kACFCType
;
91 return reject
.AddItem(&item
) ? B_OK
: B_ERROR
;
99 ACFCHandler::SendingAck(const KPPPConfigurePacket
& ack
)
101 ppp_configure_item
*item
= ack
.ItemWithType(kACFCType
);
103 if (item
&& (Options() & ALLOW_ACFC
) == 0)
107 fPeerState
= ACFC_ACCEPTED
;
109 fPeerState
= ACFC_DISABLED
;
118 fLocalState
= fPeerState
= ACFC_DISABLED
;