btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / add-ons / kernel / network / ppp / modem / ACFCHandler.cpp
blob21cc63cb5887ebaa46fa74da4f1354f829808182
1 /*
2 * Copyright 2003-2004, Waldemar Kornewald <wkornew@gmx.net>
3 * Distributed under the terms of the MIT License.
4 */
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),
16 fOptions(options),
17 fLocalState(ACFC_DISABLED),
18 fPeerState(ACFC_DISABLED)
23 status_t
24 ACFCHandler::AddToRequest(KPPPConfigurePacket& request)
26 // is ACFC not requested or was it rejected?
27 if (fLocalState == ACFC_REJECTED
28 || (Options() & REQUEST_ACFC) == 0)
29 return B_OK;
31 // add ACFC request
32 ppp_configure_item item;
33 item.type = kACFCType;
34 item.length = 2;
35 return request.AddItem(&item) ? B_OK : B_ERROR;
39 status_t
40 ACFCHandler::ParseNak(const KPPPConfigurePacket& nak)
42 // naks do not contain ACFC items
43 if (nak.ItemWithType(kACFCType))
44 return B_ERROR;
46 return B_OK;
50 status_t
51 ACFCHandler::ParseReject(const KPPPConfigurePacket& reject)
53 if (reject.ItemWithType(kACFCType)) {
54 fLocalState = ACFC_REJECTED;
56 if (Options() & FORCE_ACFC_REQUEST)
57 return B_ERROR;
60 return B_OK;
64 status_t
65 ACFCHandler::ParseAck(const KPPPConfigurePacket& ack)
67 if (ack.ItemWithType(kACFCType))
68 fLocalState = ACFC_ACCEPTED;
69 else {
70 fLocalState = ACFC_DISABLED;
72 if (Options() & FORCE_ACFC_REQUEST)
73 return B_ERROR;
76 return B_OK;
80 status_t
81 ACFCHandler::ParseRequest(const KPPPConfigurePacket& request,
82 int32 index, KPPPConfigurePacket& nak, KPPPConfigurePacket& reject)
84 if (!request.ItemWithType(kACFCType))
85 return B_OK;
87 if ((Options() & ALLOW_ACFC) == 0) {
88 ppp_configure_item item;
89 item.type = kACFCType;
90 item.length = 2;
91 return reject.AddItem(&item) ? B_OK : B_ERROR;
94 return B_OK;
98 status_t
99 ACFCHandler::SendingAck(const KPPPConfigurePacket& ack)
101 ppp_configure_item *item = ack.ItemWithType(kACFCType);
103 if (item && (Options() & ALLOW_ACFC) == 0)
104 return B_ERROR;
106 if (item)
107 fPeerState = ACFC_ACCEPTED;
108 else
109 fPeerState = ACFC_DISABLED;
111 return B_OK;
115 void
116 ACFCHandler::Reset()
118 fLocalState = fPeerState = ACFC_DISABLED;