Source code of Windows XP (NT5)
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.

762 lines
21 KiB

  1. #ifndef _Q931PDU_H
  2. #define _Q931PDU_H
  3. #define TPKT_VERSION 3
  4. #define TPKT_HEADER_SIZE 4
  5. #define CALLED_PARTY_PLAN_E164 0x01
  6. #define CALLED_PARTY_EXT_BIT 0x80
  7. #define CALLED_PARTY_TYPE_UNKNOWN 0x00
  8. typedef struct S_BUFFERDESCR
  9. {
  10. DWORD dwLength;
  11. BYTE *pbBuffer;
  12. }BUFFERDESCR, *PBUFFERDESCR;
  13. typedef struct
  14. {
  15. ASN1encoding_t pEncInfo;
  16. ASN1decoding_t pDecInfo;
  17. } ASN1_CODER_INFO;
  18. // Mask to extract a message type from a byte
  19. #define MESSAGETYPEMASK 0x7f
  20. typedef BYTE MESSAGEIDTYPE;
  21. //==========================================================
  22. // BEARER FIELD DEFINITIONS
  23. //==========================================================
  24. // bearer encoding bits...
  25. #define BEAR_EXT_BIT 0x80
  26. // bearer coding standards...
  27. #define BEAR_CCITT 0x00
  28. // ...others not needed...
  29. // bearer information transfer capability...
  30. #define BEAR_UNRESTRICTED_DIGITAL 0x08
  31. // ...others not needed...
  32. // bearer transfer mode...
  33. #define BEAR_CIRCUIT_MODE 0x00
  34. #define BEAR_PACKET_MODE 0x40
  35. // ...others not needed...
  36. // bearer information transfer rate...
  37. #define BEAR_NO_CIRCUIT_RATE 0x00
  38. #define BEAR_MULTIRATE 0x18
  39. // ...others not needed...
  40. // bearer layer1 protocol...
  41. #define BEAR_LAYER1_INDICATOR 0x20
  42. #define BEAR_LAYER1_H221_H242 0x05
  43. // ...others not needed...
  44. // Q931 defined message types
  45. #define ALERTINGMESSAGETYPE 0x01
  46. #define PROCEEDINGMESSAGETYPE 0x02
  47. #define CONNECTMESSAGETYPE 0x07
  48. #define CONNECTACKMESSAGETYPE 0x0F
  49. #define PROGRESSMESSAGETYPE 0x03
  50. #define SETUPMESSAGETYPE 0x05
  51. #define SETUPACKMESSAGETYPE 0x0D
  52. #define RESUMEMESSAGETYPE 0x26
  53. #define RESUMEACKMESSAGETYPE 0x2E
  54. #define RESUMEREJMESSAGETYPE 0x22
  55. #define SUSPENDMESSAGETYPE 0x25
  56. #define SUSPENDACKMESSAGETYPE 0x2D
  57. #define SUSPENDREJMESSAGETYPE 0x21
  58. #define USERINFOMESSAGETYPE 0x20
  59. #define DISCONNECTMESSAGETYPE 0x45
  60. #define RELEASEMESSAGETYPE 0x4D
  61. #define RELEASECOMPLMESSAGETYPE 0x5A
  62. #define RESTARTMESSAGETYPE 0x46
  63. #define RESTARTACKMESSAGETYPE 0x4E
  64. #define SEGMENTMESSAGETYPE 0x60
  65. #define CONGCTRLMESSAGETYPE 0x79
  66. #define INFORMATIONMESSAGETYPE 0x7B
  67. #define NOTIFYMESSAGETYPE 0x6E
  68. #define STATUSMESSAGETYPE 0x7D
  69. #define STATUSENQUIRYMESSAGETYPE 0x75
  70. // Mask to remove only the field identifier from a type 1 single octet field
  71. #define TYPE1IDENTMASK 0xf0
  72. // Mask to remove only the value from a type 1 single octet field
  73. #define TYPE1VALUEMASK 0x0f
  74. // Type of the field identitifiers
  75. typedef BYTE FIELDIDENTTYPE;
  76. // Field identifiers
  77. // Single octet values
  78. #define IDENT_RESERVED 0x80
  79. #define IDENT_SHIFT 0x90
  80. #define IDENT_MORE 0xA0
  81. #define IDENT_SENDINGCOMPLETE 0xA1
  82. #define IDENT_CONGESTION 0xB0
  83. #define IDENT_REPEAT 0xD0
  84. // Variable length octet values
  85. #define IDENT_SEGMENTED 0x00
  86. #define IDENT_BEARERCAP 0x04
  87. #define IDENT_CAUSE 0x08
  88. #define IDENT_CALLIDENT 0x10
  89. #define IDENT_CALLSTATE 0x14
  90. #define IDENT_CHANNELIDENT 0x18
  91. #define IDENT_PROGRESS 0x1E
  92. #define IDENT_NETWORKSPEC 0x20
  93. #define IDENT_NOTIFICATION 0x27
  94. #define IDENT_DISPLAY 0x28
  95. #define IDENT_DATE 0x29
  96. #define IDENT_KEYPAD 0x2C
  97. #define IDENT_SIGNAL 0x34
  98. #define IDENT_INFORMATIONRATE 0x40
  99. #define IDENT_ENDTOENDDELAY 0x42
  100. #define IDENT_TRANSITDELAY 0x43
  101. #define IDENT_PLBINARYPARAMS 0x44
  102. #define IDENT_PLWINDOWSIZE 0x45
  103. #define IDENT_PACKETSIZE 0x46
  104. #define IDENT_CLOSEDUG 0x47
  105. #define IDENT_REVCHARGE 0x4A
  106. #define IDENT_CALLINGNUMBER 0x6C
  107. #define IDENT_CALLINGSUBADDR 0x6D
  108. #define IDENT_CALLEDNUMBER 0x70
  109. #define IDENT_CALLEDSUBADDR 0x71
  110. #define IDENT_REDIRECTING 0x74
  111. #define IDENT_TRANSITNET 0x78
  112. #define IDENT_RESTART 0x79
  113. #define IDENT_LLCOMPATIBILITY 0x7C
  114. #define IDENT_HLCOMPATIBILITY 0x7D
  115. #define IDENT_USERUSER 0x7E
  116. #define USE_ASN1_ENCODING 5
  117. //-------------------------------------------------------------------
  118. // Structures for messages and information elements
  119. //-------------------------------------------------------------------
  120. typedef BYTE PDTYPE;
  121. #define Q931PDVALUE ((PDTYPE)0x08)
  122. typedef WORD CRTYPE;
  123. // Since right now we don't need to separate out the individual
  124. // parts of the fields of the structures these are the base
  125. // types from which the fields are made.
  126. // Single octet element type 1 (contains a value)
  127. struct S_SINGLESTRUCT1
  128. {
  129. BOOLEAN fPresent;
  130. BYTE Value;
  131. };
  132. // Single octet element type 2 (does not contain a value)
  133. struct S_SINGLESTRUCT2
  134. {
  135. BOOLEAN fPresent;
  136. };
  137. // Variable length element
  138. // Maximum element size
  139. #define MAXVARFIELDLEN 131
  140. struct S_VARSTRUCT
  141. {
  142. BOOLEAN fPresent;
  143. BYTE dwLength;
  144. BYTE pbContents[MAXVARFIELDLEN];
  145. };
  146. // Right now all of the fields are bound to the simplest
  147. // structures above. No parsing other than just
  148. // single octet/variable octet is done. When the values
  149. // in some of the subfields are important, change the
  150. // structures here and change the appropriate parsing
  151. // routine to generate the right structure
  152. // The shift element is a single type 1
  153. typedef struct S_SINGLESTRUCT1 SHIFTIE;
  154. typedef struct S_SINGLESTRUCT1 *PSHIFTIE;
  155. // The more data element is a single type 2
  156. typedef struct S_SINGLESTRUCT2 MOREDATAIE;
  157. typedef struct S_SINGLESTRUCT2 *PMOREDATAIE;
  158. // The congestion level element is a single type 1
  159. typedef struct S_SINGLESTRUCT1 CONGESTIONIE;
  160. typedef struct S_SINGLESTRUCT1 *PCONGESTIONIE;
  161. // The bearer capability element is a variable
  162. typedef struct S_VARSTRUCT BEARERCAPIE;
  163. typedef struct S_VARSTRUCT *PBEARERCAPIE;
  164. // The cause element is a variable
  165. typedef struct S_VARSTRUCT CAUSEIE;
  166. typedef struct S_VARSTRUCT *PCAUSEIE;
  167. // The call identity element is a variable
  168. typedef struct S_VARSTRUCT CALLIDENTIE;
  169. typedef struct S_VARSTRUCT *PCALLIDENTIE;
  170. // The call state element is a variable
  171. typedef struct S_VARSTRUCT CALLSTATEIE;
  172. typedef struct S_VARSTRUCT *PCALLSTATEIE;
  173. // The channel identifier element is a variable
  174. typedef struct S_VARSTRUCT CHANIDENTIE;
  175. typedef struct S_VARSTRUCT *PCHANIDENTIE;
  176. // The progress indicator element is a variable
  177. typedef struct S_VARSTRUCT PROGRESSIE;
  178. typedef struct S_VARSTRUCT *PPROGRESSIE;
  179. // The network specific element is a variable
  180. typedef struct S_VARSTRUCT NETWORKIE;
  181. typedef struct S_VARSTRUCT *PNETWORKIE;
  182. // The notification indicator element is a variable
  183. typedef struct S_VARSTRUCT NOTIFICATIONINDIE;
  184. typedef struct S_VARSTRUCT *PNOTIFICATIONINDIE;
  185. // The display element is a variable
  186. typedef struct S_VARSTRUCT DISPLAYIE;
  187. typedef struct S_VARSTRUCT *PDISPLAYIE;
  188. // The date element is a variable
  189. typedef struct S_VARSTRUCT DATEIE;
  190. typedef struct S_VARSTRUCT *PDATEIE;
  191. // The keypad element is a variable
  192. typedef struct S_VARSTRUCT KEYPADIE;
  193. typedef struct S_VARSTRUCT *PKEYPADIE;
  194. // The signal element is a variable
  195. typedef struct S_VARSTRUCT SIGNALIE;
  196. typedef struct S_VARSTRUCT *PSIGNALIE;
  197. // The information rate element is a variable
  198. typedef struct S_VARSTRUCT INFORATEIE;
  199. typedef struct S_VARSTRUCT *PINFORATEIE;
  200. // The transit delay element is a variable
  201. typedef struct S_VARSTRUCT TRANSITDELAYIE;
  202. typedef struct S_VARSTRUCT *PTRANSITDELAYIE;
  203. // The packet layer binary parameters element is a variable
  204. typedef struct S_VARSTRUCT PLBINARYPARAMSIE;
  205. typedef struct S_VARSTRUCT *PPLBINARYPARAMSIE;
  206. // The packet layer window size element is a variable
  207. typedef struct S_VARSTRUCT PLWINDOWSIZEIE;
  208. typedef struct S_VARSTRUCT *PPLWINDOWSIZEIE;
  209. // The packet size element is a variable
  210. typedef struct S_VARSTRUCT PACKETSIZEIE;
  211. typedef struct S_VARSTRUCT *PPACKETSIZEIE;
  212. // The closed user group element is a variable
  213. typedef struct S_VARSTRUCT CLOSEDUGIE;
  214. typedef struct S_VARSTRUCT *PCLOSEDUGIE;
  215. // The calling party number element is a variable
  216. typedef struct S_VARSTRUCT CALLINGNUMBERIE;
  217. typedef struct S_VARSTRUCT *PCALLINGNUMBERIE;
  218. // The calling party subaddress element is a variable
  219. typedef struct S_VARSTRUCT CALLINGSUBADDRIE;
  220. typedef struct S_VARSTRUCT *PCALLINGSUBADDRIE;
  221. // The called party subaddress element is a variable
  222. typedef struct S_VARSTRUCT CALLEDSUBADDRIE;
  223. typedef struct S_VARSTRUCT *PCALLEDSUBADDRIE;
  224. // The redirecting number element is a variable
  225. typedef struct S_VARSTRUCT REDIRECTINGIE;
  226. typedef struct S_VARSTRUCT *PREDIRECTINGIE;
  227. // The restart indicator element is a variable
  228. typedef struct S_VARSTRUCT RESTARTIE;
  229. typedef struct S_VARSTRUCT *PRESTARTIE;
  230. // The low layer compatibility element is a variable
  231. typedef struct S_VARSTRUCT LLCOMPATIBILITYIE;
  232. typedef struct S_VARSTRUCT *PLLCOMPATIBILITYIE;
  233. // The higher layer compatibility element is a variable
  234. typedef struct S_VARSTRUCT HLCOMPATIBILITYIE;
  235. typedef struct S_VARSTRUCT *PHLCOMPATIBILITYIE;
  236. #define Q931_PROTOCOL_X209 ((PDTYPE)0x05)
  237. typedef struct
  238. {
  239. BOOLEAN fPresent;
  240. BYTE ProtocolDiscriminator;
  241. WORD wUserInfoLen;
  242. BYTE pbUserInfo[0x1000]; // 4k bytes should be good for now...
  243. } USERUSERIE, *PUSERUSERIE;
  244. typedef struct S_PARTY_NUMBER
  245. {
  246. BOOLEAN fPresent;
  247. BYTE NumberType;
  248. BYTE NumberingPlan;
  249. BYTE PartyNumberLength;
  250. BYTE PartyNumbers[MAXVARFIELDLEN];
  251. } CALLEDNUMBERIE, *PCALLEDNUMBERIE;
  252. // Q932 defined message types
  253. #define HOLDMESSAGETYPE 0x24
  254. #define HOLDACKMESSAGETYPE 0x28
  255. #define HOLDREJECTMESSAGETYPE 0x30
  256. #define RETRIEVEMESSAGETYPE 0x31
  257. #define RETRIEVEACKMESSAGETYPE 0x33
  258. #define RETRIEVEREJECTMESSAGETYPE 0x37
  259. #define FACILITYMESSAGETYPE 0x62
  260. #define REGISTERMESSAGETYPE 0x64
  261. #define IDENT_FACILITY 0x1C
  262. typedef struct S_VARSTRUCT FACILITYIE;
  263. typedef struct S_VARSTRUCT *PFACILITYIE;
  264. // Generic structure for a Q.931 message
  265. typedef struct S_MESSAGE
  266. {
  267. PDTYPE ProtocolDiscriminator;
  268. CRTYPE wCallRef;
  269. MESSAGEIDTYPE MessageType;
  270. SHIFTIE Shift;
  271. MOREDATAIE MoreData;
  272. BEARERCAPIE BearerCapability;
  273. CAUSEIE Cause;
  274. CALLIDENTIE CallIdentity;
  275. CALLSTATEIE CallState;
  276. CHANIDENTIE ChannelIdentification;
  277. PROGRESSIE ProgressIndicator;
  278. NETWORKIE NetworkFacilities;
  279. NOTIFICATIONINDIE NotificationIndicator;
  280. DISPLAYIE Display;
  281. DATEIE Date;
  282. KEYPADIE Keypad;
  283. SIGNALIE Signal;
  284. INFORATEIE InformationRate;
  285. PLBINARYPARAMSIE PacketLayerBinaryParams;
  286. PLWINDOWSIZEIE PacketLayerWindowSize;
  287. PACKETSIZEIE PacketSize;
  288. CALLINGNUMBERIE CallingPartyNumber;
  289. CALLINGSUBADDRIE CallingPartySubaddress;
  290. CALLEDNUMBERIE CalledPartyNumber;
  291. CALLEDSUBADDRIE CalledPartySubaddress;
  292. REDIRECTINGIE RedirectingNumber;
  293. RESTARTIE RestartIndicator;
  294. LLCOMPATIBILITYIE LowLayerCompatibility;
  295. HLCOMPATIBILITYIE HighLayerCompatibility;
  296. FACILITYIE Facility;
  297. USERUSERIE UserToUser;
  298. }Q931MESSAGE, *PQ931MESSAGE;
  299. typedef struct _BINARY_STRING
  300. {
  301. WORD length;
  302. BYTE *pbBuffer;
  303. } BINARY_STRING;
  304. typedef struct _Q931_SETUP_ASN
  305. {
  306. BOOL fNonStandardDataPresent;
  307. H323NonStandardData nonStandardData;
  308. PH323_ALIASNAMES pCallerAliasList;
  309. PH323_ALIASNAMES pCalleeAliasList;
  310. PH323_ALIASNAMES pExtraAliasList;
  311. PH323_ALIASITEM pExtensionAliasItem;
  312. BOOL fSourceAddrPresent;
  313. BOOL fCallerAddrPresent;
  314. BOOL fCalleeAddrPresent;
  315. BOOL fCalleeDestAddrPresent;
  316. H323_ADDR sourceAddr; // originating addr
  317. H323_ADDR callerAddr; // gk addr
  318. H323_ADDR calleeAddr; // local addr
  319. H323_ADDR calleeDestAddr; // target destination addr
  320. WORD wGoal;
  321. WORD wCallType;
  322. BOOL bCallerIsMC;
  323. GUID ConferenceID;
  324. H323_ENDPOINTTYPE EndpointType;
  325. H323_VENDORINFO VendorInfo;
  326. BOOL fFastStartPresent;
  327. PH323_FASTSTART pFastStart;
  328. BOOL fCallIdentifierPresent;
  329. GUID callIdentifier;
  330. } Q931_SETUP_ASN;
  331. typedef struct _Q931_RELEASE_COMPLETE_ASN
  332. {
  333. BOOL fNonStandardDataPresent;
  334. H323NonStandardData nonStandardData;
  335. BYTE bReason;
  336. BOOL fCallIdentifierPresent;
  337. GUID callIdentifier;
  338. } Q931_RELEASE_COMPLETE_ASN;
  339. typedef struct _Q931_CONNECT_ASN
  340. {
  341. BOOL fNonStandardDataPresent;
  342. H323NonStandardData nonStandardData;
  343. BOOL h245AddrPresent;
  344. H323_ADDR h245Addr;
  345. GUID ConferenceID;
  346. H323_ENDPOINTTYPE EndpointType;
  347. H323_VENDORINFO VendorInfo;
  348. BOOL fFastStartPresent;
  349. PH323_FASTSTART pFastStart;
  350. BOOL fCallIdentifierPresent;
  351. GUID callIdentifier;
  352. } Q931_CONNECT_ASN;
  353. typedef struct _Q931_ALERTING_ASN
  354. {
  355. BOOL fNonStandardDataPresent;
  356. H323NonStandardData nonStandardData;
  357. BOOL fH245AddrPresent;
  358. H323_ADDR h245Addr;
  359. BOOL fFastStartPresent;
  360. PH323_FASTSTART pFastStart;
  361. BOOL fCallIdentifierPresent;
  362. GUID callIdentifier;
  363. } Q931_ALERTING_ASN, Q931_CALL_PROCEEDING_ASN ;
  364. typedef struct _Q931_FACILITY_ASN
  365. {
  366. BOOL fNonStandardDataPresent;
  367. H323NonStandardData nonStandardData;
  368. H323_ADDR AlternativeAddr;
  369. BOOL fAlternativeAddressPresent;
  370. PH323_ALIASNAMES pAlternativeAliasList;
  371. GUID ConferenceID;
  372. BOOL ConferenceIDPresent;
  373. WORD bReason;
  374. BOOL fCallIdentifierPresent;
  375. GUID callIdentifier;
  376. DWORD dwInvokeID;
  377. ASN1octetstring_t pH245PDU;
  378. DWORD dwH450APDUType;
  379. H323_ADDR h245Addr;
  380. BOOL fH245AddrPresent;
  381. } Q931_FACILITY_ASN;
  382. //-------------------------------------------------------------------
  383. // Initialization Routines
  384. //-------------------------------------------------------------------
  385. HRESULT
  386. WritePartyNumber(
  387. PBUFFERDESCR pBuf,
  388. BYTE bIdent,
  389. BYTE NumberType,
  390. BYTE NumberingPlan,
  391. BYTE bPartyNumberLength,
  392. BYTE *pbPartyNumbers,
  393. DWORD * pdwPDULen );
  394. void WriteProtocolDiscriminator(
  395. PBUFFERDESCR pBuf,
  396. DWORD * dwPDULen );
  397. void WriteCallReference(
  398. PBUFFERDESCR pBuf,
  399. WORD *pwCallReference,
  400. DWORD * dwPDULen );
  401. void WriteMessageType(
  402. PBUFFERDESCR pBuf,
  403. MESSAGEIDTYPE *MessageType,
  404. DWORD* pdwPDULen );
  405. void WriteVariableOctet(
  406. PBUFFERDESCR pBuf,
  407. BYTE bIdent,
  408. BYTE dwLength,
  409. BYTE *pbContents,
  410. DWORD* pdwPDULen);
  411. void WriteUserInformation(
  412. PBUFFERDESCR pBuf,
  413. BYTE bIdent,
  414. WORD wUserInfoLen,
  415. BYTE *pbUserInfo,
  416. DWORD* pdwPDULen);
  417. HRESULT
  418. ParseSingleOctetType1(
  419. PBUFFERDESCR pBuf,
  420. BYTE *bIdent,
  421. BYTE *Value);
  422. HRESULT
  423. ParseSingleOctetType2(
  424. PBUFFERDESCR pBuf,
  425. BYTE *bIdent);
  426. HRESULT
  427. ParseVariableOctet(
  428. PBUFFERDESCR pBuf,
  429. BYTE *pdwLength,
  430. BYTE *pbContents);
  431. HRESULT
  432. ParseVariableASN(
  433. PBUFFERDESCR pBuf,
  434. BYTE *bIdent,
  435. BYTE *ProtocolDiscriminator,
  436. WORD *pwUserInfoLen, // Length of the User Information.
  437. BYTE *pbUserInfo); // Bytes of the User Information.
  438. BYTE
  439. GetNextIdent(
  440. void *BufferPtr);
  441. HRESULT
  442. ParseProtocolDiscriminator(
  443. PBUFFERDESCR pBuf,
  444. PDTYPE *Discrim);
  445. HRESULT
  446. ParseCallReference(
  447. PBUFFERDESCR pBuf,
  448. CRTYPE *wCallRef);
  449. HRESULT
  450. ParseMessageType(
  451. PBUFFERDESCR pBuf,
  452. MESSAGEIDTYPE *MessageType);
  453. HRESULT
  454. ParseShift(
  455. PBUFFERDESCR pBuf,
  456. PSHIFTIE FieldStruct);
  457. HRESULT
  458. ParseFacility(
  459. PBUFFERDESCR pBuf,
  460. PFACILITYIE FieldStruct);
  461. HRESULT
  462. ParseBearerCapability(
  463. PBUFFERDESCR pBuf,
  464. PBEARERCAPIE FieldStruct);
  465. HRESULT
  466. ParseCause(
  467. PBUFFERDESCR pBuf,
  468. PCAUSEIE FieldStruct);
  469. HRESULT
  470. ParseCallState(
  471. PBUFFERDESCR pBuf,
  472. PCALLSTATEIE FieldStruct);
  473. HRESULT
  474. ParseChannelIdentification(
  475. PBUFFERDESCR pBuf,
  476. PCHANIDENTIE FieldStruct);
  477. HRESULT
  478. ParseProgress(
  479. PBUFFERDESCR pBuf,
  480. PPROGRESSIE FieldStruct);
  481. HRESULT
  482. ParseNetworkSpec(
  483. PBUFFERDESCR pBuf,
  484. PNETWORKIE FieldStruct);
  485. HRESULT
  486. ParseNotificationIndicator(
  487. PBUFFERDESCR pBuf,
  488. PNOTIFICATIONINDIE FieldStruct);
  489. HRESULT
  490. ParseDisplay(
  491. PBUFFERDESCR pBuf,
  492. PDISPLAYIE FieldStruct);
  493. HRESULT
  494. ParseDate(
  495. PBUFFERDESCR pBuf,
  496. PDATEIE FieldStruct);
  497. HRESULT
  498. ParseKeypad(
  499. PBUFFERDESCR pBuf,
  500. PKEYPADIE FieldStruct);
  501. HRESULT
  502. ParseSignal(
  503. PBUFFERDESCR pBuf,
  504. PSIGNALIE FieldStruct);
  505. HRESULT
  506. ParseInformationRate(
  507. PBUFFERDESCR pBuf,
  508. PINFORATEIE FieldStruct);
  509. HRESULT
  510. ParseCallingPartyNumber(
  511. PBUFFERDESCR pBuf,
  512. PCALLINGNUMBERIE FieldStruct);
  513. HRESULT
  514. ParseCallingPartySubaddress(
  515. PBUFFERDESCR pBuf,
  516. PCALLINGSUBADDRIE FieldStruct);
  517. HRESULT
  518. ParseCalledPartyNumber(
  519. PBUFFERDESCR pBuf,
  520. PCALLEDNUMBERIE FieldStruct);
  521. HRESULT
  522. ParseCalledPartySubaddress(
  523. PBUFFERDESCR pBuf,
  524. PCALLEDSUBADDRIE FieldStruct);
  525. HRESULT
  526. ParseRedirectingNumber(
  527. PBUFFERDESCR pBuf,
  528. PREDIRECTINGIE FieldStruct);
  529. HRESULT
  530. ParseLowLayerCompatibility(
  531. PBUFFERDESCR pBuf,
  532. PLLCOMPATIBILITYIE FieldStruct);
  533. HRESULT
  534. ParseHighLayerCompatibility(
  535. PBUFFERDESCR pBuf,
  536. PHLCOMPATIBILITYIE FieldStruct);
  537. HRESULT
  538. ParseUserToUser(
  539. PBUFFERDESCR pBuf,
  540. PUSERUSERIE FieldStruct);
  541. HRESULT
  542. ParseQ931Field(
  543. PBUFFERDESCR pBuf,
  544. PQ931MESSAGE pMessage);
  545. BOOL ParseVendorInfo(
  546. PH323_VENDORINFO pDestVendorInfo,
  547. VendorIdentifier* pVendor
  548. );
  549. BOOL ParseNonStandardData(
  550. H323NonStandardData * dstNonStdData,
  551. H225NonStandardParameter *srcNonStdData );
  552. BOOL AliasAddrToAliasNames(
  553. PH323_ALIASNAMES *ppTarget,
  554. Setup_UUIE_sourceAddress *pSource );
  555. HRESULT AliasAddrToAliasItem( PH323_ALIASITEM pTarget,
  556. AliasAddress *pSource);
  557. void FreeConnectASN( Q931_CONNECT_ASN *pConnectASN );
  558. void FreeSetupASN( Q931_SETUP_ASN* pSetupASN );
  559. void FreeAlertingASN( Q931_ALERTING_ASN* pAlertingASN );
  560. void FreeFacilityASN( IN Q931_FACILITY_ASN* pFacilityASN );
  561. void FreeProceedingASN( Q931_CALL_PROCEEDING_ASN* pProceedingASN );
  562. void FreeVendorInfo( PH323_VENDORINFO pVendorInfo );
  563. void FreeAliasNames( PH323_ALIASNAMES pSource );
  564. void FreeAliasItems( PH323_ALIASNAMES pSource );
  565. void FreeFastStart( PH323_FASTSTART pFastStart );
  566. PH323_FASTSTART CopyFastStart( PSetup_UUIE_fastStart pSrcFastStart );
  567. int GetTpktLength( char * pTpktHeader );
  568. int Q931_InitModule(void);
  569. void SetupTPKTHeader( BYTE * pbTpktHeader, DWORD dwLength);
  570. BOOL IsInList( LIST_ENTRY * List, LIST_ENTRY * Entry );
  571. DWORD GetLocalIPAddress( DWORD dwRemoteAddr );
  572. BOOL CompareAliasItems( AliasAddress* pAliasAddress,
  573. PH323_ALIASITEM pAliasItem );
  574. BOOL MapAliasItem( IN PH323_ALIASNAMES pCalleeAliasNames,
  575. IN AliasAddress* pAliasAddress );
  576. #define ISVALIDQ931MESSAGE(messageType) ( (messageType==ALERTINGMESSAGETYPE) || \
  577. (messageType==PROCEEDINGMESSAGETYPE) || \
  578. (messageType==CONNECTMESSAGETYPE) || \
  579. (messageType==SETUPMESSAGETYPE) || \
  580. (messageType==RELEASEMESSAGETYPE) || \
  581. (messageType==RELEASECOMPLMESSAGETYPE)||\
  582. (messageType==FACILITYMESSAGETYPE) )
  583. //-------------------------------------------------------------------
  584. // Encoding Routines
  585. //-------------------------------------------------------------------
  586. // extract an IP address and UDP/TCP port from an H.323 TransportAddress PDU
  587. static __inline BOOL GetTransportAddress (
  588. IN const TransportAddress * transport,
  589. OUT SOCKADDR_IN * sockaddr)
  590. {
  591. union {
  592. IN_ADDR in_addr;
  593. UCHAR octet [4];
  594. } ip_addr;
  595. _ASSERTE (transport);
  596. _ASSERTE (sockaddr);
  597. if (transport -> choice != ipAddress_chosen)
  598. {
  599. H323DBG ((DEBUG_LEVEL_WARNING, "GetTransportAddress: not IP address"));
  600. return FALSE;
  601. }
  602. if (transport -> u.ipAddress.ip.length != 4)
  603. {
  604. H323DBG ((DEBUG_LEVEL_WARNING, "GetTransportAddress: bogus IP address byte length"));
  605. return FALSE;
  606. }
  607. #define Bx(x) ip_addr.octet [x] = transport -> u.ipAddress.ip.value [x];
  608. Bx (0)
  609. Bx (1)
  610. Bx (2)
  611. Bx (3)
  612. #undef Bx
  613. sockaddr -> sin_family = AF_INET;
  614. sockaddr -> sin_port = htons (transport -> u.ipAddress.port);
  615. sockaddr -> sin_addr = ip_addr.in_addr;
  616. return TRUE;
  617. }
  618. // construct an H.323 TransportAddress from an IP address and TCP/UDP port
  619. static __inline void SetTransportAddress (
  620. IN const SOCKADDR_IN * addr,
  621. OUT TransportAddress * transport)
  622. {
  623. union {
  624. IN_ADDR in_addr;
  625. UCHAR octet [4];
  626. } ip_addr;
  627. _ASSERTE( addr );
  628. _ASSERTE( transport );
  629. ip_addr.in_addr = addr -> sin_addr;
  630. #define Bx(x) transport -> u.ipAddress.ip.value [x] = ip_addr.octet [x];
  631. Bx (0)
  632. Bx (1)
  633. Bx (2)
  634. Bx (3)
  635. #undef Bx
  636. transport -> choice = ipAddress_chosen;
  637. transport -> u.ipAddress.port = ntohs (addr -> sin_port);
  638. transport -> u.ipAddress.ip.length = 4;
  639. }
  640. #endif //_Q931PDU_H