PageRenderTime 67ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

/epan/dissectors/packet-x11.c

https://github.com/labx-technologies-llc/wireshark
C | 5658 lines | 4515 code | 650 blank | 493 comment | 535 complexity | 8e585c65f8191423a1c8a34fc80b582c MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause

Large files files are truncated, but you can click here to view the full file

  1. /* packet-x11.c
  2. * Routines for X11 dissection
  3. * Copyright 2000, Christophe Tronche <ch.tronche@computer.org>
  4. * Copyright 2003, Michael Shuldman
  5. *
  6. * $Id$
  7. *
  8. * Wireshark - Network traffic analyzer
  9. * By Gerald Combs <gerald@wireshark.org>
  10. * Copyright 1998 Gerald Combs
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License
  14. * as published by the Free Software Foundation; either version 2
  15. * of the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  25. */
  26. /* TODO (in no particular order):
  27. *
  28. * - keep track of Atom creation by server to be able to display
  29. * non-predefined atoms
  30. * - Idem for keysym <-> keycode ???
  31. * - Idem for fonts
  32. * - Subtree the request ids (that is x11.create-window.window and
  33. * x11.change-window.window should be distinct), and add hidden fields
  34. * (so we still have x11.window).
  35. * - add hidden fields so we can have x11.circulate-window in addition to
  36. * x11.opcode == 13 (but you could match on x11.opcode == "CirculateWindow"
  37. * now)
  38. * - add hidden fields so we have x11.listOfStuff.length
  39. * - use a faster scheme that linear list searching for the opcode.
  40. * - correct display of Unicode chars.
  41. * - Not everything is homogeneous, in particular the handling of items in
  42. * list is a total mess.
  43. */
  44. /* By the way, I wrote a program to generate every request and test
  45. * that stuff. If you're interested, you can get it at
  46. * http://tronche.com/gui/x/
  47. */
  48. #include "config.h"
  49. #include <assert.h>
  50. #include <string.h>
  51. #include <ctype.h>
  52. #include <glib.h>
  53. #include <epan/packet.h>
  54. #include <epan/conversation.h>
  55. #include <epan/expert.h>
  56. #include <epan/show_exception.h>
  57. #include <epan/prefs.h>
  58. #include <epan/emem.h>
  59. #include "packet-x11-keysymdef.h"
  60. #include "packet-x11.h"
  61. #define cVALS(x) (const value_string*)(x)
  62. /*
  63. * Data structure associated with a conversation; keeps track of the
  64. * request for which we're expecting a reply, the frame number of
  65. * the initial connection request, and the byte order of the connection.
  66. *
  67. * An opcode of -3 means we haven't yet seen any requests yet.
  68. * An opcode of -2 means we're not expecting a reply (unused).
  69. * An opcode of -1 means we're waiting for a reply to the initial
  70. * connection request.
  71. * An opcode of 0 means the request was not seen (or unknown).
  72. * Other values are the opcode of the request for which we're expecting
  73. * a reply.
  74. *
  75. */
  76. #define NOTHING_SEEN -3
  77. #define NOTHING_EXPECTED -2
  78. #define INITIAL_CONN -1
  79. #define UNKNOWN_OPCODE 0
  80. #define MAX_OPCODES (255 + 1) /* 255 + INITIAL_CONN */
  81. #define LastExtensionError 255
  82. #define LastExtensionEvent 127
  83. #define BYTE_ORDER_BE 0
  84. #define BYTE_ORDER_LE 1
  85. #define BYTE_ORDER_UNKNOWN -1
  86. static const char *modifiers[] = {
  87. "Shift",
  88. "Lock",
  89. "Control",
  90. "Mod1",
  91. "Mod2",
  92. "Mod3",
  93. "Mod4",
  94. "Mod5"
  95. };
  96. /* Keymasks. From <X11/X.h>. */
  97. #define ShiftMask (1<<0)
  98. #define LockMask (1<<1)
  99. #define ControlMask (1<<2)
  100. #define Mod1Mask (1<<3)
  101. #define Mod2Mask (1<<4)
  102. #define Mod3Mask (1<<5)
  103. #define Mod4Mask (1<<6)
  104. #define Mod5Mask (1<<7)
  105. static const int modifiermask[] = { ShiftMask, LockMask, ControlMask,
  106. Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask };
  107. /* from <X11/X.h> */
  108. #define NoSymbol 0L /* special KeySym */
  109. typedef struct _x11_conv_data {
  110. struct _x11_conv_data *next;
  111. GHashTable *seqtable; /* hashtable of sequencenumber <-> opcode. */
  112. GHashTable *valtable; /* hashtable of sequencenumber <-> &opcode_vals */
  113. /* major opcodes including extensions (NULL terminated) */
  114. value_string opcode_vals[MAX_OPCODES+1];
  115. /* error codes including extensions (NULL terminated) */
  116. value_string errorcode_vals[LastExtensionError + 2];
  117. /* event codes including extensions (NULL terminated) */
  118. value_string eventcode_vals[LastExtensionEvent + 2];
  119. GHashTable *eventcode_funcs; /* hashtable of eventcode <-> dissect_event() */
  120. GHashTable *reply_funcs; /* hashtable of opcode <-> dissect_reply() */
  121. int sequencenumber; /* sequencenumber of current packet. */
  122. guint32 iconn_frame; /* frame # of initial connection request */
  123. guint32 iconn_reply; /* frame # of initial connection reply */
  124. int byte_order; /* byte order of connection */
  125. gboolean resync; /* resynchronization of sequence number performed */
  126. int *keycodemap[256]; /* keycode to keysymvalue map. */
  127. int keysyms_per_keycode;
  128. int first_keycode;
  129. int *modifiermap[array_length(modifiers)];/* modifier to keycode.*/
  130. int keycodes_per_modifier;
  131. union {
  132. struct {
  133. int first_keycode;
  134. } GetKeyboardMapping;
  135. } request;
  136. } x11_conv_data_t;
  137. static x11_conv_data_t *x11_conv_data_list = NULL;
  138. static GHashTable *extension_table; /* hashtable of extension name <-> dispatch function */
  139. static GHashTable *event_table; /* hashtable of extension name <-> event info list */
  140. static GHashTable *error_table; /* hashtable of extension name <-> error list */
  141. static GHashTable *reply_table; /* hashtable of extension name <-> reply list */
  142. /* Initialize the protocol and registered fields */
  143. static int proto_x11 = -1;
  144. #include "x11-declarations.h"
  145. /* Initialize the subtree pointers */
  146. static gint ett_x11 = -1;
  147. static gint ett_x11_color_flags = -1;
  148. static gint ett_x11_list_of_arc = -1;
  149. static gint ett_x11_arc = -1;
  150. static gint ett_x11_list_of_atom = -1;
  151. static gint ett_x11_list_of_card32 = -1;
  152. static gint ett_x11_list_of_float = -1;
  153. static gint ett_x11_list_of_double = -1;
  154. static gint ett_x11_list_of_color_item = -1;
  155. static gint ett_x11_color_item = -1;
  156. static gint ett_x11_list_of_keycode = -1;
  157. static gint ett_x11_list_of_keysyms = -1;
  158. static gint ett_x11_keysym = -1;
  159. static gint ett_x11_list_of_point = -1;
  160. static gint ett_x11_point = -1;
  161. static gint ett_x11_list_of_rectangle = -1;
  162. static gint ett_x11_rectangle = -1;
  163. static gint ett_x11_list_of_segment = -1;
  164. static gint ett_x11_segment = -1;
  165. static gint ett_x11_list_of_string8 = -1;
  166. static gint ett_x11_list_of_text_item = -1;
  167. static gint ett_x11_text_item = -1;
  168. static gint ett_x11_gc_value_mask = -1; /* XXX - unused */
  169. static gint ett_x11_event_mask = -1; /* XXX - unused */
  170. static gint ett_x11_do_not_propagate_mask = -1; /* XXX - unused */
  171. static gint ett_x11_set_of_key_mask = -1;
  172. static gint ett_x11_pointer_event_mask = -1; /* XXX - unused */
  173. static gint ett_x11_window_value_mask = -1; /* XXX - unused */
  174. static gint ett_x11_configure_window_mask = -1; /* XXX - unused */
  175. static gint ett_x11_keyboard_value_mask = -1; /* XXX - unused */
  176. static gint ett_x11_same_screen_focus = -1;
  177. static gint ett_x11_event = -1;
  178. static expert_field ei_x11_invalid_format = EI_INIT;
  179. /* desegmentation of X11 messages */
  180. static gboolean x11_desegment = TRUE;
  181. #define TCP_PORT_X11 6000
  182. #define TCP_PORT_X11_2 6001
  183. #define TCP_PORT_X11_3 6002
  184. /*
  185. * Round a length to a multiple of 4 bytes.
  186. */
  187. #define ROUND_LENGTH(n) ((((n) + 3)/4) * 4)
  188. /************************************************************************
  189. *** ***
  190. *** E N U M T A B L E S D E F I N I T I O N S ***
  191. *** ***
  192. ************************************************************************/
  193. static const value_string byte_order_vals[] = {
  194. { 'B', "Big-endian" },
  195. { 'l', "Little-endian" },
  196. { 0, NULL }
  197. };
  198. static const value_string image_byte_order_vals[] = {
  199. { 0, "LSBFirst" },
  200. { 1, "MSBFirst" },
  201. { 0, NULL }
  202. };
  203. static const value_string access_mode_vals[] = {
  204. { 0, "Disable" },
  205. { 1, "Enable" },
  206. { 0, NULL }
  207. };
  208. static const value_string all_temporary_vals[] = {
  209. { 0, "AllTemporary" },
  210. { 0, NULL }
  211. };
  212. static const value_string alloc_vals[] = {
  213. { 0, "None" },
  214. { 1, "All" },
  215. { 0, NULL }
  216. };
  217. static const value_string allow_events_mode_vals[] = {
  218. { 0, "AsyncPointer" },
  219. { 1, "SyncPointer" },
  220. { 2, "ReplayPointer" },
  221. { 3, "AsyncKeyboard" },
  222. { 4, "SyncKeyboard" },
  223. { 5, "ReplayKeyboard" },
  224. { 6, "AsyncBoth" },
  225. { 7, "SyncBoth" },
  226. { 0, NULL }
  227. };
  228. static const value_string arc_mode_vals[] = {
  229. { 0, "Chord" },
  230. { 1, "PieSlice" },
  231. { 0, NULL }
  232. };
  233. static const char *atom_predefined_interpretation[] = {
  234. "<error>",
  235. "PRIMARY",
  236. "SECONDARY",
  237. "ARC",
  238. "ATOM",
  239. "BITMAP",
  240. "CARDINAL",
  241. "COLORMAP",
  242. "CURSOR",
  243. "CUT_BUFFER0",
  244. "CUT_BUFFER1",
  245. "CUT_BUFFER2",
  246. "CUT_BUFFER3",
  247. "CUT_BUFFER4",
  248. "CUT_BUFFER5",
  249. "CUT_BUFFER6",
  250. "CUT_BUFFER7",
  251. "DRAWABLE",
  252. "FONT",
  253. "INTEGER",
  254. "PIXMAP",
  255. "POINT",
  256. "RECTANGLE",
  257. "RESOURCE_MANAGER",
  258. "RGB_COLOR_MAP",
  259. "RGB_BEST_MAP",
  260. "RGB_BLUE_MAP",
  261. "RGB_DEFAULT_MAP",
  262. "RGB_GRAY_MAP",
  263. "RGB_GREEN_MAP",
  264. "RGB_RED_MAP",
  265. "STRING",
  266. "VISUALID",
  267. "WINDOW",
  268. "WM_COMMAND",
  269. "WM_HINTS",
  270. "WM_CLIENT_MACHINE",
  271. "WM_ICON_NAME",
  272. "WM_ICON_SIZE",
  273. "WM_NAME",
  274. "WM_NORMAL_HINTS",
  275. "WM_SIZE_HINTS",
  276. "WM_ZOOM_HINTS",
  277. "MIN_SPACE",
  278. "NORM_SPACE",
  279. "MAX_SPACE",
  280. "END_SPACE",
  281. "SUPERSCRIPT_X",
  282. "SUPERSCRIPT_Y",
  283. "SUBSCRIPT_X",
  284. "SUBSCRIPT_Y",
  285. "UNDERLINE_POSITION",
  286. "UNDERLINE_THICKNESS",
  287. "STRIKEOUT_ASCENT",
  288. "STRIKEOUT_DESCENT",
  289. "ITALIC_ANGLE",
  290. "X_HEIGHT",
  291. "QUAD_WIDTH",
  292. "WEIGHT",
  293. "POINT_SIZE",
  294. "RESOLUTION",
  295. "COPYRIGHT",
  296. "NOTICE",
  297. "FONT_NAME",
  298. "FAMILY_NAME",
  299. "FULL_NAME",
  300. "CAP_HEIGHT",
  301. "WM_CLASS",
  302. "WM_TRANSIENT_FOR",
  303. };
  304. static const value_string auto_repeat_mode_vals[] = {
  305. { 0, "Off" },
  306. { 1, "On" },
  307. { 2, "Default" },
  308. { 0, NULL }
  309. };
  310. static const value_string background_pixmap_vals[] = {
  311. { 0, "None" },
  312. { 1, "ParentRelative" },
  313. { 0, NULL }
  314. };
  315. static const value_string backing_store_vals[] = {
  316. { 0, "NotUseful" },
  317. { 1, "WhenMapped" },
  318. { 2, "Always" },
  319. { 0, NULL }
  320. };
  321. static const value_string border_pixmap_vals[] = {
  322. { 0, "CopyFromParent" },
  323. { 0, NULL }
  324. };
  325. static const value_string button_vals[] = {
  326. { 0x8000, "AnyButton" },
  327. { 0, NULL }
  328. };
  329. static const value_string cap_style_vals[] = {
  330. { 0, "NotLast" },
  331. { 1, "Butt" },
  332. { 2, "Round" },
  333. { 3, "Projecting" },
  334. { 0, NULL }
  335. };
  336. static const value_string class_vals[] = {
  337. { 0, "Cursor" },
  338. { 1, "Tile" },
  339. { 2, "Stipple" },
  340. { 0, NULL }
  341. };
  342. static const value_string close_down_mode_vals[] = {
  343. { 0, "Destroy" },
  344. { 1, "RetainPermanent" },
  345. { 2, "RetainTemporary" },
  346. { 0, NULL }
  347. };
  348. static const value_string colormap_state_vals[] = {
  349. { 0, "Uninstalled" },
  350. { 1, "Installed" },
  351. { 0, NULL }
  352. };
  353. static const value_string coordinate_mode_vals[] = {
  354. { 0, "Origin" },
  355. { 1, "Previous" },
  356. { 0, NULL }
  357. };
  358. static const value_string destination_vals[] = {
  359. { 0, "PointerWindow" },
  360. { 1, "InputFocus" },
  361. { 0, NULL }
  362. };
  363. static const value_string direction_vals[] = {
  364. { 0, "RaiseLowest" },
  365. { 1, "LowerHighest" },
  366. { 0, NULL }
  367. };
  368. static const value_string event_detail_vals[] = {
  369. { 0, "Ancestor" },
  370. { 1, "Virtual" },
  371. { 2, "Inferior" },
  372. { 3, "Nonlinear" },
  373. { 4, "NonlinearVirtual" },
  374. { 0, NULL }
  375. };
  376. #define FAMILY_INTERNET 0
  377. #define FAMILY_DECNET 1
  378. #define FAMILY_CHAOS 2
  379. static const value_string family_vals[] = {
  380. { FAMILY_INTERNET, "Internet" },
  381. { FAMILY_DECNET, "DECnet" },
  382. { FAMILY_CHAOS, "Chaos" },
  383. { 0, NULL }
  384. };
  385. static const value_string fill_rule_vals[] = {
  386. { 0, "EvenOdd" },
  387. { 1, "Winding" },
  388. { 0, NULL }
  389. };
  390. static const value_string fill_style_vals[] = {
  391. { 0, "Solid" },
  392. { 1, "Tiled" },
  393. { 2, "Stippled" },
  394. { 3, "OpaqueStippled" },
  395. { 0, NULL }
  396. };
  397. static const value_string focus_detail_vals[] = {
  398. { 0, "Ancestor" },
  399. { 1, "Virtual" },
  400. { 2, "Inferior" },
  401. { 3, "Nonlinear" },
  402. { 4, "NonlinearVirtual" },
  403. { 5, "Pointer" },
  404. { 6, "PointerRoot" },
  405. { 7, "None" },
  406. { 0, NULL }
  407. };
  408. static const value_string focus_mode_vals[] = {
  409. { 0, "Normal" },
  410. { 1, "Grab" },
  411. { 2, "Ungrab" },
  412. { 3, "WhileGrabbed" },
  413. { 0, NULL }
  414. };
  415. static const value_string focus_vals[] = {
  416. { 0, "None" },
  417. { 1, "PointerRoot" },
  418. { 0, NULL }
  419. };
  420. static const value_string function_vals[] = {
  421. { 0, "Clear" },
  422. { 1, "And" },
  423. { 2, "AndReverse" },
  424. { 3, "Copy" },
  425. { 4, "AndInverted" },
  426. { 5, "NoOp" },
  427. { 6, "Xor" },
  428. { 7, "Or" },
  429. { 8, "Nor" },
  430. { 9, "Equiv" },
  431. { 10, "Invert" },
  432. { 11, "OrReverse" },
  433. { 12, "CopyInverted" },
  434. { 13, "OrInverted" },
  435. { 14, "Nand" },
  436. { 15, "Set" },
  437. { 0, NULL }
  438. };
  439. static const value_string grab_mode_vals[] = {
  440. { 0, "Normal" },
  441. { 1, "Grab" },
  442. { 2, "Ungrab" },
  443. { 0, NULL }
  444. };
  445. static const value_string grab_status_vals[] = {
  446. { 0, "Success" },
  447. { 1, "AlreadyGrabbed" },
  448. { 2, "InvalidTime" },
  449. { 3, "NotViewable" },
  450. { 4, "Frozen" },
  451. { 0, NULL }
  452. };
  453. static const value_string gravity_vals[] = {
  454. { 1, "NorthWest" },
  455. { 2, "North" },
  456. { 3, "NorthEast" },
  457. { 4, "West" },
  458. { 5, "Center" },
  459. { 6, "East" },
  460. { 7, "SouthWest" },
  461. { 8, "South" },
  462. { 9, "SouthEast" },
  463. { 10, "Static" },
  464. { 0, NULL }
  465. };
  466. static const value_string image_format_vals[] = {
  467. { 0, "Bitmap" },
  468. { 1, "XYPixmap" },
  469. { 2, "ZPixmap" },
  470. { 0, NULL }
  471. };
  472. static const value_string image_pixmap_format_vals[] = {
  473. { 1, "XYPixmap" },
  474. { 2, "ZPixmap" },
  475. { 0, NULL }
  476. };
  477. static const value_string join_style_vals[] = {
  478. { 0, "Miter" },
  479. { 1, "Round" },
  480. { 2, "Bevel" },
  481. { 0, NULL }
  482. };
  483. static const value_string key_vals[] = {
  484. { 0, "AnyKey" },
  485. { 0, NULL }
  486. };
  487. #include "x11-keysym.h"
  488. static const value_string line_style_vals[] = {
  489. { 0, "Solid" },
  490. { 1, "OnOffDash" },
  491. { 2, "DoubleDash" },
  492. { 0, NULL }
  493. };
  494. static const value_string mode_vals[] = {
  495. { 0, "Replace" },
  496. { 1, "Prepend" },
  497. { 2, "Append" },
  498. { 0, NULL }
  499. };
  500. static const value_string on_off_vals[] = {
  501. { 0, "Off" },
  502. { 1, "On" },
  503. { 0, NULL }
  504. };
  505. static const value_string place_vals[] = {
  506. { 0, "Top" },
  507. { 1, "Bottom" },
  508. { 0, NULL }
  509. };
  510. static const value_string property_state_vals[] = {
  511. { 0, "NewValue" },
  512. { 1, "Deleted" },
  513. { 0, NULL }
  514. };
  515. static const value_string visibility_state_vals[] = {
  516. { 0, "Unobscured" },
  517. { 1, "PartiallyObscured" },
  518. { 2, "FullyObscured" },
  519. { 0, NULL }
  520. };
  521. static const value_string mapping_request_vals[] = {
  522. { 0, "MappingModifier" },
  523. { 1, "MappingKeyboard" },
  524. { 2, "MappingPointer" },
  525. { 0, NULL }
  526. };
  527. /* Requestcodes. From <X11/Xproto.h>. */
  528. #define X_CreateWindow 1
  529. #define X_ChangeWindowAttributes 2
  530. #define X_GetWindowAttributes 3
  531. #define X_DestroyWindow 4
  532. #define X_DestroySubwindows 5
  533. #define X_ChangeSaveSet 6
  534. #define X_ReparentWindow 7
  535. #define X_MapWindow 8
  536. #define X_MapSubwindows 9
  537. #define X_UnmapWindow 10
  538. #define X_UnmapSubwindows 11
  539. #define X_ConfigureWindow 12
  540. #define X_CirculateWindow 13
  541. #define X_GetGeometry 14
  542. #define X_QueryTree 15
  543. #define X_InternAtom 16
  544. #define X_GetAtomName 17
  545. #define X_ChangeProperty 18
  546. #define X_DeleteProperty 19
  547. #define X_GetProperty 20
  548. #define X_ListProperties 21
  549. #define X_SetSelectionOwner 22
  550. #define X_GetSelectionOwner 23
  551. #define X_ConvertSelection 24
  552. #define X_SendEvent 25
  553. #define X_GrabPointer 26
  554. #define X_UngrabPointer 27
  555. #define X_GrabButton 28
  556. #define X_UngrabButton 29
  557. #define X_ChangeActivePointerGrab 30
  558. #define X_GrabKeyboard 31
  559. #define X_UngrabKeyboard 32
  560. #define X_GrabKey 33
  561. #define X_UngrabKey 34
  562. #define X_AllowEvents 35
  563. #define X_GrabServer 36
  564. #define X_UngrabServer 37
  565. #define X_QueryPointer 38
  566. #define X_GetMotionEvents 39
  567. #define X_TranslateCoords 40
  568. #define X_WarpPointer 41
  569. #define X_SetInputFocus 42
  570. #define X_GetInputFocus 43
  571. #define X_QueryKeymap 44
  572. #define X_OpenFont 45
  573. #define X_CloseFont 46
  574. #define X_QueryFont 47
  575. #define X_QueryTextExtents 48
  576. #define X_ListFonts 49
  577. #define X_ListFontsWithInfo 50
  578. #define X_SetFontPath 51
  579. #define X_GetFontPath 52
  580. #define X_CreatePixmap 53
  581. #define X_FreePixmap 54
  582. #define X_CreateGC 55
  583. #define X_ChangeGC 56
  584. #define X_CopyGC 57
  585. #define X_SetDashes 58
  586. #define X_SetClipRectangles 59
  587. #define X_FreeGC 60
  588. #define X_ClearArea 61
  589. #define X_CopyArea 62
  590. #define X_CopyPlane 63
  591. #define X_PolyPoint 64
  592. #define X_PolyLine 65
  593. #define X_PolySegment 66
  594. #define X_PolyRectangle 67
  595. #define X_PolyArc 68
  596. #define X_FillPoly 69
  597. #define X_PolyFillRectangle 70
  598. #define X_PolyFillArc 71
  599. #define X_PutImage 72
  600. #define X_GetImage 73
  601. #define X_PolyText8 74
  602. #define X_PolyText16 75
  603. #define X_ImageText8 76
  604. #define X_ImageText16 77
  605. #define X_CreateColormap 78
  606. #define X_FreeColormap 79
  607. #define X_CopyColormapAndFree 80
  608. #define X_InstallColormap 81
  609. #define X_UninstallColormap 82
  610. #define X_ListInstalledColormaps 83
  611. #define X_AllocColor 84
  612. #define X_AllocNamedColor 85
  613. #define X_AllocColorCells 86
  614. #define X_AllocColorPlanes 87
  615. #define X_FreeColors 88
  616. #define X_StoreColors 89
  617. #define X_StoreNamedColor 90
  618. #define X_QueryColors 91
  619. #define X_LookupColor 92
  620. #define X_CreateCursor 93
  621. #define X_CreateGlyphCursor 94
  622. #define X_FreeCursor 95
  623. #define X_RecolorCursor 96
  624. #define X_QueryBestSize 97
  625. #define X_QueryExtension 98
  626. #define X_ListExtensions 99
  627. #define X_ChangeKeyboardMapping 100
  628. #define X_GetKeyboardMapping 101
  629. #define X_ChangeKeyboardControl 102
  630. #define X_GetKeyboardControl 103
  631. #define X_Bell 104
  632. #define X_ChangePointerControl 105
  633. #define X_GetPointerControl 106
  634. #define X_SetScreenSaver 107
  635. #define X_GetScreenSaver 108
  636. #define X_ChangeHosts 109
  637. #define X_ListHosts 110
  638. #define X_SetAccessControl 111
  639. #define X_SetCloseDownMode 112
  640. #define X_KillClient 113
  641. #define X_RotateProperties 114
  642. #define X_ForceScreenSaver 115
  643. #define X_SetPointerMapping 116
  644. #define X_GetPointerMapping 117
  645. #define X_SetModifierMapping 118
  646. #define X_GetModifierMapping 119
  647. #define X_NoOperation 127
  648. #define X_FirstExtension 128
  649. #define X_LastExtension 255
  650. static const value_string opcode_vals[] = {
  651. { INITIAL_CONN, "Initial connection request" },
  652. { X_CreateWindow, "CreateWindow" },
  653. { X_ChangeWindowAttributes, "ChangeWindowAttributes" },
  654. { X_GetWindowAttributes, "GetWindowAttributes" },
  655. { X_DestroyWindow, "DestroyWindow" },
  656. { X_DestroySubwindows, "DestroySubwindows" },
  657. { X_ChangeSaveSet, "ChangeSaveSet" },
  658. { X_ReparentWindow, "ReparentWindow" },
  659. { X_MapWindow, "MapWindow" },
  660. { X_MapSubwindows, "MapSubwindows" },
  661. { X_UnmapWindow, "UnmapWindow" },
  662. { X_UnmapSubwindows, "UnmapSubwindows" },
  663. { X_ConfigureWindow, "ConfigureWindow" },
  664. { X_CirculateWindow, "CirculateWindow" },
  665. { X_GetGeometry, "GetGeometry" },
  666. { X_QueryTree, "QueryTree" },
  667. { X_InternAtom, "InternAtom" },
  668. { X_GetAtomName, "GetAtomName" },
  669. { X_ChangeProperty, "ChangeProperty" },
  670. { X_DeleteProperty, "DeleteProperty" },
  671. { X_GetProperty, "GetProperty" },
  672. { X_ListProperties, "ListProperties" },
  673. { X_SetSelectionOwner, "SetSelectionOwner" },
  674. { X_GetSelectionOwner, "GetSelectionOwner" },
  675. { X_ConvertSelection, "ConvertSelection" },
  676. { X_SendEvent, "SendEvent" },
  677. { X_GrabPointer, "GrabPointer" },
  678. { X_UngrabPointer, "UngrabPointer" },
  679. { X_GrabButton, "GrabButton" },
  680. { X_UngrabButton, "UngrabButton" },
  681. { X_ChangeActivePointerGrab, "ChangeActivePointerGrab" },
  682. { X_GrabKeyboard, "GrabKeyboard" },
  683. { X_UngrabKeyboard, "UngrabKeyboard" },
  684. { X_GrabKey, "GrabKey" },
  685. { X_UngrabKey, "UngrabKey" },
  686. { X_AllowEvents, "AllowEvents" },
  687. { X_GrabServer, "GrabServer" },
  688. { X_UngrabServer, "UngrabServer" },
  689. { X_QueryPointer, "QueryPointer" },
  690. { X_GetMotionEvents, "GetMotionEvents" },
  691. { X_TranslateCoords, "TranslateCoordinates" },
  692. { X_WarpPointer, "WarpPointer" },
  693. { X_SetInputFocus, "SetInputFocus" },
  694. { X_GetInputFocus, "GetInputFocus" },
  695. { X_QueryKeymap, "QueryKeymap" },
  696. { X_OpenFont, "OpenFont" },
  697. { X_CloseFont, "CloseFont" },
  698. { X_QueryFont, "QueryFont" },
  699. { X_QueryTextExtents, "QueryTextExtents" },
  700. { X_ListFonts, "ListFonts" },
  701. { X_ListFontsWithInfo, "ListFontsWithInfo" },
  702. { X_SetFontPath, "SetFontPath" },
  703. { X_GetFontPath, "GetFontPath" },
  704. { X_CreatePixmap, "CreatePixmap" },
  705. { X_FreePixmap, "FreePixmap" },
  706. { X_CreateGC, "CreateGC" },
  707. { X_ChangeGC, "ChangeGC" },
  708. { X_CopyGC, "CopyGC" },
  709. { X_SetDashes, "SetDashes" },
  710. { X_SetClipRectangles, "SetClipRectangles" },
  711. { X_FreeGC, "FreeGC" },
  712. { X_ClearArea, "ClearArea" },
  713. { X_CopyArea, "CopyArea" },
  714. { X_CopyPlane, "CopyPlane" },
  715. { X_PolyPoint, "PolyPoint" },
  716. { X_PolyLine, "PolyLine" },
  717. { X_PolySegment, "PolySegment" },
  718. { X_PolyRectangle, "PolyRectangle" },
  719. { X_PolyArc, "PolyArc" },
  720. { X_FillPoly, "FillPoly" },
  721. { X_PolyFillRectangle, "PolyFillRectangle" },
  722. { X_PolyFillArc, "PolyFillArc" },
  723. { X_PutImage, "PutImage" },
  724. { X_GetImage, "GetImage" },
  725. { X_PolyText8, "PolyText8" },
  726. { X_PolyText16, "PolyText16" },
  727. { X_ImageText8, "ImageText8" },
  728. { X_ImageText16, "ImageText16" },
  729. { X_CreateColormap, "CreateColormap" },
  730. { X_FreeColormap, "FreeColormap" },
  731. { X_CopyColormapAndFree, "CopyColormapAndFree" },
  732. { X_InstallColormap, "InstallColormap" },
  733. { X_UninstallColormap, "UninstallColormap" },
  734. { X_ListInstalledColormaps, "ListInstalledColormaps" },
  735. { X_AllocColor, "AllocColor" },
  736. { X_AllocNamedColor, "AllocNamedColor" },
  737. { X_AllocColorCells, "AllocColorCells" },
  738. { X_AllocColorPlanes, "AllocColorPlanes" },
  739. { X_FreeColors, "FreeColors" },
  740. { X_StoreColors, "StoreColors" },
  741. { X_StoreNamedColor, "StoreNamedColor" },
  742. { X_QueryColors, "QueryColors" },
  743. { X_LookupColor, "LookupColor" },
  744. { X_CreateCursor, "CreateCursor" },
  745. { X_CreateGlyphCursor, "CreateGlyphCursor" },
  746. { X_FreeCursor, "FreeCursor" },
  747. { X_RecolorCursor, "RecolorCursor" },
  748. { X_QueryBestSize, "QueryBestSize" },
  749. { X_QueryExtension, "QueryExtension" },
  750. { X_ListExtensions, "ListExtensions" },
  751. { X_ChangeKeyboardMapping, "ChangeKeyboardMapping" },
  752. { X_GetKeyboardMapping, "GetKeyboardMapping" },
  753. { X_ChangeKeyboardControl, "ChangeKeyboardControl" },
  754. { X_GetKeyboardControl, "GetKeyboardControl" },
  755. { X_Bell, "Bell" },
  756. { X_ChangePointerControl, "ChangePointerControl" },
  757. { X_GetPointerControl, "GetPointerControl" },
  758. { X_SetScreenSaver, "SetScreenSaver" },
  759. { X_GetScreenSaver, "GetScreenSaver" },
  760. { X_ChangeHosts, "ChangeHosts" },
  761. { X_ListHosts, "ListHosts" },
  762. { X_SetAccessControl, "SetAccessControl" },
  763. { X_SetCloseDownMode, "SetCloseDownMode" },
  764. { X_KillClient, "KillClient" },
  765. { X_RotateProperties, "RotateProperties" },
  766. { X_ForceScreenSaver, "ForceScreenSaver" },
  767. { X_SetPointerMapping, "SetPointerMapping" },
  768. { X_GetPointerMapping, "GetPointerMapping" },
  769. { X_SetModifierMapping, "SetModifierMapping" },
  770. { X_GetModifierMapping, "GetModifierMapping" },
  771. { X_NoOperation, "NoOperation" },
  772. { 0, NULL }
  773. };
  774. /* Eventscodes. From <X11/X.h>. */
  775. #define KeyPress 2
  776. #define KeyRelease 3
  777. #define ButtonPress 4
  778. #define ButtonRelease 5
  779. #define MotionNotify 6
  780. #define EnterNotify 7
  781. #define LeaveNotify 8
  782. #define FocusIn 9
  783. #define FocusOut 10
  784. #define KeymapNotify 11
  785. #define Expose 12
  786. #define GraphicsExpose 13
  787. #define NoExpose 14
  788. #define VisibilityNotify 15
  789. #define CreateNotify 16
  790. #define DestroyNotify 17
  791. #define UnmapNotify 18
  792. #define MapNotify 19
  793. #define MapRequest 20
  794. #define ReparentNotify 21
  795. #define ConfigureNotify 22
  796. #define ConfigureRequest 23
  797. #define GravityNotify 24
  798. #define ResizeRequest 25
  799. #define CirculateNotify 26
  800. #define CirculateRequest 27
  801. #define PropertyNotify 28
  802. #define SelectionClear 29
  803. #define SelectionRequest 30
  804. #define SelectionNotify 31
  805. #define ColormapNotify 32
  806. #define ClientMessage 33
  807. #define MappingNotify 34
  808. static const value_string eventcode_vals[] = {
  809. { KeyPress, "KeyPress" },
  810. { KeyRelease, "KeyRelease" },
  811. { ButtonPress, "ButtonPress" },
  812. { ButtonRelease, "ButtonRelease" },
  813. { MotionNotify, "MotionNotify" },
  814. { EnterNotify, "EnterNotify" },
  815. { LeaveNotify, "LeaveNotify" },
  816. { FocusIn, "FocusIn" },
  817. { FocusOut, "FocusOut" },
  818. { KeymapNotify, "KeymapNotify" },
  819. { Expose, "Expose" },
  820. { GraphicsExpose, "GraphicsExpose" },
  821. { NoExpose, "NoExpose" },
  822. { VisibilityNotify, "VisibilityNotify" },
  823. { CreateNotify, "CreateNotify" },
  824. { DestroyNotify, "DestroyNotify" },
  825. { UnmapNotify, "UnmapNotify" },
  826. { MapNotify, "MapNotify" },
  827. { MapRequest, "MapRequest" },
  828. { ReparentNotify, "ReparentNotify" },
  829. { ConfigureNotify, "ConfigureNotify" },
  830. { ConfigureRequest, "ConfigureRequest" },
  831. { GravityNotify, "GravityNotify" },
  832. { ResizeRequest, "ResizeRequest" },
  833. { CirculateNotify, "CirculateNotify" },
  834. { CirculateRequest, "CirculateRequest" },
  835. { PropertyNotify, "PropertyNotify" },
  836. { SelectionClear, "SelectionClear" },
  837. { SelectionRequest, "SelectionRequest" },
  838. { SelectionNotify, "SelectionNotify" },
  839. { ColormapNotify, "ColormapNotify" },
  840. { ClientMessage, "ClientMessage" },
  841. { MappingNotify, "MappingNotify" },
  842. { 0, NULL }
  843. };
  844. /* Errorcodes. From <X11/X.h> */
  845. #define Success 0 /* everything's okay */
  846. #define BadRequest 1 /* bad request code */
  847. #define BadValue 2 /* int parameter out of range */
  848. #define BadWindow 3 /* parameter not a Window */
  849. #define BadPixmap 4 /* parameter not a Pixmap */
  850. #define BadAtom 5 /* parameter not an Atom */
  851. #define BadCursor 6 /* parameter not a Cursor */
  852. #define BadFont 7 /* parameter not a Font */
  853. #define BadMatch 8 /* parameter mismatch */
  854. #define BadDrawable 9 /* parameter not a Pixmap or Window */
  855. #define BadAccess 10 /* depending on context:
  856. - key/button already grabbed
  857. - attempt to free an illegal
  858. cmap entry
  859. - attempt to store into a read-only
  860. color map entry.
  861. - attempt to modify the access control
  862. list from other than the local host.
  863. */
  864. #define BadAlloc 11 /* insufficient resources */
  865. #define BadColor 12 /* no such colormap */
  866. #define BadGC 13 /* parameter not a GC */
  867. #define BadIDChoice 14 /* choice not in range or already used */
  868. #define BadName 15 /* font or color name doesn't exist */
  869. #define BadLength 16 /* Request length incorrect */
  870. #define BadImplementation 17 /* server is defective */
  871. static const value_string errorcode_vals[] = {
  872. { Success, "Success" },
  873. { BadRequest, "BadRequest" },
  874. { BadValue, "BadValue" },
  875. { BadWindow, "BadWindow" },
  876. { BadPixmap, "BadPixmap" },
  877. { BadAtom, "BadAtom" },
  878. { BadCursor, "BadCursor" },
  879. { BadFont, "BadFont" },
  880. { BadMatch, "BadMatch" },
  881. { BadDrawable, "BadDrawable" },
  882. { BadAccess, "BadAccess" },
  883. { BadAlloc, "BadAlloc" },
  884. { BadColor, "BadColor" },
  885. { BadGC, "BadGC" },
  886. { BadIDChoice, "BadIDChoice" },
  887. { BadName, "BadName" },
  888. { BadLength, "BadLength" },
  889. { BadImplementation, "BadImplementation" },
  890. { 0, NULL }
  891. };
  892. static const value_string ordering_vals[] = {
  893. { 0, "UnSorted" },
  894. { 1, "YSorted" },
  895. { 2, "YXSorted" },
  896. { 3, "YXBanded" },
  897. { 0, NULL }
  898. };
  899. static const value_string plane_mask_vals[] = {
  900. { 0xFFFFFFFF, "AllPlanes" },
  901. { 0, NULL }
  902. };
  903. static const value_string pointer_keyboard_mode_vals[] = {
  904. { 0, "Synchronous" },
  905. { 1, "Asynchronous" },
  906. { 0, NULL }
  907. };
  908. static const value_string revert_to_vals[] = {
  909. { 0, "None" },
  910. { 1, "PointerRoot" },
  911. { 2, "Parent" },
  912. { 0, NULL }
  913. };
  914. static const value_string insert_delete_vals[] = {
  915. { 0, "Insert" },
  916. { 1, "Delete" },
  917. { 0, NULL }
  918. };
  919. static const value_string screen_saver_mode_vals[] = {
  920. { 0, "Reset" },
  921. { 1, "Activate" },
  922. { 0, NULL }
  923. };
  924. static const value_string shape_vals[] = {
  925. { 0, "Complex" },
  926. { 1, "Nonconvex" },
  927. { 2, "Convex" },
  928. { 0, NULL }
  929. };
  930. static const value_string stack_mode_vals[] = {
  931. { 0, "Above" },
  932. { 1, "Below" },
  933. { 2, "TopIf" },
  934. { 3, "BottomIf" },
  935. { 4, "Opposite" },
  936. { 0, NULL }
  937. };
  938. static const value_string subwindow_mode_vals[] = {
  939. { 0, "ClipByChildren" },
  940. { 1, "IncludeInferiors" },
  941. { 0, NULL }
  942. };
  943. static const value_string window_class_vals[] = {
  944. { 0, "CopyFromParent" },
  945. { 1, "InputOutput" },
  946. { 2, "InputOnly" },
  947. { 0, NULL }
  948. };
  949. static const value_string yes_no_default_vals[] = {
  950. { 0, "No" },
  951. { 1, "Yes" },
  952. { 2, "Default" },
  953. { 0, NULL }
  954. };
  955. static const value_string zero_is_any_property_type_vals[] = {
  956. { 0, "AnyPropertyType" },
  957. { 0, NULL }
  958. };
  959. static const value_string zero_is_none_vals[] = {
  960. { 0, "None" },
  961. { 0, NULL }
  962. };
  963. /* we have not seen packet before. */
  964. #define PACKET_IS_NEW(pinfo) \
  965. (!((pinfo)->fd->flags.visited))
  966. /************************************************************************
  967. *** ***
  968. *** F I E L D D E C O D I N G M A C R O S ***
  969. *** ***
  970. ************************************************************************/
  971. #define VALUE8(tvb, offset) (tvb_get_guint8(tvb, offset))
  972. #define VALUE16(tvb, offset) (byte_order == ENC_BIG_ENDIAN ? tvb_get_ntohs(tvb, offset) : tvb_get_letohs(tvb, offset))
  973. #define VALUE32(tvb, offset) (byte_order == ENC_BIG_ENDIAN ? tvb_get_ntohl(tvb, offset) : tvb_get_letohl(tvb, offset))
  974. #define FLOAT(tvb, offset) (byte_order == ENC_BIG_ENDIAN ? tvb_get_ntohieee_float(tvb, offset) : tvb_get_letohieee_float(tvb, offset))
  975. #define DOUBLE(tvb, offset) (byte_order == ENC_BIG_ENDIAN ? tvb_get_ntohieee_double(tvb, offset) : tvb_get_letohieee_double(tvb, offset))
  976. #define FIELD8(name) (field8(tvb, offsetp, t, hf_x11_##name, byte_order))
  977. #define FIELD16(name) (field16(tvb, offsetp, t, hf_x11_##name, byte_order))
  978. #define FIELD32(name) (field32(tvb, offsetp, t, hf_x11_##name, byte_order))
  979. #define BITFIELD(TYPE, position, name) { \
  980. int unused; \
  981. int save = *offsetp; \
  982. proto_tree_add_item(bitmask_tree, hf_x11_##position##_##name, tvb, bitmask_offset, \
  983. bitmask_size, byte_order); \
  984. if (bitmask_value & proto_registrar_get_nth(hf_x11_##position##_##name) -> bitmask) { \
  985. TYPE(name); \
  986. unused = save + 4 - *offsetp; \
  987. if (unused) \
  988. proto_tree_add_item(t, hf_x11_unused, tvb, *offsetp, unused, ENC_NA); \
  989. *offsetp = save + 4; \
  990. } \
  991. }
  992. #define FLAG(position, name) {\
  993. proto_tree_add_boolean(bitmask_tree, hf_x11_##position##_mask##_##name, tvb, bitmask_offset, bitmask_size, bitmask_value); }
  994. #define FLAG_IF_NONZERO(position, name) do {\
  995. if (bitmask_value & proto_registrar_get_nth(hf_x11_##position##_mask##_##name) -> bitmask) \
  996. proto_tree_add_boolean(bitmask_tree, hf_x11_##position##_mask##_##name, tvb, bitmask_offset, bitmask_size, bitmask_value); } while (0)
  997. #define ATOM(name) { atom(tvb, offsetp, t, hf_x11_##name, byte_order); }
  998. #define BITGRAVITY(name) { gravity(tvb, offsetp, t, hf_x11_##name, "Forget"); }
  999. #define BITMASK(name, size) {\
  1000. proto_item *bitmask_ti; \
  1001. guint32 bitmask_value; \
  1002. int bitmask_offset; \
  1003. int bitmask_size; \
  1004. proto_tree *bitmask_tree; \
  1005. bitmask_value = ((size == 1) ? (guint32)VALUE8(tvb, *offsetp) : \
  1006. ((size == 2) ? (guint32)VALUE16(tvb, *offsetp) : \
  1007. (guint32)VALUE32(tvb, *offsetp))); \
  1008. bitmask_offset = *offsetp; \
  1009. bitmask_size = size; \
  1010. bitmask_ti = proto_tree_add_uint(t, hf_x11_##name##_mask, tvb, *offsetp, size, bitmask_value); \
  1011. bitmask_tree = proto_item_add_subtree(bitmask_ti, ett_x11_##name##_mask); \
  1012. *offsetp += size;
  1013. #define ENDBITMASK }
  1014. #define BITMASK8(name) BITMASK(name, 1);
  1015. #define BITMASK16(name) BITMASK(name, 2);
  1016. #define BITMASK32(name) BITMASK(name, 4);
  1017. #define BOOL(name) (add_boolean(tvb, offsetp, t, hf_x11_##name))
  1018. #define BUTTON(name) FIELD8(name)
  1019. #define CARD8(name) FIELD8(name)
  1020. #define CARD16(name) (FIELD16(name))
  1021. #define CARD32(name) (FIELD32(name))
  1022. #define COLOR_FLAGS(name) colorFlags(tvb, offsetp, t)
  1023. #define COLORMAP(name) FIELD32(name)
  1024. #define CURSOR(name) FIELD32(name)
  1025. #define DRAWABLE(name) FIELD32(name)
  1026. #define ENUM8(name) (FIELD8(name))
  1027. #define ENUM16(name) (FIELD16(name))
  1028. #define FONT(name) FIELD32(name)
  1029. #define FONTABLE(name) FIELD32(name)
  1030. #define GCONTEXT(name) FIELD32(name)
  1031. #define INT8(name) FIELD8(name)
  1032. #define INT16(name) FIELD16(name)
  1033. #define INT32(name) FIELD32(name)
  1034. #define KEYCODE(name) FIELD8(name)
  1035. #define KEYCODE_DECODED(name, keycode, mask) do { \
  1036. proto_tree_add_uint_format(t, hf_x11_##name, tvb, offset, 1, \
  1037. keycode, "keycode: %d (%s)", \
  1038. keycode, keycode2keysymString(state->keycodemap, \
  1039. state->first_keycode, state->keysyms_per_keycode, \
  1040. state->modifiermap, state->keycodes_per_modifier, \
  1041. keycode, mask)); \
  1042. ++offset; \
  1043. } while (0)
  1044. #define EVENT() do { \
  1045. tvbuff_t *next_tvb; \
  1046. unsigned char eventcode; \
  1047. const char *sent; \
  1048. proto_item *event_ti; \
  1049. proto_tree *event_proto_tree; \
  1050. next_tvb = tvb_new_subset(tvb, offset, next_offset - offset, \
  1051. next_offset - offset); \
  1052. eventcode = tvb_get_guint8(next_tvb, 0); \
  1053. sent = (eventcode & 0x80) ? "Sent-" : ""; \
  1054. event_ti = proto_tree_add_text(t, next_tvb, 0, -1, \
  1055. "event: %d (%s)", \
  1056. eventcode, \
  1057. val_to_str(eventcode & 0x7F, \
  1058. state->eventcode_vals, \
  1059. "<Unknown eventcode %u>")); \
  1060. event_proto_tree = proto_item_add_subtree(event_ti, \
  1061. ett_x11_event); \
  1062. decode_x11_event(next_tvb, eventcode, sent, event_proto_tree, \
  1063. state, byte_order); \
  1064. offset = next_offset; \
  1065. } while (0)
  1066. #define LISTofARC(name) { listOfArc(tvb, offsetp, t, hf_x11_##name, (next_offset - *offsetp) / 12, byte_order); }
  1067. #define LISTofATOM(name, length) { listOfAtom(tvb, offsetp, t, hf_x11_##name, (length) / 4, byte_order); }
  1068. #define LISTofBYTE(name, length) { listOfByte(tvb, offsetp, t, hf_x11_##name, (length), byte_order); }
  1069. #define LISTofCARD8(name, length) { listOfByte(tvb, offsetp, t, hf_x11_##name, (length), byte_order); }
  1070. #define LISTofIPADDRESS(name, length) { listOfByte(tvb, offsetp, t, hf_x11_##name, (length), FALSE); }
  1071. #define LISTofCARD16(name, length) { listOfCard16(tvb, offsetp, t, hf_x11_##name, hf_x11_##name##_item, (length) / 2, byte_order); }
  1072. #define LISTofCARD32(name, length) { listOfCard32(tvb, offsetp, t, hf_x11_##name, hf_x11_##name##_item, (length) / 4, byte_order); }
  1073. #define LISTofCOLORITEM(name, length) { listOfColorItem(tvb, offsetp, t, hf_x11_##name, (length) / 12, byte_order); }
  1074. #define LISTofKEYCODE(map, name, length) { listOfKeycode(tvb, offsetp, t, hf_x11_##name, map, (length), byte_order); }
  1075. #define LISTofKEYSYM(name, map, keycode_first, keycode_count, \
  1076. keysyms_per_keycode) {\
  1077. listOfKeysyms(tvb, offsetp, t, hf_x11_##name, hf_x11_##name##_item, map, (keycode_first), (keycode_count), (keysyms_per_keycode), byte_order); }
  1078. #define LISTofPOINT(name, length) { listOfPoint(tvb, offsetp, t, hf_x11_##name, (length) / 4, byte_order); }
  1079. #define LISTofRECTANGLE(name) { listOfRectangle(tvb, offsetp, t, hf_x11_##name, (next_offset - *offsetp) / 8, byte_order); }
  1080. #define LISTofSEGMENT(name) { listOfSegment(tvb, offsetp, t, hf_x11_##name, (next_offset - *offsetp) / 8, byte_order); }
  1081. #define LISTofSTRING8(name, length) { listOfString8(tvb, offsetp, t, hf_x11_##name, hf_x11_##name##_string, (length), byte_order); }
  1082. #define LISTofTEXTITEM8(name) { listOfTextItem(tvb, offsetp, t, hf_x11_##name, FALSE, next_offset, byte_order); }
  1083. #define LISTofTEXTITEM16(name) { listOfTextItem(tvb, offsetp, t, hf_x11_##name, TRUE, next_offset, byte_order); }
  1084. #define OPCODE() { \
  1085. opcode = VALUE8(tvb, *offsetp); \
  1086. proto_tree_add_uint_format(t, hf_x11_opcode, tvb, *offsetp, \
  1087. 1, opcode, "opcode: %u (%s)", opcode, \
  1088. val_to_str_const(opcode, state->opcode_vals, "Unknown")); \
  1089. *offsetp += 1; \
  1090. }
  1091. #define PIXMAP(name) { FIELD32(name); }
  1092. #define REQUEST_LENGTH() (requestLength(tvb, offsetp, t, byte_order))
  1093. #define SETofEVENT(name) { setOfEvent(tvb, offsetp, t, byte_order); }
  1094. #define SETofDEVICEEVENT(name) { setOfDeviceEvent(tvb, offsetp, t, byte_order);}
  1095. #define SETofKEYMASK(name) { setOfKeyButMask(tvb, offsetp, t, byte_order, 0); }
  1096. #define SETofKEYBUTMASK(name) { setOfKeyButMask(tvb, offsetp, t, byte_order, 1); }
  1097. #define SETofPOINTEREVENT(name) { setOfPointerEvent(tvb, offsetp, t, byte_order); }
  1098. #define STRING8(name, length) { string8(tvb, offsetp, t, hf_x11_##name, length); }
  1099. #define STRING16(name, length) { string16(tvb, offsetp, t, hf_x11_##name, hf_x11_##name##_bytes, length, byte_order); }
  1100. #define TIMESTAMP(name){ timestamp(tvb, offsetp, t, hf_x11_##name, byte_order); }
  1101. #define UNDECODED(x) { proto_tree_add_item(t, hf_x11_undecoded, tvb, *offsetp, x, ENC_NA); *offsetp += x; }
  1102. #define UNUSED(x) { proto_tree_add_item(t, hf_x11_unused, tvb, *offsetp, x, ENC_NA); *offsetp += x; }
  1103. #define PAD() { if (next_offset - *offsetp > 0) proto_tree_add_item(t, hf_x11_unused, tvb, *offsetp, next_offset - *offsetp, ENC_NA); *offsetp = next_offset; }
  1104. #define WINDOW(name) { FIELD32(name); }
  1105. #define WINGRAVITY(name) { gravity(tvb, offsetp, t, hf_x11_##name, "Unmap"); }
  1106. #define VISUALID(name) { gint32 v = VALUE32(tvb, *offsetp); \
  1107. proto_tree_add_uint_format(t, hf_x11_##name, tvb, *offsetp, 4, v, "Visualid: 0x%08x%s", v, \
  1108. v ? "" : " (CopyFromParent)"); *offsetp += 4; }
  1109. #define REPLY(name) FIELD8(name);
  1110. #define REPLYLENGTH(name) FIELD32(name);
  1111. #define EVENTCONTENTS_COMMON() do { \
  1112. TIMESTAMP(time); \
  1113. WINDOW(rootwindow); \
  1114. WINDOW(eventwindow); \
  1115. WINDOW(childwindow); \
  1116. INT16(root_x); \
  1117. INT16(root_y); \
  1118. INT16(event_x); \
  1119. INT16(event_y); \
  1120. setOfKeyButMask(tvb, offsetp, t, byte_order, 1); \
  1121. } while (0)
  1122. #define SEQUENCENUMBER_REPLY(name) do { \
  1123. guint16 seqno; \
  1124. \
  1125. seqno = VALUE16(tvb, *offsetp); \
  1126. proto_tree_add_uint_format(t, hf_x11_reply_##name, tvb, \
  1127. *offsetp, 2, seqno, \
  1128. "sequencenumber: %d (%s)", \
  1129. (int)seqno, \
  1130. val_to_str(opcode & 0xFF, state->opcode_vals, "<Unknown opcode %d>")); \
  1131. *offsetp += 2; \
  1132. } while (0)
  1133. #define REPLYCONTENTS_COMMON() do { \
  1134. REPLY(reply); \
  1135. proto_tree_add_item(t, hf_x11_undecoded, tvb, *offsetp, \
  1136. 1, ENC_NA); \
  1137. ++(*offsetp); \
  1138. SEQUENCENUMBER_REPLY(sequencenumber); \
  1139. REPLYLENGTH(replylength); \
  1140. proto_tree_add_item(t, hf_x11_undecoded, tvb, *offsetp, \
  1141. tvb_reported_length_remaining(tvb, *offsetp), ENC_NA); \
  1142. *offsetp += tvb_reported_length_remaining(tvb, *offsetp); \
  1143. } while (0)
  1144. #define HANDLE_REPLY(plen, length_remaining, str, func) do { \
  1145. if (length_remaining < plen) { \
  1146. if (x11_desegment && pinfo->can_desegment) { \
  1147. pinfo->desegment_offset = offset; \
  1148. pinfo->desegment_len = plen - length_remaining; \
  1149. return; \
  1150. } else { \
  1151. ; /* XXX yes, what then? Need to skip/join. */ \
  1152. } \
  1153. } \
  1154. if (length_remaining > plen) \
  1155. length_remaining = plen; \
  1156. next_tvb = tvb_new_subset(tvb, offset, length_remaining, plen); \
  1157. \
  1158. if (sep == NULL) { \
  1159. col_set_str(pinfo->cinfo, COL_INFO, str); \
  1160. sep = ":"; \
  1161. } \
  1162. \
  1163. TRY { \
  1164. func(next_tvb, pinfo, tree,

Large files files are truncated, but you can click here to view the full file