1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
|
/* BLURB lgpl
Coda File System
Release 5
Copyright (c) 1987-1999 Carnegie Mellon University
Additional copyrights listed below
This code is distributed "AS IS" without warranty of any kind under
the terms of the GNU Library General Public Licence Version 2, as
shown in the file LICENSE. The technical and financial contributors to
Coda are listed in the file CREDITS.
Additional copyrights
#*/
/*
IBM COPYRIGHT NOTICE
Copyright (C) 1986
International Business Machines Corporation
All Rights Reserved
This file contains some code identical to or derived from the 1986
version of the Andrew File System ("AFS"), which is owned by the IBM
Corporation. This code is provided "AS IS" and IBM does not warrant
that it is free of infringement of any intellectual rights of any
third party. IBM disclaims liability of any kind for any damages
whatsoever resulting directly or indirectly from use of this software
or of any derivative work. Carnegie Mellon University has obtained
permission to modify, distribute and sublicense this code, which is
based on Version 2 of AFS and does not contain the features and
enhancements that are part of Version 3 of AFS. Version 3 of AFS is
commercially available and supported by Transarc Corporation,
Pittsburgh, PA.
*/
#include <rpc2/rpc2_addrinfo.h>
/*------------ For tracing calls -------------*/
/* Call codes */
#define TRACEBASE 198732
#define INIT TRACEBASE+1 /* not actually traced */
#define EXPORT TRACEBASE+2
#define DEEXPORT TRACEBASE+3
#define ALLOCBUFFER TRACEBASE+4
#define FREEBUFFER TRACEBASE+5
#define SENDRESPONSE TRACEBASE+6
#define GETREQUEST TRACEBASE+7
#define MAKERPC TRACEBASE+8
#define BIND TRACEBASE+9
#define INITSIDEEFFECT TRACEBASE+10
#define CHECKSIDEEFFECT TRACEBASE+11
#define UNBIND TRACEBASE+12
#define GETPRIVATEPOINTER TRACEBASE+13
#define SETPRIVATEPOINTER TRACEBASE+14
#define GETSEPOINTER TRACEBASE+15
#define SETSEPOINTER TRACEBASE+16
#define GETPEERINFO TRACEBASE+17
#define SLNEWPACKET TRACEBASE+18
#define SENDRELIABLY TRACEBASE+19
#define XMITPACKET TRACEBASE+20
#define CLOCKTICK TRACEBASE+21
#define MULTIRPC TRACEBASE+22
#define MSENDPACKETSRELIABLY TRACEBASE+23
#define CREATEMGRP TRACEBASE+24
#define ADDTOMGRP TRACEBASE+25
#define REMOVEFROMMGRP TRACEBASE+26
#define XLATEMCASTPACKET TRACEBASE+27
struct TraceElem
{
int CallCode;
char ActiveLWP[20];
union
{
struct te_EXPORT
{
RPC2_SubsysIdent Subsys;
}
ExportEntry;
struct te_DEEXPORT
{
RPC2_SubsysIdent Subsys;
}
DeExportEntry;
struct te_ALLOCBUFFER
{
int MinBodySize;
}
AllocBufferEntry;
struct te_FREEBUFFER
{
RPC2_PacketBuffer *BuffPtr;
}
FreeBufferEntry;
struct te_SENDRESPONSE
{
RPC2_Handle ConnHandle;
RPC2_PacketBuffer *Reply_Address;
RPC2_PacketBuffer Reply;
int IsNullSDesc;
SE_Descriptor SDesc;
}
SendResponseEntry;
struct te_GETREQUEST
{
RPC2_RequestFilter Filter;
int IsNullBreathOfLife;
struct timeval BreathOfLife;
long (*GetKeys)();
int EncryptionTypeMask;
}
GetRequestEntry;
struct te_MAKERPC
{
RPC2_Handle ConnHandle;
RPC2_PacketBuffer *Request_Address;
RPC2_PacketBuffer Request;
int IsNullSDesc;
SE_Descriptor SDesc;
int IsNullBreathOfLife;
struct timeval BreathOfLife;
int EnqueueRequest;
}
MakeRPCEntry;
struct te_MULTIRPC
{
RPC2_Handle *ConnHandle;
RPC2_Integer HowMany;
RPC2_PacketBuffer *Request_Address;
RPC2_PacketBuffer Request;
int IsNullSDesc;
SE_Descriptor SDesc;
RPC2_HandleResult_func *HandleResult;
int IsNullBreathOfLife;
struct timeval BreathOfLife;
/* int EnqueueRequest; */
}
MultiRPCEntry;
struct te_BIND
{
int SecurityLevel;
int EncryptionType;
RPC2_HostIdent Host;
RPC2_PortIdent Port;
RPC2_SubsysIdent Subsys;
int SideEffectType;
int IsNullClientIdent;
RPC2_CountedBS ClientIdent;
char ClientIdent_Value[20];
}
BindEntry;
struct te_INITSIDEEFFECT
{
RPC2_Handle ConnHandle;
int IsNullSDesc;
SE_Descriptor SDesc;
}
InitSideEffectEntry;
struct te_CHECKSIDEEFFECT
{
RPC2_Handle ConnHandle;
int IsNullSDesc;
SE_Descriptor SDesc;
int Flags;
}
CheckSideEffectEntry;
struct te_UNBIND
{
RPC2_Handle whichConn;
}
UnbindEntry;
struct te_GETPRIVATEPOINTER
{
RPC2_Handle ConnHandle;
}
GetPrivatePointerEntry;
struct te_SETPRIVATEPOINTER
{
RPC2_Handle ConnHandle;
char *PrivatePtr;
}
SetPrivatePointerEntry;
struct te_GETSEPOINTER
{
RPC2_Handle ConnHandle;
}
GetSEPointerEntry;
struct te_SETSEPOINTER
{
RPC2_Handle ConnHandle;
char *SEPtr;
}SetSEPointerEntry;
struct te_GETPEERINFO
{
RPC2_Handle ConnHandle;
}
GetPeerInfoEntry;
struct te_SLNEWPACKET
{
RPC2_PacketBuffer *pb_Address;
RPC2_PacketBuffer pb;
}
SLNewPacketEntry;
struct te_SENDRELIABLY
{
struct CEntry *Conn;
int Conn_UniqueCID;
RPC2_PacketBuffer *Packet_Address;
RPC2_PacketBuffer Packet;
int IsNullTimeout;
struct timeval Timeout;
}
SendReliablyEntry;
struct te_MSENDPACKETSRELIABLY
{
int HowMany;
struct CEntry *ConnArray0; /* only first element */
int ConnArray0_UniqueCID;
RPC2_PacketBuffer *PacketArray0_Address; /* of first packet */
RPC2_PacketBuffer PacketArray0; /* first packet */
long (*HandleResult)();
int IsNullTimeout;
struct timeval Timeout;
}
MSendPacketsReliablyEntry;
struct te_XMITPACKET
{
RPC2_PacketBuffer *whichPB_Address;
RPC2_PacketBuffer whichPB;
long whichSocket;
struct RPC2_addrinfo whichAddr;
}
XmitPacketEntry;
struct te_CLOCKTICK
{
int TimeNow;
}
ClockTickEntry;
struct te_CREATEMGRP
{
RPC2_Handle MgroupHandle;
RPC2_McastIdent McastHost;
RPC2_PortIdent Port;
RPC2_SubsysIdent Subsys;
}
CreateMgrpEntry;
struct te_ADDTOMGRP
{
RPC2_Handle MgroupHandle;
RPC2_Handle ConnHandle;
}
AddToMgrpEntry;
struct te_REMOVEFROMMGRP
{
struct MEntry me;
struct CEntry ce;
}
RemoveFromMgrpEntry;
struct te_XLATEMCASTPACKET
{
RPC2_PacketBuffer pb;
long pb_address;
struct RPC2_addrinfo ThisAddr;
}
XlateMcastPacketEntry;
}
Args;
};
/* Macros to actually do the tracing follows. Each of these is used only once,
but is placed here to avoid cluttering up all the other files */
#ifndef RPC2DEBUG
#define TR_SENDRESPONSE()
#define TR_GETREQUEST()
#define TR_MAKERPC()
#define TR_BIND()
#define TR_INITSE()
#define TR_CHECKSE()
#define TR_UNBIND()
#define TR_MULTI()
#define TR_MSENDRELIABLY()
#define TR_XMIT()
#define TR_RECV()
#define TR_SENDRELIABLY()
#define TR_CREATEMGRP()
#define TR_ADDTOMGRP()
#define TR_REMOVEFROMMGRP()
#define TR_XLATEMCASTPACKET()
#else
#define TR_SENDRESPONSE() do {\
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_SENDRESPONSE *tea;\
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.SendResponseEntry;\
te->CallCode = SENDRESPONSE;\
strncpy(te->ActiveLWP, LWP_Name(), sizeof(te->ActiveLWP)-1);\
tea->ConnHandle = ConnHandle;\
tea->Reply_Address = Reply;\
tea->Reply = *Reply; /* structure assignment */\
} } while (0)
#define TR_GETREQUEST() do {\
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_GETREQUEST *tea;\
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.GetRequestEntry;\
te->CallCode = GETREQUEST;\
strncpy(te->ActiveLWP, LWP_Name(), sizeof(te->ActiveLWP)-1);\
tea->Filter = *Filter; /* structure assignment */\
if (BreathOfLife == NULL) tea->IsNullBreathOfLife = TRUE;\
else {tea->IsNullBreathOfLife = FALSE; tea->BreathOfLife = *BreathOfLife; /* structure assignment */}\
tea->GetKeys = GetKeys;\
tea->EncryptionTypeMask = EncryptionTypeMask;\
} } while(0)
#define TR_MAKERPC() do {\
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_MAKERPC *tea;\
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.MakeRPCEntry;\
te->CallCode = MAKERPC;\
strncpy(te->ActiveLWP, LWP_Name(), sizeof(te->ActiveLWP)-1);\
tea->ConnHandle = ConnHandle;\
tea->Request_Address = Request;\
tea->Request = *Request; /* structure assignment */\
if (SDesc == NULL) tea->IsNullSDesc = TRUE;\
else {tea->IsNullSDesc = FALSE; tea->SDesc = *SDesc; /* structure assignment */}\
if (BreathOfLife == NULL) tea->IsNullBreathOfLife = TRUE;\
else {tea->IsNullBreathOfLife = FALSE; tea->BreathOfLife = *BreathOfLife; /* structure assignment */}\
tea->EnqueueRequest = EnqueueRequest;\
} } while (0)
#define TR_BIND() do {\
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_BIND *tea;\
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.BindEntry;\
te->CallCode = BIND;\
strncpy(te->ActiveLWP, LWP_Name(), sizeof(te->ActiveLWP)-1);\
tea->SecurityLevel = Bparms->SecurityLevel;\
tea->EncryptionType = Bparms->EncryptionType;\
tea->Host = *Host; /* structure assignment */\
tea->Port = *Port; /* structure assignment */\
tea->Subsys = *Subsys; /* structure assignment */\
tea->SideEffectType = Bparms->SideEffectType;\
if (Bparms->ClientIdent == NULL) tea->IsNullClientIdent = TRUE;\
else\
{\
tea->IsNullClientIdent = FALSE;\
tea->ClientIdent.SeqLen = Bparms->ClientIdent->SeqLen; /* not actual length, could be truncated */\
if (Bparms->ClientIdent->SeqLen < sizeof(tea->ClientIdent_Value))\
memcpy(tea->ClientIdent_Value, Bparms->ClientIdent->SeqBody, Bparms->ClientIdent->SeqLen);\
else memcpy(tea->ClientIdent_Value, Bparms->ClientIdent->SeqBody, sizeof(tea->ClientIdent_Value));\
}\
} } while (0)
#define TR_INITSE()do {\
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_INITSIDEEFFECT *tea;\
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.InitSideEffectEntry;\
te->CallCode = INITSIDEEFFECT;\
strncpy(te->ActiveLWP, LWP_Name(), sizeof(te->ActiveLWP)-1);\
tea->ConnHandle = ConnHandle;\
if (SDesc == NULL) tea->IsNullSDesc = TRUE;\
else {tea->IsNullSDesc = FALSE; tea->SDesc = *SDesc; /* structure assignment */ }\
} } while(0)
#define TR_CHECKSE()do {\
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_CHECKSIDEEFFECT *tea;\
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.CheckSideEffectEntry;\
te->CallCode = CHECKSIDEEFFECT;\
strncpy(te->ActiveLWP, LWP_Name(), sizeof(te->ActiveLWP)-1);\
tea->ConnHandle = ConnHandle;\
if (SDesc == NULL) tea->IsNullSDesc = TRUE;\
else {tea->IsNullSDesc = FALSE; tea->SDesc = *SDesc; /* structure assignment */}\
tea->Flags = Flags;\
} } while (0)
#define TR_UNBIND() do {\
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_UNBIND *tea;\
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.UnbindEntry;\
te->CallCode = UNBIND;\
strncpy(te->ActiveLWP, LWP_Name(), sizeof(te->ActiveLWP)-1);\
tea->whichConn = whichConn;\
}} while (0)
#define TR_MULTI() do {\
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_MULTIRPC *tea;\
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.MultiRPCEntry;\
te->CallCode = MULTIRPC;\
strncpy(te->ActiveLWP, LWP_Name(), sizeof(te->ActiveLWP)-1);\
tea->ConnHandle = ConnHandleList;\
tea->Request_Address = Request;\
tea->Request = *Request; /* structure assignment */\
if (SDescList == NULL) tea->IsNullSDesc = TRUE;\
else {tea->IsNullSDesc = FALSE; tea->SDesc = SDescList[0]; /* structure assignment */}\
tea->HandleResult = ArgInfo->HandleResult;\
if (BreathOfLife == NULL) tea->IsNullBreathOfLife = TRUE;\
else {tea->IsNullBreathOfLife = FALSE; tea->BreathOfLife = *BreathOfLife; /* structure assignment */}\
} } while (0)
#define TR_MSENDRELIABLY() do { \
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_MSENDPACKETSRELIABLY *tea;\
int idx; \
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.MSendPacketsReliablyEntry;\
te->CallCode = MSENDPACKETSRELIABLY;\
strncpy(te->ActiveLWP, LWP_Name(), sizeof(te->ActiveLWP)-1);\
tea->HowMany = HowMany;\
for(idx = 0; !ConnHandleList[idx] && idx < HowMany; idx++)/*loop*/; \
tea->ConnArray0 = mcon[idx].ceaddr;\
tea->ConnArray0_UniqueCID = (mcon[idx].ceaddr)->UniqueCID;\
tea->PacketArray0_Address = mcon[idx].req;\
if (mcon[idx].req) \
tea->PacketArray0 = *(mcon[idx].req); /* structure assignment */\
if (TimeOut == NULL) tea->IsNullTimeout = 1;\
else\
{\
tea->IsNullTimeout = 0;\
tea->Timeout = *TimeOut; /* structure assignment */\
}\
} } while(0)
#define TR_XMIT() do {\
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_XMITPACKET *tea;\
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.XmitPacketEntry;\
te->CallCode = XMITPACKET;\
strncpy(te->ActiveLWP, LWP_Name(), sizeof(te->ActiveLWP)-1);\
tea->whichSocket = whichSocket;\
tea->whichPB_Address = pb;\
tea->whichPB = *pb; /* structure assignment */\
rpc2_htonp(&tea->whichPB);\
tea->whichAddr = *addr; /* BAD! structure assignment */\
tea->whichAddr.ai_next = NULL; \
} }while(0)
#define TR_RECV() do {\
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_SLNEWPACKET *tea;\
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.SLNewPacketEntry;\
te->CallCode = SLNEWPACKET;\
strncpy(te->ActiveLWP, LWP_Name(), sizeof(te->ActiveLWP)-1);\
tea->pb_Address = whichBuff;\
tea->pb = *whichBuff; /* Structure assignment */\
rpc2_ntohp(&tea->pb);\
} } while(0)
#define TR_SENDRELIABLY() do {\
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_SENDRELIABLY *tea;\
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.SendReliablyEntry;\
te->CallCode = SENDRELIABLY;\
strncpy(te->ActiveLWP, LWP_Name(), sizeof(te->ActiveLWP)-1);\
tea->Conn = Conn;\
tea->Conn_UniqueCID = Conn->UniqueCID;\
tea->Packet_Address = Packet;\
tea->Packet = *Packet; /* structure assignment */\
if (TimeOut == NULL) tea->IsNullTimeout = 1;\
else\
{\
tea->IsNullTimeout = 0;\
tea->Timeout = *TimeOut; /* structure assignment */\
}\
} } while(0)
#define TR_CREATEMGRP() do { \
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_CREATEMGRP *tea;\
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.CreateMgrpEntry;\
te->CallCode = CREATEMGRP;\
strncpy(te->ActiveLWP, LWP_Name(), sizeof(te->ActiveLWP)-1);\
tea->MgroupHandle = *MgroupHandle;\
tea->McastHost = *MulticastHost; /* structure assignment */\
tea->Subsys = *Subsys; /* structure assignment */\
} } while(0)
#define TR_ADDTOMGRP() do {\
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_ADDTOMGRP *tea;\
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.AddToMgrpEntry;\
te->CallCode = ADDTOMGRP;\
tea->MgroupHandle = MgroupHandle;\
tea->ConnHandle = ConnHandle;\
} }while(0)
#define TR_REMOVEFROMMGRP() do { \
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_REMOVEFROMMGRP *tea;\
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.RemoveFromMgrpEntry;\
te->CallCode = REMOVEFROMMGRP;\
tea->me = *me; /* structure assignment */\
tea->ce = *ce; /* structure assignment */\
} } while (0)
#define TR_XLATEMCASTPACKET() do {\
if (RPC2_Trace && rpc2_TraceBuffHeader)\
{\
struct TraceElem *te;\
struct te_XLATEMCASTPACKET *tea;\
te = (struct TraceElem *)CBUF_NextSlot(rpc2_TraceBuffHeader);\
tea = &te->Args.XlateMcastPacketEntry;\
te->CallCode = XLATEMCASTPACKET;\
tea->pb = *pb; /* structure assignment */\
tea->pb_address = (long) pb;\
tea->ThisAddr = *pb->Prefix.PeerAddr; /* BAD! structure assignment */\
tea->ThisAddr.ai_next = NULL; \
} } while (0)
#endif
|