34 : cpType(cpt), rrType(rrt), seqNum(seq) {
44 for (
int i = CPA_START; i < CPA_END; i++) aSet[i] =
false;
46 void CtlPkt::reset(CpTypeIndex cpt, CpRrType rrt, uint64_t seq) {
47 cpType = cpt; rrType = rrt;
seqNum = seq;
58 if (!CpType::validIndex(cpType))
60 if (rrType != REQUEST && rrType != POS_REPLY && rrType != NEG_REPLY)
63 payload[pp++] = htonl(CpType::getCode(cpType));
68 if (rrType == REQUEST) {
71 for (
int i = CPA_START + 1; i < CPA_END; i++) {
72 CpAttrIndex ii = CpAttrIndex(i);
73 if (CpType::isReqAttr(cpType, ii)) {
74 if (isSet(ii)) packAttr(ii);
75 else if (CpType::isReqReqAttr(cpType,ii))
79 }
else if (rrType == POS_REPLY) {
80 for (
int i = CPA_START + 1; i < CPA_END; i++) {
81 CpAttrIndex ii = CpAttrIndex(i);
82 if (CpType::isRepAttr(cpType, ii)) {
83 if (isSet(ii)) packAttr(ii);
90 int j = Util::strnlen(
errMsg,MAX_MSG_LEN);
91 if (j == MAX_MSG_LEN)
errMsg[MAX_MSG_LEN] = 0;
107 if (pleng < 4)
return false;
110 cpType = CpType::getIndexByCode(ntohl(
payload[pp++]));
111 rrType = (CpRrType) ntohl(
payload[pp++]);
115 if (!CpType::validIndex(cpType))
return false;
116 if (rrType != REQUEST && rrType != POS_REPLY && rrType != NEG_REPLY)
119 if (rrType == NEG_REPLY) {
126 while (pp < pleng-1) {
if (unpackAttr() == 0)
return false; }
128 if (rrType == REQUEST) {
130 for (
int i = CPA_START + 1; i < CPA_END; i++) {
131 CpAttrIndex ii = CpAttrIndex(i);
132 if (CpType::isReqReqAttr(cpType, ii) && !isSet(ii)) {
138 for (
int i = CPA_START + 1; i < CPA_END; i++) {
139 CpAttrIndex ii = CpAttrIndex(i);
140 if (CpType::isRepAttr(cpType, ii) && !isSet(ii)) {
156 ss << CpAttr::getName(ii) <<
"=";
158 ss <<
"(missing)"; s = ss.str();
return s;
160 int32_t val = getAttr(ii);
161 if (ii == COMTREE_OWNER || ii == LEAF_ADR ||
162 ii == PEER_ADR || ii == PEER_DEST ||
163 ii == RTR_ADR || ii == CLIENT_ADR ||
164 ii == FIRST_LEAF_ADR || ii == LAST_LEAF_ADR ||
167 }
else if (ii == LOCAL_IP || ii == PEER_IP ||
168 ii == CLIENT_IP || ii == RTR_IP) {
170 }
else if (ii == PEER_TYPE) {
171 ss << Forest::nodeType2string((ntyp_t) val,s);
185 bool reqPkt = (rrType == REQUEST);
187 ss << CpType::getName(cpType);
188 if (reqPkt) ss <<
" (request,";
189 else if (rrType == POS_REPLY) ss <<
" (pos reply,";
190 else ss <<
" (neg reply,";
193 if (rrType == REQUEST) {
194 for (
int i = CPA_START+1; i < CPA_END; i++) {
195 CpAttrIndex ii = CpAttrIndex(i);
196 if (!CpType::isReqAttr(cpType,ii))
continue;
197 if (!CpType::isReqReqAttr(cpType,ii) && !isSet(ii))
201 }
else if (rrType == POS_REPLY) {
202 for (
int i = CPA_START+1; i < CPA_END; i++) {
203 CpAttrIndex ii = CpAttrIndex(i);
204 if (!CpType::isRepAttr(cpType,ii))
continue;
208 ss <<
" errMsg=" <<
errMsg;