1 /*
2 * fca-rreq.cc --
3 *
4 * repair request and reply classes
5 *
6 * Copyright (c) 1997-2002 The Regents of the University of California.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * A. Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 * B. Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 * C. Neither the names of the copyright holders nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
22 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 /*
35 * fca_rreq.cc -- Helen J. Wang
36 */
37
38 #include "fca-rreq.h"
39
40 static class FCARepairRequestClass : public TclClass {
41 public:
42 FCARepairRequestClass() : TclClass ("FCARepairRequest") {
43 Debug (dbgFCA, ("created FCARepairRequest class: %s \n", classname_));
44 }
45 TclObject* create (int /*argc*/, const char*const* /*argv*/) {
46 return (new FCARepairRequest);
47 }
48 } fcaRequest;
49
50
51 // cancel after asking for 10 times
52 // static const cNumMaxRreq = 20;
53 int FCARepairRequest::fill_ADU(u_char* pb, int len)
54 {
55 if (this->Packetize(pb, len)==FALSE) {
56 Debug (dbgFCA, ("unable to packetize repair request"));
57 return 0;
58 }
59 static char buffer[10000];
60 *buffer = '\0';
61 for (int i=0; i<len; i++) {
62 sprintf (buffer, "%s%02x ", buffer, pb[i]);
63 }
64 // Debug (dbgFCA, ("%s", buffer));
65 return len;
66 }
67
68
69 int FCARepairRequest::command(int /*argc*/, const char*const* argv) {
70 if (!strcmp(argv[1], "cancel")) {
71 this->cancel();
72 Tcl::instance().resultf("");
73 }
74
75 if (!strcmp(argv[1], "backoff")) {
76 this->Backoff();
77 Tcl::instance().resultf("");
78 }
79 return TCL_OK;
80 }
81
82
83
84 /***************************************************************/
85
86
87 static class FCARepairReplyClass : public TclClass {
88 public:
89 FCARepairReplyClass () : TclClass ("FCARepairReply") {
90 Debug (dbgFCA, ("created FCARepairReply class: %s \n", classname_));
91 }
92 TclObject* create (int /*argc*/, const char*const* /*argv*/) {
93 return (new FCARepairReply);
94 }
95 } fcaReply;
96
97
98 int FCARepairReply::fill_ADU(Byte* pb, int len)
99 {
100 if (this->Packetize(pb, len)==FALSE) {
101 Debug (dbgFCA, ("unable to packetize repair reply"));
102 return 0;
103 }
104 Debug(dbgFCA, ("FCARepairReply::fill_ADU contains %d bytes:", len));
105 static char buffer[10000];
106 *buffer = '\0';
107 for (int i=0; i<len; i++) {
108 sprintf (buffer, "%s%02x ", buffer, pb[i]);
109 }
110 // Debug (dbgFCA, ("%s", buffer));
111 return len;
112 }
113
114
115 int FCARepairReply::command(int /*argc*/, const char*const* argv) {
116 if (!strcmp(argv[1], "cancel")) {
117 this->cancel();
118 Tcl::instance().resultf("");
119 }
120
121 if (!strcmp(argv[1], "backoff")) {
122 this->Backoff();
123 Tcl::instance().resultf("");
124 }
125 return TCL_OK;
126 }
127
128
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.