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.

762 lines
22 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. #define MAX_USER_TO_USER_INFO_LEN 0x1000
  238. typedef struct
  239. {
  240. BOOLEAN fPresent;
  241. BYTE ProtocolDiscriminator;
  242. WORD wUserInfoLen;
  243. BYTE pbUserInfo[MAX_USER_TO_USER_INFO_LEN]; // 4k bytes should be good for now...
  244. } USERUSERIE, *PUSERUSERIE;
  245. typedef struct S_PARTY_NUMBER
  246. {
  247. BOOLEAN fPresent;
  248. BYTE NumberType;
  249. BYTE NumberingPlan;
  250. BYTE PartyNumberLength;
  251. BYTE PartyNumbers[MAXVARFIELDLEN];
  252. } CALLEDNUMBERIE, *PCALLEDNUMBERIE;
  253. // Q932 defined message types
  254. #define HOLDMESSAGETYPE 0x24
  255. #define HOLDACKMESSAGETYPE 0x28
  256. #define HOLDREJECTMESSAGETYPE 0x30
  257. #define RETRIEVEMESSAGETYPE 0x31
  258. #define RETRIEVEACKMESSAGETYPE 0x33
  259. #define RETRIEVEREJECTMESSAGETYPE 0x37
  260. #define FACILITYMESSAGETYPE 0x62
  261. #define REGISTERMESSAGETYPE 0x64
  262. #define IDENT_FACILITY 0x1C
  263. typedef struct S_VARSTRUCT FACILITYIE;
  264. typedef struct S_VARSTRUCT *PFACILITYIE;
  265. // Generic structure for a Q.931 message
  266. typedef struct S_MESSAGE
  267. {
  268. PDTYPE ProtocolDiscriminator;
  269. CRTYPE wCallRef;
  270. MESSAGEIDTYPE MessageType;
  271. SHIFTIE Shift;
  272. MOREDATAIE MoreData;
  273. BEARERCAPIE BearerCapability;
  274. CAUSEIE Cause;
  275. CALLIDENTIE CallIdentity;
  276. CALLSTATEIE CallState;
  277. CHANIDENTIE ChannelIdentification;
  278. PROGRESSIE ProgressIndicator;
  279. NETWORKIE NetworkFacilities;
  280. NOTIFICATIONINDIE NotificationIndicator;
  281. DISPLAYIE Display;
  282. DATEIE Date;
  283. KEYPADIE Keypad;
  284. SIGNALIE Signal;
  285. INFORATEIE InformationRate;
  286. PLBINARYPARAMSIE PacketLayerBinaryParams;
  287. PLWINDOWSIZEIE PacketLayerWindowSize;
  288. PACKETSIZEIE PacketSize;
  289. CALLINGNUMBERIE CallingPartyNumber;
  290. CALLINGSUBADDRIE CallingPartySubaddress;
  291. CALLEDNUMBERIE CalledPartyNumber;
  292. CALLEDSUBADDRIE CalledPartySubaddress;
  293. REDIRECTINGIE RedirectingNumber;
  294. RESTARTIE RestartIndicator;
  295. LLCOMPATIBILITYIE LowLayerCompatibility;
  296. HLCOMPATIBILITYIE HighLayerCompatibility;
  297. FACILITYIE Facility;
  298. USERUSERIE UserToUser;
  299. }Q931MESSAGE, *PQ931MESSAGE;
  300. typedef struct _BINARY_STRING
  301. {
  302. WORD length;
  303. BYTE *pbBuffer;
  304. } BINARY_STRING;
  305. typedef struct _Q931_SETUP_ASN
  306. {
  307. BOOL fNonStandardDataPresent;
  308. H323NonStandardData nonStandardData;
  309. PH323_ALIASNAMES pCallerAliasList;
  310. PH323_ALIASNAMES pCalleeAliasList;
  311. PH323_ALIASNAMES pExtraAliasList;
  312. PH323_ALIASITEM pExtensionAliasItem;
  313. BOOL fSourceAddrPresent;
  314. BOOL fCallerAddrPresent;
  315. BOOL fCalleeAddrPresent;
  316. BOOL fCalleeDestAddrPresent;
  317. H323_ADDR sourceAddr; // originating addr
  318. H323_ADDR callerAddr; // gk addr
  319. H323_ADDR calleeAddr; // local addr
  320. H323_ADDR calleeDestAddr; // target destination addr
  321. WORD wGoal;
  322. WORD wCallType;
  323. BOOL bCallerIsMC;
  324. GUID ConferenceID;
  325. H323_ENDPOINTTYPE EndpointType;
  326. H323_VENDORINFO VendorInfo;
  327. BOOL fFastStartPresent;
  328. PH323_FASTSTART pFastStart;
  329. BOOL fCallIdentifierPresent;
  330. GUID callIdentifier;
  331. } Q931_SETUP_ASN;
  332. typedef struct _Q931_RELEASE_COMPLETE_ASN
  333. {
  334. BOOL fNonStandardDataPresent;
  335. H323NonStandardData nonStandardData;
  336. BYTE bReason;
  337. BOOL fCallIdentifierPresent;
  338. GUID callIdentifier;
  339. } Q931_RELEASE_COMPLETE_ASN;
  340. typedef struct _Q931_CONNECT_ASN
  341. {
  342. BOOL fNonStandardDataPresent;
  343. H323NonStandardData nonStandardData;
  344. BOOL h245AddrPresent;
  345. H323_ADDR h245Addr;
  346. GUID ConferenceID;
  347. H323_ENDPOINTTYPE EndpointType;
  348. H323_VENDORINFO VendorInfo;
  349. BOOL fFastStartPresent;
  350. PH323_FASTSTART pFastStart;
  351. BOOL fCallIdentifierPresent;
  352. GUID callIdentifier;
  353. } Q931_CONNECT_ASN;
  354. typedef struct _Q931_ALERTING_ASN
  355. {
  356. BOOL fNonStandardDataPresent;
  357. H323NonStandardData nonStandardData;
  358. BOOL fH245AddrPresent;
  359. H323_ADDR h245Addr;
  360. BOOL fFastStartPresent;
  361. PH323_FASTSTART pFastStart;
  362. BOOL fCallIdentifierPresent;
  363. GUID callIdentifier;
  364. } Q931_ALERTING_ASN, Q931_CALL_PROCEEDING_ASN ;
  365. typedef struct _Q931_FACILITY_ASN
  366. {
  367. BOOL fNonStandardDataPresent;
  368. H323NonStandardData nonStandardData;
  369. H323_ADDR AlternativeAddr;
  370. BOOL fAlternativeAddressPresent;
  371. PH323_ALIASNAMES pAlternativeAliasList;
  372. GUID ConferenceID;
  373. BOOL ConferenceIDPresent;
  374. WORD bReason;
  375. BOOL fCallIdentifierPresent;
  376. GUID callIdentifier;
  377. DWORD dwInvokeID;
  378. ASN1octetstring_t pH245PDU;
  379. DWORD dwH450APDUType;
  380. H323_ADDR h245Addr;
  381. BOOL fH245AddrPresent;
  382. } Q931_FACILITY_ASN;
  383. //-------------------------------------------------------------------
  384. // Initialization Routines
  385. //-------------------------------------------------------------------
  386. HRESULT
  387. WritePartyNumber(
  388. PBUFFERDESCR pBuf,
  389. BYTE bIdent,
  390. BYTE NumberType,
  391. BYTE NumberingPlan,
  392. BYTE bPartyNumberLength,
  393. BYTE *pbPartyNumbers,
  394. DWORD * pdwPDULen );
  395. void WriteProtocolDiscriminator(
  396. PBUFFERDESCR pBuf,
  397. DWORD * dwPDULen );
  398. void WriteCallReference(
  399. PBUFFERDESCR pBuf,
  400. WORD *pwCallReference,
  401. DWORD * dwPDULen );
  402. void WriteMessageType(
  403. PBUFFERDESCR pBuf,
  404. MESSAGEIDTYPE *MessageType,
  405. DWORD* pdwPDULen );
  406. void WriteVariableOctet(
  407. PBUFFERDESCR pBuf,
  408. BYTE bIdent,
  409. BYTE dwLength,
  410. BYTE *pbContents,
  411. DWORD* pdwPDULen);
  412. void WriteUserInformation(
  413. PBUFFERDESCR pBuf,
  414. BYTE bIdent,
  415. WORD wUserInfoLen,
  416. BYTE *pbUserInfo,
  417. DWORD* pdwPDULen);
  418. HRESULT
  419. ParseSingleOctetType1(
  420. PBUFFERDESCR pBuf,
  421. BYTE *bIdent,
  422. BYTE *Value);
  423. HRESULT
  424. ParseSingleOctetType2(
  425. PBUFFERDESCR pBuf,
  426. BYTE *bIdent);
  427. HRESULT
  428. ParseVariableOctet(
  429. PBUFFERDESCR pBuf,
  430. BYTE *pdwLength,
  431. BYTE *pbContents);
  432. HRESULT
  433. ParseVariableASN(
  434. PBUFFERDESCR pBuf,
  435. BYTE *bIdent,
  436. BYTE *ProtocolDiscriminator,
  437. WORD *pwUserInfoLen, // Length of the User Information.
  438. BYTE *pbUserInfo); // Bytes of the User Information.
  439. BYTE
  440. GetNextIdent(
  441. void *BufferPtr);
  442. HRESULT
  443. ParseProtocolDiscriminator(
  444. PBUFFERDESCR pBuf,
  445. PDTYPE *Discrim);
  446. HRESULT
  447. ParseCallReference(
  448. PBUFFERDESCR pBuf,
  449. CRTYPE *wCallRef);
  450. HRESULT
  451. ParseMessageType(
  452. PBUFFERDESCR pBuf,
  453. MESSAGEIDTYPE *MessageType);
  454. HRESULT
  455. ParseShift(
  456. PBUFFERDESCR pBuf,
  457. PSHIFTIE FieldStruct);
  458. HRESULT
  459. ParseFacility(
  460. PBUFFERDESCR pBuf,
  461. PFACILITYIE FieldStruct);
  462. HRESULT
  463. ParseBearerCapability(
  464. PBUFFERDESCR pBuf,
  465. PBEARERCAPIE FieldStruct);
  466. HRESULT
  467. ParseCause(
  468. PBUFFERDESCR pBuf,
  469. PCAUSEIE FieldStruct);
  470. HRESULT
  471. ParseCallState(
  472. PBUFFERDESCR pBuf,
  473. PCALLSTATEIE FieldStruct);
  474. HRESULT
  475. ParseChannelIdentification(
  476. PBUFFERDESCR pBuf,
  477. PCHANIDENTIE FieldStruct);
  478. HRESULT
  479. ParseProgress(
  480. PBUFFERDESCR pBuf,
  481. PPROGRESSIE FieldStruct);
  482. HRESULT
  483. ParseNetworkSpec(
  484. PBUFFERDESCR pBuf,
  485. PNETWORKIE FieldStruct);
  486. HRESULT
  487. ParseNotificationIndicator(
  488. PBUFFERDESCR pBuf,
  489. PNOTIFICATIONINDIE FieldStruct);
  490. HRESULT
  491. ParseDisplay(
  492. PBUFFERDESCR pBuf,
  493. PDISPLAYIE FieldStruct);
  494. HRESULT
  495. ParseDate(
  496. PBUFFERDESCR pBuf,
  497. PDATEIE FieldStruct);
  498. HRESULT
  499. ParseKeypad(
  500. PBUFFERDESCR pBuf,
  501. PKEYPADIE FieldStruct);
  502. HRESULT
  503. ParseSignal(
  504. PBUFFERDESCR pBuf,
  505. PSIGNALIE FieldStruct);
  506. HRESULT
  507. ParseInformationRate(
  508. PBUFFERDESCR pBuf,
  509. PINFORATEIE FieldStruct);
  510. HRESULT
  511. ParseCallingPartyNumber(
  512. PBUFFERDESCR pBuf,
  513. PCALLINGNUMBERIE FieldStruct);
  514. HRESULT
  515. ParseCallingPartySubaddress(
  516. PBUFFERDESCR pBuf,
  517. PCALLINGSUBADDRIE FieldStruct);
  518. HRESULT
  519. ParseCalledPartyNumber(
  520. PBUFFERDESCR pBuf,
  521. PCALLEDNUMBERIE FieldStruct);
  522. HRESULT
  523. ParseCalledPartySubaddress(
  524. PBUFFERDESCR pBuf,
  525. PCALLEDSUBADDRIE FieldStruct);
  526. HRESULT
  527. ParseRedirectingNumber(
  528. PBUFFERDESCR pBuf,
  529. PREDIRECTINGIE FieldStruct);
  530. HRESULT
  531. ParseLowLayerCompatibility(
  532. PBUFFERDESCR pBuf,
  533. PLLCOMPATIBILITYIE FieldStruct);
  534. HRESULT
  535. ParseHighLayerCompatibility(
  536. PBUFFERDESCR pBuf,
  537. PHLCOMPATIBILITYIE FieldStruct);
  538. HRESULT
  539. ParseUserToUser(
  540. PBUFFERDESCR pBuf,
  541. PUSERUSERIE FieldStruct);
  542. HRESULT
  543. ParseQ931Field(
  544. PBUFFERDESCR pBuf,
  545. PQ931MESSAGE pMessage);
  546. BOOL ParseVendorInfo(
  547. PH323_VENDORINFO pDestVendorInfo,
  548. VendorIdentifier* pVendor
  549. );
  550. BOOL ParseNonStandardData(
  551. H323NonStandardData * dstNonStdData,
  552. H225NonStandardParameter *srcNonStdData );
  553. BOOL AliasAddrToAliasNames(
  554. PH323_ALIASNAMES *ppTarget,
  555. Setup_UUIE_sourceAddress *pSource );
  556. HRESULT AliasAddrToAliasItem( PH323_ALIASITEM pTarget,
  557. AliasAddress *pSource);
  558. void FreeConnectASN( Q931_CONNECT_ASN *pConnectASN );
  559. void FreeSetupASN( Q931_SETUP_ASN* pSetupASN );
  560. void FreeAlertingASN( Q931_ALERTING_ASN* pAlertingASN );
  561. void FreeFacilityASN( IN Q931_FACILITY_ASN* pFacilityASN );
  562. void FreeProceedingASN( Q931_CALL_PROCEEDING_ASN* pProceedingASN );
  563. void FreeVendorInfo( PH323_VENDORINFO pVendorInfo );
  564. void FreeAliasNames( PH323_ALIASNAMES pSource );
  565. void FreeAliasItems( PH323_ALIASNAMES pSource );
  566. void FreeFastStart( PH323_FASTSTART pFastStart );
  567. PH323_FASTSTART CopyFastStart( PSetup_UUIE_fastStart pSrcFastStart );
  568. int GetTpktLength( char * pTpktHeader );
  569. int Q931_InitModule(void);
  570. void SetupTPKTHeader( BYTE * pbTpktHeader, DWORD dwLength);
  571. BOOL IsInList( LIST_ENTRY * List, LIST_ENTRY * Entry );
  572. DWORD GetLocalIPAddress( DWORD dwRemoteAddr );
  573. BOOL CompareAliasItems( AliasAddress* pAliasAddress,
  574. PH323_ALIASITEM pAliasItem );
  575. BOOL MapAliasItem( IN PH323_ALIASNAMES pCalleeAliasNames,
  576. IN AliasAddress* pAliasAddress );
  577. #define ISVALIDQ931MESSAGE(messageType) ( (messageType==ALERTINGMESSAGETYPE) || \
  578. (messageType==PROCEEDINGMESSAGETYPE) || \
  579. (messageType==CONNECTMESSAGETYPE) || \
  580. (messageType==SETUPMESSAGETYPE) || \
  581. (messageType==RELEASEMESSAGETYPE) || \
  582. (messageType==RELEASECOMPLMESSAGETYPE)||\
  583. (messageType==FACILITYMESSAGETYPE) )
  584. //-------------------------------------------------------------------
  585. // Encoding Routines
  586. //-------------------------------------------------------------------
  587. // extract an IP address and UDP/TCP port from an H.323 TransportAddress PDU
  588. static __inline BOOL GetTransportAddress (
  589. IN const TransportAddress * transport,
  590. OUT SOCKADDR_IN * sockaddr)
  591. {
  592. union {
  593. IN_ADDR in_addr;
  594. UCHAR octet [4];
  595. } ip_addr;
  596. _ASSERTE (transport);
  597. _ASSERTE (sockaddr);
  598. if (transport -> choice != ipAddress_chosen)
  599. {
  600. H323DBG ((DEBUG_LEVEL_WARNING, "GetTransportAddress: not IP address"));
  601. return FALSE;
  602. }
  603. if (transport -> u.ipAddress.ip.length != 4)
  604. {
  605. H323DBG ((DEBUG_LEVEL_WARNING, "GetTransportAddress: bogus IP address byte length"));
  606. return FALSE;
  607. }
  608. #define Bx(x) ip_addr.octet [x] = transport -> u.ipAddress.ip.value [x];
  609. Bx (0)
  610. Bx (1)
  611. Bx (2)
  612. Bx (3)
  613. #undef Bx
  614. sockaddr -> sin_family = AF_INET;
  615. sockaddr -> sin_port = htons (transport -> u.ipAddress.port);
  616. sockaddr -> sin_addr = ip_addr.in_addr;
  617. return TRUE;
  618. }
  619. // construct an H.323 TransportAddress from an IP address and TCP/UDP port
  620. static __inline void SetTransportAddress (
  621. IN const SOCKADDR_IN * addr,
  622. OUT TransportAddress * transport)
  623. {
  624. union {
  625. IN_ADDR in_addr;
  626. UCHAR octet [4];
  627. } ip_addr;
  628. _ASSERTE( addr );
  629. _ASSERTE( transport );
  630. ip_addr.in_addr = addr -> sin_addr;
  631. #define Bx(x) transport -> u.ipAddress.ip.value [x] = ip_addr.octet [x];
  632. Bx (0)
  633. Bx (1)
  634. Bx (2)
  635. Bx (3)
  636. #undef Bx
  637. transport -> choice = ipAddress_chosen;
  638. transport -> u.ipAddress.port = ntohs (addr -> sin_port);
  639. transport -> u.ipAddress.ip.length = 4;
  640. }
  641. #endif //_Q931PDU_H