Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
4.3 KiB

  1. /***************************************************************************
  2. Name : SENDFR.C
  3. Comment :
  4. Functions: (see Prototypes just below)
  5. Copyright (c) 1993 Microsoft Corp.
  6. Revision Log
  7. Date Name Description
  8. -------- ----- ---------------------------------------------------------
  9. ***************************************************************************/
  10. #define USE_DEBUG_CONTEXT DEBUG_CONTEXT_T30_MAIN
  11. #include "prep.h"
  12. #include "efaxcb.h"
  13. #include "protocol.h"
  14. #include "glbproto.h"
  15. #include "psslog.h"
  16. #define FILE_ID FILE_ID_SENDFR
  17. #include "pssframe.h"
  18. VOID BCtoNSFCSIDIS(PThrdGlbl pTG, NPRFS npfs, NPBC npbc, NPLLPARAMS npll)
  19. {
  20. // Use bigger buf. Avoid truncating Id before stripping alphas
  21. char szCSI[MAXTOTALIDLEN + 2];
  22. ZeroRFS(pTG, npfs);
  23. strcpy (szCSI, pTG->LocalID);
  24. if(_fstrlen(szCSI))
  25. {
  26. PSSLogEntry(PSS_MSG, 1, "CSI is \"%s\"", szCSI);
  27. CreateIDFrame(pTG, ifrCSI, npfs, szCSI);
  28. }
  29. CreateDISorDTC(pTG, ifrDIS, npfs, &npbc->Fax, npll);
  30. }
  31. void CreateIDFrame(PThrdGlbl pTG, IFR ifr, NPRFS npfs, LPSTR szId)
  32. {
  33. BYTE szTemp[IDFIFSIZE+2];
  34. NPFR npfr;
  35. DEBUG_FUNCTION_NAME(("CreateIDFrame"));
  36. npfr = (NPFR) fsFreePtr(pTG, npfs);
  37. if( fsFreeSpace(pTG, npfs) <= (sizeof(FRBASE)+IDFIFSIZE) ||
  38. npfs->uNumFrames >= MAXFRAMES)
  39. {
  40. return;
  41. }
  42. _fmemcpy(szTemp, szId, IDFIFSIZE);
  43. szTemp[IDFIFSIZE] = 0;
  44. DebugPrintEx(DEBUG_MSG,"Got<%s> Sent<%s>", (LPSTR)szId, (LPSTR)szTemp);
  45. if(_fstrlen(szTemp))
  46. {
  47. CreateStupidReversedFIFs(pTG, npfr->fif, szTemp);
  48. npfr->ifr = ifr;
  49. npfr->cb = IDFIFSIZE;
  50. npfs->rglpfr[npfs->uNumFrames++] = npfr;
  51. npfs->uFreeSpaceOff += IDFIFSIZE+sizeof(FRBASE);
  52. }
  53. else
  54. {
  55. DebugPrintEx(DEBUG_WRN, "ORIGINAL ID is EMPTY. Not sending");
  56. }
  57. }
  58. void CreateDISorDTC
  59. (
  60. PThrdGlbl pTG,
  61. IFR ifr,
  62. NPRFS npfs,
  63. NPBCFAX npbcFax,
  64. NPLLPARAMS npll
  65. )
  66. {
  67. USHORT uLen;
  68. NPFR npfr;
  69. if( fsFreeSpace(pTG, npfs) <= (sizeof(FRBASE)+sizeof(DIS)) ||
  70. npfs->uNumFrames >= MAXFRAMES)
  71. {
  72. return;
  73. }
  74. npfr = (NPFR) fsFreePtr(pTG, npfs);
  75. uLen = SetupDISorDCSorDTC(pTG, (NPDIS)npfr->fif, npbcFax, npll);
  76. npfr->ifr = ifr;
  77. npfr->cb = (BYTE) uLen;
  78. npfs->rglpfr[npfs->uNumFrames++] = npfr;
  79. npfs->uFreeSpaceOff += uLen+sizeof(FRBASE);
  80. }
  81. VOID CreateNSSTSIDCS(PThrdGlbl pTG, NPPROT npProt, NPRFS npfs)
  82. {
  83. // Use bigger buf. Avoid truncating Id before stripping alphas
  84. char szTSI[MAXTOTALIDLEN + 2];
  85. ZeroRFS(pTG, npfs);
  86. strcpy (szTSI, pTG->LocalID);
  87. if(_fstrlen(szTSI))
  88. {
  89. PSSLogEntry(PSS_MSG, 1, "TSI is \"%s\"", szTSI);
  90. CreateIDFrame(pTG, ifrTSI, npfs, szTSI);
  91. }
  92. CreateDCS(pTG, npfs, &(npProt->SendParams.Fax), &npProt->llNegot);
  93. }
  94. void CreateDCS(PThrdGlbl pTG, NPRFS npfs, NPBCFAX npbcFax, NPLLPARAMS npll)
  95. {
  96. USHORT uLen;
  97. NPFR npfr;
  98. if( fsFreeSpace(pTG, npfs) <= (sizeof(FRBASE)+sizeof(DIS)) ||
  99. npfs->uNumFrames >= MAXFRAMES)
  100. {
  101. return;
  102. }
  103. npfr = (NPFR) fsFreePtr(pTG, npfs);
  104. npbcFax->fPublicPoll = 0;
  105. // the G3Poll bit *has* to be 0 in DCS
  106. // else the OMNIFAX G77 and GT croak
  107. // the PWD/SEP/SUB bits *have* to be 0 in DCS
  108. // Baud rate, ECM and ECM frame size according to lowlevel negotiation
  109. // everything else according to high level negotiation
  110. uLen = SetupDISorDCSorDTC( pTG,
  111. (NPDIS)npfr->fif,
  112. npbcFax,
  113. npll);
  114. // If DCS is longer than the recvd DIS truncate the DCS to the same
  115. // length as the DIS. (It should never be more than 1byte longer --
  116. // because of the extra 0).
  117. if(pTG->ProtInst.uRemoteDISlen && (pTG->ProtInst.uRemoteDISlen < uLen))
  118. uLen = pTG->ProtInst.uRemoteDISlen;
  119. npfr->ifr = ifrDCS;
  120. npfr->cb = (BYTE) uLen;
  121. npfs->rglpfr[npfs->uNumFrames++] = npfr;
  122. npfs->uFreeSpaceOff += uLen+sizeof(FRBASE);
  123. PSSLogEntry(PSS_MSG, 1, "DCS Composed as follows:");
  124. LogClass1DCSDetails(pTG, (NPDIS)npfr->fif);
  125. }