PageRenderTime 61ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/epan/dissectors/packet-ncp-nmas.c

https://github.com/labx-technologies-llc/wireshark
C | 776 lines | 652 code | 62 blank | 62 comment | 41 complexity | f74e0c927ffb1f8153d3321b022c2ca0 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause
  1. /* packet-ncp-nmas.c
  2. * Routines for Novell Modular Authentication Service
  3. * Greg Morris <gmorris@novell.com>
  4. * Copyright (c) Novell, Inc. 2002-2004
  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. #include "config.h"
  27. #include <glib.h>
  28. #include <epan/packet.h>
  29. #include <epan/emem.h>
  30. #include "packet-ncp-int.h"
  31. #include "packet-ncp-nmas.h"
  32. static gint ett_nmas = -1;
  33. static int proto_nmas = -1;
  34. /* static int hf_func = -1; */
  35. /* static int hf_subfunc = -1; */
  36. static int hf_ping_version = -1;
  37. static int hf_ping_flags = -1;
  38. static int hf_frag_handle = -1;
  39. static int hf_length = -1;
  40. static int hf_subverb = -1;
  41. static int hf_tree = -1;
  42. static int hf_user = -1;
  43. static int hf_nmas_version = -1;
  44. static int hf_msg_version = -1;
  45. static int hf_session_ident = -1;
  46. static int hf_msg_verb = -1;
  47. /* static int hf_attribute = -1; */
  48. static int hf_clearance = -1;
  49. static int hf_login_sequence = -1;
  50. static int hf_opaque = -1;
  51. static int hf_data = -1;
  52. static int hf_return_code = -1;
  53. static int hf_lsm_verb = -1;
  54. static int hf_squeue_bytes = -1;
  55. static int hf_cqueue_bytes = -1;
  56. static int hf_num_creds = -1;
  57. static int hf_cred_type = -1;
  58. static int hf_login_state = -1;
  59. static int hf_enc_cred = -1;
  60. static int hf_enc_data = -1;
  61. static int hf_reply_buffer_size = -1;
  62. static int hf_encrypt_error = -1;
  63. static expert_field ei_encrypt_error = EI_INIT;
  64. static expert_field ei_return_error = EI_INIT;
  65. static const value_string nmas_func_enum[] = {
  66. { 0x01, "Ping" },
  67. { 0x02, "Fragment" },
  68. { 0x03, "Abort" },
  69. { 0, NULL }
  70. };
  71. static const value_string nmas_subverb_enum[] = {
  72. { 0, "Fragmented Ping" },
  73. { 2, "Client Put Data" },
  74. { 4, "Client Get Data" },
  75. { 6, "Client Get User NDS Credentials" },
  76. { 8, "Login Store Management" },
  77. { 10, "Writable Object Check" },
  78. { 1242, "Message Handler" },
  79. { 0, NULL }
  80. };
  81. static const value_string nmas_msgverb_enum[] = {
  82. { 1, "Echo Data" },
  83. { 3, "Start Session" },
  84. { 5, "Client Write Data" },
  85. { 7, "Client Read Data" },
  86. { 9, "End Session" },
  87. { 0, NULL }
  88. };
  89. static const value_string nmas_attribute_enum[] = {
  90. { 1, "User Name" },
  91. { 2, "Tree Name" },
  92. { 4, "Clearance" },
  93. { 11, "Login Sequence" },
  94. { 0, NULL }
  95. };
  96. static const value_string nmas_lsmverb_enum[] = {
  97. { 1, "Put Login Configuration" },
  98. { 2, "Get Login Configuration" },
  99. { 3, "Get All Configurations" },
  100. { 4, "Delete Login Configuration" },
  101. { 5, "Put Login Secret" },
  102. { 6, "Delete Login Secret" },
  103. { 7, "Set Password" },
  104. { 8, "Change Password" },
  105. { 9, "Delete Password" },
  106. { 10, "Get Password" },
  107. { 11, "Check Password Policy" },
  108. { 0, NULL }
  109. };
  110. static const value_string nmas_errors_enum[] = {
  111. { 0xFFFFF9A1, "(-1631) FRAGMENT FAILURE" },
  112. { 0xFFFFF9A0, "(-1632) BAD REQUEST SYNTAX" },
  113. { 0xFFFFF99F, "(-1633) BUFFER OVERFLOW" },
  114. { 0xFFFFF99E, "(-1634) SYSTEM RESOURCES" },
  115. { 0xFFFFF99D, "(-1635) INSUFFICIENT MEMORY" },
  116. { 0xFFFFF99C, "(-1636) NOT SUPPORTED" },
  117. { 0xFFFFF99B, "(-1637) BUFFER UNDERFLOW" },
  118. { 0xFFFFF99A, "(-1638) NOT FOUND" },
  119. { 0xFFFFF999, "(-1639) INVALID OPERATION" },
  120. { 0xFFFFF998, "(-1640) ASN1 DECODE" },
  121. { 0xFFFFF997, "(-1641) ASN1 ENCODE" },
  122. { 0xFFFFF996, "(-1642) LOGIN FAILED" },
  123. { 0xFFFFF995, "(-1643) INVALID PARAMETER" },
  124. { 0xFFFFF994, "(-1644) TIMED OUT RECOVERABLE" },
  125. { 0xFFFFF993, "(-1645) TIMED OUT NOT RECOVERABLE" },
  126. { 0xFFFFF992, "(-1646) TIMED OUT UNKNOWN" },
  127. { 0xFFFFF991, "(-1647) AUTHORIZATION FAILURE" },
  128. { 0xFFFFF990, "(-1648) INVALID DISTINGUISHED NAME" },
  129. { 0xFFFFF98F, "(-1649) CANNOT RESOLVE DISTINGUISHED NAME" },
  130. { 0xFFFFF98E, "(-1650) CANNOT RESOLVE CONNECTION" },
  131. { 0xFFFFF98D, "(-1651) NO CRYPTOGRAPHY" },
  132. { 0xFFFFF98C, "(-1652) INVALID VERSION" },
  133. { 0xFFFFF98B, "(-1653) SYNC NEEDED" },
  134. { 0xFFFFF98A, "(-1654) PROTOCOL STATE" },
  135. { 0xFFFFF989, "(-1655) INVALID HANDLE" },
  136. { 0xFFFFF988, "(-1656) INVALID METHOD" },
  137. { 0xFFFFF987, "(-1657) DEVELOPMENT VERSION" },
  138. { 0xFFFFF986, "(-1658) MISSING KEY" },
  139. { 0xFFFFF985, "(-1659) ACCESS NOT ALLOWED" },
  140. { 0xFFFFF984, "(-1660) SEQUENCE NOT FOUND" },
  141. { 0xFFFFF983, "(-1661) CLEARANCE NOT FOUND" },
  142. { 0xFFFFF982, "(-1662) LOGIN SERVER METHOD NOT FOUND" },
  143. { 0xFFFFF981, "(-1663) LOGIN CLIENT METHOD NOT FOUND" },
  144. { 0xFFFFF980, "(-1664) SERVER NOT FOUND" },
  145. { 0xFFFFF97F, "(-1665) LOGIN ATTRIBUTE NOT FOUND" },
  146. { 0xFFFFF97E, "(-1666) LEGACY INVALID PASSWORD" },
  147. { 0xFFFFF97D, "(-1667) ACCOUNT DISABLED" },
  148. { 0xFFFFF97C, "(-1668) ACCOUNT LOCKED" },
  149. { 0xFFFFF97B, "(-1669) ADDRESS RESTRICTION" },
  150. { 0xFFFFF97A, "(-1670) CONNECTION CLEARED" },
  151. { 0xFFFFF979, "(-1671) TIME RESTRICTION" },
  152. { 0xFFFFF978, "(-1672) SHORT TERM SECRET" },
  153. { 0xFFFFF977, "(-1673) NO NMAS ON TREE" },
  154. { 0xFFFFF976, "(-1674) NO NMAS ON SERVER" },
  155. { 0xFFFFF975, "(-1675) REQUEST CHALLENGED" },
  156. { 0xFFFFF974, "(-1676) LOGIN CANCELED" },
  157. { 0xFFFFF973, "(-1677) LOCAL CREDENTIAL STORE" },
  158. { 0xFFFFF972, "(-1678) REMOTE CREDENTIAL STORE" },
  159. { 0xFFFFF971, "(-1679) SMC NICM" },
  160. { 0xFFFFF970, "(-1680) SEQUENCE NOT AUTHORIZED" },
  161. { 0xFFFFF96F, "(-1681) TRANSPORT" },
  162. { 0xFFFFF96E, "(-1682) CRYPTO FAILED INIT" },
  163. { 0xFFFFF96D, "(-1683) DOUBLEBYTE FAILED INIT" },
  164. { 0xFFFFF96C, "(-1684) CODEPAGE FAILED INIT" },
  165. { 0xFFFFF96B, "(-1685) UNICODE FAILED INIT" },
  166. { 0xFFFFF96A, "(-1686) DLL FAILED LOADING" },
  167. { 0xFFFFF969, "(-1687) EVALUATION VERSION WARNING" },
  168. { 0xFFFFF968, "(-1688) CONCURRENT LOGIN" },
  169. { 0xFFFFF969, "(-1689) THREAD CREATE" },
  170. { 0xFFFFF96A, "(-1690) SECURE CHANNEL REQUIRED" },
  171. { 0xFFFFF96B, "(-1691) NO DEFAULT USER SEQUENCE" },
  172. { 0xFFFFF96C, "(-1692) NO TREENAME" },
  173. { 0xFFFFF96D, "(-1693) MECHANISM NOT FOUND" },
  174. { 0, NULL }
  175. };
  176. #if 0
  177. static int
  178. align_4(tvbuff_t *tvb, int aoffset)
  179. {
  180. if (tvb_length_remaining(tvb, aoffset) > 4 ) {
  181. return (aoffset%4);
  182. }
  183. return 0;
  184. }
  185. #endif
  186. static int
  187. nmas_string(tvbuff_t* tvb, int hfinfo, proto_tree *nmas_tree, int offset, gboolean little)
  188. {
  189. int foffset = offset;
  190. guint32 str_length;
  191. char *buffer;
  192. guint32 i;
  193. guint16 c_char;
  194. guint32 length_remaining = 0;
  195. buffer = (char *)ep_alloc(ITEM_LABEL_LENGTH+1);
  196. if (little) {
  197. str_length = tvb_get_letohl(tvb, foffset);
  198. } else {
  199. str_length = tvb_get_ntohl(tvb, foffset);
  200. }
  201. foffset += 4;
  202. if (str_length >= ITEM_LABEL_LENGTH) {
  203. proto_tree_add_string(nmas_tree, hfinfo, tvb, foffset,
  204. length_remaining + 4, "<String too long to process>");
  205. foffset += length_remaining;
  206. return foffset;
  207. }
  208. if (str_length == 0) {
  209. proto_tree_add_string(nmas_tree, hfinfo, tvb, offset, 4,
  210. "<Not Specified>");
  211. return foffset;
  212. }
  213. /*
  214. * XXX - other than the special-casing of null bytes,
  215. * we could just use "proto_tree_add_item()", as for
  216. * FT_STRING, FT_STRINGZ, and FT_UINT_STRING fields,
  217. * the display representation of an item is generated
  218. * using "format_text()", so it handles non-printable
  219. * characters.
  220. */
  221. for ( i = 0; i < str_length; i++ ) {
  222. c_char = tvb_get_guint8(tvb, foffset );
  223. if (c_char<0x20 || c_char>0x7e) {
  224. if (c_char != 0x00) {
  225. c_char = 0x2e;
  226. buffer[i] = c_char & 0xff;
  227. } else {
  228. i--;
  229. str_length--;
  230. }
  231. } else {
  232. buffer[i] = c_char & 0xff;
  233. }
  234. foffset++;
  235. length_remaining--;
  236. if (length_remaining==1) {
  237. i++;
  238. break;
  239. }
  240. }
  241. buffer[i] = '\0';
  242. if (little) {
  243. str_length = tvb_get_letohl(tvb, offset);
  244. } else {
  245. str_length = tvb_get_ntohl(tvb, offset);
  246. }
  247. proto_tree_add_string(nmas_tree, hfinfo, tvb, offset+4, str_length, buffer);
  248. return foffset;
  249. }
  250. void
  251. dissect_nmas_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, ncp_req_hash_value *request_value)
  252. {
  253. guint8 /*func,*/ subfunc;
  254. guint32 msg_length=0, cur_string_len=0;
  255. guint32 foffset;
  256. guint32 subverb=0;
  257. guint32 attribute=0;
  258. guint8 msgverb=0;
  259. proto_tree *atree;
  260. proto_item *aitem;
  261. foffset = 6;
  262. /*func = tvb_get_guint8(tvb, foffset);*/
  263. foffset += 1;
  264. subfunc = tvb_get_guint8(tvb, foffset);
  265. foffset += 1;
  266. /* Fill in the INFO column. */
  267. col_set_str(pinfo->cinfo, COL_PROTOCOL, "NMAS");
  268. col_add_fstr(pinfo->cinfo, COL_INFO, "C NMAS - %s",
  269. val_to_str(subfunc, nmas_func_enum, "Unknown (0x%02x)"));
  270. aitem = proto_tree_add_text(ncp_tree, tvb, foffset, -1, "Packet Type: %s",
  271. val_to_str(subfunc, nmas_func_enum, "Unknown (0x%02x)"));
  272. atree = proto_item_add_subtree(aitem, ett_nmas);
  273. switch (subfunc) {
  274. case 1:
  275. proto_tree_add_item(atree, hf_ping_version, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  276. foffset += 4;
  277. proto_tree_add_item(atree, hf_ping_flags, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  278. foffset += 4;
  279. break;
  280. case 2:
  281. proto_tree_add_item(atree, hf_frag_handle, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  282. /* Check for Fragment packet */
  283. if (tvb_get_letohl(tvb, foffset)!=0xffffffff) {
  284. break;
  285. }
  286. foffset += 4;
  287. foffset += 4; /* Dont know what this is */
  288. proto_tree_add_item(atree, hf_length, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  289. msg_length = tvb_get_letohl(tvb, foffset);
  290. foffset += 4;
  291. foffset += 12;
  292. msg_length -= 16;
  293. proto_tree_add_item(atree, hf_subverb, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  294. subverb = tvb_get_letohl(tvb, foffset);
  295. if (request_value) {
  296. request_value->req_nds_flags=subverb; /* Store the NMAS fragment verb */
  297. }
  298. foffset += 4;
  299. msg_length -= 4;
  300. col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
  301. val_to_str(subverb, nmas_subverb_enum, "Unknown subverb (%u)"));
  302. switch (subverb) {
  303. case 0: /* Fragmented Ping */
  304. proto_tree_add_item(atree, hf_ping_version, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  305. foffset += 4;
  306. proto_tree_add_item(atree, hf_ping_flags, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  307. foffset += 4;
  308. break;
  309. case 2: /* Client Put Data */
  310. proto_tree_add_item(atree, hf_opaque, tvb, foffset, msg_length, ENC_NA);
  311. foffset += msg_length;
  312. break;
  313. case 4: /* Client Get Data */
  314. case 6: /* Client Get User NDS Credentials */
  315. /* No Op */
  316. break;
  317. case 8: /* Login Store Management */
  318. proto_tree_add_item(atree, hf_reply_buffer_size, tvb, foffset, 1, ENC_LITTLE_ENDIAN);
  319. foffset += 4;
  320. msgverb = tvb_get_guint8(tvb, foffset);
  321. if (request_value) {
  322. request_value->nds_request_verb=msgverb; /* Use nds_request_verb for passed subverb */
  323. }
  324. proto_tree_add_item(atree, hf_lsm_verb, tvb, foffset, 1, ENC_LITTLE_ENDIAN);
  325. foffset += 4;
  326. col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
  327. val_to_str(msgverb, nmas_lsmverb_enum, "Unknown (%u)"));
  328. switch (msgverb) {
  329. case 1:
  330. break;
  331. case 2:
  332. break;
  333. case 4:
  334. break;
  335. case 5:
  336. break;
  337. case 6:
  338. break;
  339. default:
  340. break;
  341. }
  342. break;
  343. case 10: /* Writable Object Check */
  344. /* The first GUINT32 value is the len of the header? */
  345. foffset += 4;
  346. /* The next two GUINT32 values are reserved and always 0 */
  347. foffset += 8;
  348. foffset = nmas_string(tvb, hf_tree, atree, foffset, TRUE);
  349. foffset = nmas_string(tvb, hf_user, atree, foffset, TRUE);
  350. break;
  351. case 1242: /* Message Handler */
  352. foffset += 4;
  353. proto_tree_add_item(atree, hf_msg_version, tvb, foffset, 4, ENC_BIG_ENDIAN);
  354. foffset += 4;
  355. proto_tree_add_item(atree, hf_session_ident, tvb, foffset, 4, ENC_BIG_ENDIAN);
  356. foffset += 4;
  357. foffset += 3;
  358. msgverb = tvb_get_guint8(tvb, foffset);
  359. if (request_value) {
  360. request_value->nds_request_verb=msgverb; /* Use nds_request_verb for passed verb */
  361. }
  362. proto_tree_add_item(atree, hf_msg_verb, tvb, foffset, 1, ENC_BIG_ENDIAN);
  363. foffset += 1;
  364. msg_length -= 12;
  365. col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
  366. val_to_str(msgverb, nmas_msgverb_enum, "Unknown (%u)"));
  367. switch(msgverb) {
  368. case 1:
  369. msg_length = tvb_get_ntohl(tvb, foffset);
  370. proto_tree_add_item(atree, hf_length, tvb, foffset, 4, ENC_BIG_ENDIAN);
  371. foffset += 4;
  372. proto_tree_add_item(atree, hf_data, tvb, foffset, msg_length, ENC_NA);
  373. foffset += msg_length;
  374. break;
  375. case 3:
  376. msg_length = tvb_get_ntohl(tvb, foffset);
  377. msg_length -= 4;
  378. proto_tree_add_item(atree, hf_length, tvb, foffset, 4, ENC_BIG_ENDIAN);
  379. foffset += 4;
  380. while (msg_length > 0) {
  381. attribute = tvb_get_ntohl(tvb, foffset);
  382. foffset += 4;
  383. cur_string_len=tvb_get_ntohl(tvb, foffset);
  384. switch (attribute) {
  385. case 1:
  386. foffset = nmas_string(tvb, hf_user, atree, foffset, FALSE);
  387. break;
  388. case 2:
  389. foffset = nmas_string(tvb, hf_tree, atree, foffset, FALSE);
  390. break;
  391. case 4:
  392. foffset = nmas_string(tvb, hf_clearance, atree, foffset, FALSE);
  393. break;
  394. case 11:
  395. foffset = nmas_string(tvb, hf_login_sequence, atree, foffset, FALSE);
  396. break;
  397. default:
  398. break;
  399. }
  400. msg_length -= cur_string_len;
  401. if (tvb_reported_length_remaining(tvb, foffset)<5) {
  402. break;
  403. }
  404. }
  405. break;
  406. case 5:
  407. proto_tree_add_item(atree, hf_opaque, tvb, foffset,
  408. tvb_reported_length_remaining(tvb, foffset), ENC_NA);
  409. foffset += msg_length;
  410. break;
  411. case 7:
  412. case 9:
  413. /* No Op */
  414. break;
  415. default:
  416. break;
  417. }
  418. break;
  419. default:
  420. break;
  421. }
  422. break;
  423. case 3:
  424. /* No Op */
  425. break;
  426. default:
  427. break;
  428. }
  429. }
  430. void
  431. dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guint8 func _U_, guint8 subfunc, ncp_req_hash_value *request_value)
  432. {
  433. guint32 foffset=0, roffset=0;
  434. guint32 subverb=0;
  435. guint8 msgverb=0;
  436. guint32 msg_length=0;
  437. guint32 return_code=0, encrypt_error=0;
  438. proto_tree *atree;
  439. proto_item *aitem;
  440. proto_item *expert_item;
  441. const gchar *str;
  442. foffset = 8;
  443. if (request_value) {
  444. subverb = request_value->req_nds_flags;
  445. msgverb = request_value->nds_request_verb;
  446. }
  447. col_set_str(pinfo->cinfo, COL_PROTOCOL, "NMAS");
  448. if (tvb_reported_length_remaining(tvb, foffset)<4) {
  449. return;
  450. }
  451. aitem = proto_tree_add_text(ncp_tree, tvb, foffset, -1, "Packet Type: %s",
  452. val_to_str(subfunc, nmas_func_enum, "Unknown (0x%02x)"));
  453. atree = proto_item_add_subtree(aitem, ett_nmas);
  454. switch (subfunc) {
  455. case 1:
  456. proto_tree_add_item(atree, hf_ping_flags, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  457. foffset += 4;
  458. proto_tree_add_item(atree, hf_nmas_version, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  459. foffset += 4;
  460. break;
  461. case 2:
  462. proto_tree_add_text(atree, tvb, foffset, -1, "Verb: %s",
  463. val_to_str(subverb, nmas_subverb_enum, "Unknown (%u)"));
  464. proto_tree_add_item(atree, hf_length, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  465. msg_length = tvb_get_letohl(tvb, foffset);
  466. foffset +=4;
  467. proto_tree_add_item(atree, hf_frag_handle, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  468. /* Check for a fragment packet */
  469. if (tvb_get_letohl(tvb, foffset)!=0xffffffff) {
  470. break;
  471. }
  472. foffset += 4;
  473. return_code = tvb_get_letohl(tvb, foffset);
  474. roffset = foffset;
  475. foffset += 4;
  476. msg_length -= 8;
  477. if (return_code == 0 && msg_length > 0) {
  478. switch (subverb) {
  479. case 0: /* Fragmented Ping */
  480. proto_tree_add_item(atree, hf_session_ident, tvb, foffset, 4, ENC_BIG_ENDIAN);
  481. foffset += 4;
  482. /*proto_tree_add_item(atree, hf_nmas_version, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  483. foffset += 4;*/
  484. break;
  485. case 2: /* Client Put Data */
  486. proto_tree_add_item(atree, hf_squeue_bytes, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  487. foffset += 4;
  488. proto_tree_add_item(atree, hf_cqueue_bytes, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  489. foffset += 4;
  490. break;
  491. case 4: /* Client Get Data */
  492. proto_tree_add_item(atree, hf_opaque, tvb, foffset, msg_length, ENC_NA);
  493. foffset += msg_length;
  494. break;
  495. case 6: /* Client Get User NDS Credentials */
  496. proto_tree_add_item(atree, hf_num_creds, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  497. foffset += 4;
  498. proto_tree_add_item(atree, hf_cred_type, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  499. foffset += 4;
  500. proto_tree_add_item(atree, hf_login_state, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  501. foffset += 4;
  502. msg_length -= 12;
  503. proto_tree_add_item(atree, hf_enc_cred, tvb, foffset, msg_length, ENC_NA);
  504. foffset += msg_length;
  505. break;
  506. case 8: /* Login Store Management */
  507. proto_tree_add_text(atree, tvb, foffset, -1, "Subverb: %s",
  508. val_to_str(msgverb, nmas_lsmverb_enum, "Unknown (%u)"));
  509. switch(msgverb) {
  510. /* The data within these structures is all encrypted. */
  511. case 1:
  512. case 3:
  513. case 5:
  514. case 7:
  515. case 9:
  516. proto_tree_add_item(atree, hf_enc_data, tvb, foffset, msg_length, ENC_NA);
  517. foffset += msg_length;
  518. break;
  519. default:
  520. break;
  521. }
  522. break;
  523. case 10: /* Writable Object Check */
  524. proto_tree_add_item(atree, hf_nmas_version, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
  525. foffset += 4;
  526. break;
  527. case 1242: /* Message Handler */
  528. proto_tree_add_text(atree, tvb, foffset, -1, "Subverb: %s",
  529. val_to_str(msgverb, nmas_msgverb_enum, "Unknown (%u)"));
  530. switch(msgverb) {
  531. case 1:
  532. msg_length = tvb_get_ntohl(tvb, foffset);
  533. proto_tree_add_item(atree, hf_length, tvb, foffset, 4, ENC_BIG_ENDIAN);
  534. foffset += 4;
  535. proto_tree_add_item(atree, hf_data, tvb, foffset, msg_length, ENC_NA);
  536. foffset += msg_length;
  537. break;
  538. case 3:
  539. proto_tree_add_item(atree, hf_session_ident, tvb, foffset, 4, ENC_BIG_ENDIAN);
  540. foffset += 4;
  541. break;
  542. case 5:
  543. /* No Op */
  544. break;
  545. case 7:
  546. encrypt_error = tvb_get_ntohl(tvb, foffset);
  547. str = try_val_to_str(encrypt_error, nmas_errors_enum);
  548. if (str) {
  549. col_add_fstr(pinfo->cinfo, COL_INFO, "R Payload Error - %s", str);
  550. expert_item = proto_tree_add_item(atree, hf_encrypt_error, tvb, foffset, 4, ENC_BIG_ENDIAN);
  551. expert_add_info_format_text(pinfo, expert_item, &ei_encrypt_error, "NMAS Payload Error: %s", str);
  552. } else {
  553. proto_tree_add_item(atree, hf_opaque, tvb, foffset, msg_length, ENC_NA);
  554. }
  555. foffset += msg_length;
  556. break;
  557. case 9:
  558. /* No Op */
  559. break;
  560. default:
  561. break;
  562. }
  563. break;
  564. default:
  565. break;
  566. }
  567. }
  568. str = try_val_to_str(return_code, nmas_errors_enum);
  569. if (str) {
  570. expert_item = proto_tree_add_item(atree, hf_return_code, tvb, roffset, 4, ENC_LITTLE_ENDIAN);
  571. expert_add_info_format_text(pinfo, expert_item, &ei_return_error, "NMAS Error: 0x%08x %s", return_code, str);
  572. col_add_fstr(pinfo->cinfo, COL_INFO, "R Error - %s", str);
  573. } else {
  574. if (return_code!=0) {
  575. expert_item = proto_tree_add_item(atree, hf_return_code, tvb, roffset, 4, ENC_LITTLE_ENDIAN);
  576. expert_add_info_format_text(pinfo, expert_item, &ei_return_error, "NMAS Error: 0x%08x is unknown", return_code);
  577. col_add_fstr(pinfo->cinfo, COL_INFO, "R Unknown NMAS Error - 0x%08x", return_code);
  578. }
  579. }
  580. if (return_code == 0) {
  581. proto_tree_add_text(atree, tvb, roffset, 4, "Return Code: Success (0x00000000)");
  582. }
  583. break;
  584. case 3:
  585. break;
  586. default:
  587. break;
  588. }
  589. }
  590. void
  591. proto_register_nmas(void)
  592. {
  593. static hf_register_info hf_nmas[] = {
  594. #if 0
  595. { &hf_func,
  596. { "Function", "nmas.func",
  597. FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
  598. #endif
  599. #if 0
  600. { &hf_subfunc,
  601. { "Subfunction", "nmas.subfunc",
  602. FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
  603. #endif
  604. { &hf_ping_version,
  605. { "Ping Version", "nmas.ping_version",
  606. FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
  607. { &hf_ping_flags,
  608. { "Flags", "nmas.ping_flags",
  609. FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
  610. { &hf_frag_handle,
  611. { "Fragment Handle", "nmas.frag_handle",
  612. FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
  613. { &hf_length,
  614. { "Length", "nmas.length",
  615. FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
  616. { &hf_subverb,
  617. { "Sub Verb", "nmas.subverb",
  618. FT_UINT32, BASE_HEX, VALS(nmas_subverb_enum), 0x0, NULL, HFILL }},
  619. { &hf_tree,
  620. { "Tree", "nmas.tree",
  621. FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
  622. { &hf_user,
  623. { "User", "nmas.user",
  624. FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
  625. { &hf_nmas_version,
  626. { "NMAS Protocol Version", "nmas.version",
  627. FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
  628. { &hf_msg_version,
  629. { "Message Version", "nmas.msg_version",
  630. FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
  631. { &hf_session_ident,
  632. { "Session Identifier", "nmas.session_ident",
  633. FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
  634. { &hf_msg_verb,
  635. { "Message Verb", "nmas.msg_verb",
  636. FT_UINT8, BASE_HEX, VALS(nmas_msgverb_enum), 0x0, NULL, HFILL }},
  637. #if 0
  638. { &hf_attribute,
  639. { "Attribute Type", "nmas.attribute",
  640. FT_UINT32, BASE_DEC, VALS(nmas_attribute_enum), 0x0, NULL, HFILL }},
  641. #endif
  642. { &hf_clearance,
  643. { "Requested Clearance", "nmas.clearance",
  644. FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
  645. { &hf_login_sequence,
  646. { "Requested Login Sequence", "nmas.login_seq",
  647. FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
  648. { &hf_opaque,
  649. { "Opaque Data", "nmas.opaque",
  650. FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
  651. { &hf_data,
  652. { "Data", "nmas.data",
  653. FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
  654. { &hf_return_code,
  655. { "Return Code", "nmas.return_code",
  656. FT_UINT32, BASE_HEX, VALS(nmas_errors_enum), 0x0, NULL, HFILL }},
  657. { &hf_lsm_verb,
  658. { "Login Store Message Verb", "nmas.lsm_verb",
  659. FT_UINT8, BASE_HEX, VALS(nmas_lsmverb_enum), 0x0, NULL, HFILL }},
  660. { &hf_squeue_bytes,
  661. { "Server Queue Number of Bytes", "nmas.squeue_bytes",
  662. FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
  663. { &hf_cqueue_bytes,
  664. { "Client Queue Number of Bytes", "nmas.cqueue_bytes",
  665. FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
  666. { &hf_num_creds,
  667. { "Number of Credentials", "nmas.num_creds",
  668. FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
  669. { &hf_cred_type,
  670. { "Credential Type", "nmas.cred_type",
  671. FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
  672. { &hf_login_state,
  673. { "Login State", "nmas.login_state",
  674. FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
  675. { &hf_enc_cred,
  676. { "Encrypted Credential", "nmas.enc_cred",
  677. FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
  678. { &hf_enc_data,
  679. { "Encrypted Data", "nmas.enc_data",
  680. FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
  681. { &hf_reply_buffer_size,
  682. { "Reply Buffer Size", "nmas.buf_size",
  683. FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
  684. { &hf_encrypt_error,
  685. { "Payload Error", "nmas.encrypt_error",
  686. FT_UINT32, BASE_HEX, VALS(nmas_errors_enum), 0x0,
  687. "Payload/Encryption Return Code", HFILL }}
  688. };
  689. static gint *ett[] = {
  690. &ett_nmas
  691. };
  692. static ei_register_info ei[] = {
  693. { &ei_encrypt_error, { "nmas.encrypt_error.expert", PI_RESPONSE_CODE, PI_NOTE, "NMAS Payload Erro", EXPFILL }},
  694. { &ei_return_error, { "nmas.return_code.expert", PI_RESPONSE_CODE, PI_NOTE, "NMAS Error", EXPFILL }},
  695. };
  696. expert_module_t* expert_nmas;
  697. proto_nmas = proto_register_protocol("Novell Modular Authentication Service", "NMAS", "nmas");
  698. proto_register_field_array(proto_nmas, hf_nmas, array_length(hf_nmas));
  699. proto_register_subtree_array(ett, array_length(ett));
  700. expert_nmas = expert_register_protocol(proto_nmas);
  701. expert_register_field_array(expert_nmas, ei, array_length(ei));
  702. }
  703. /*
  704. * Editor modelines - http://www.wireshark.org/tools/modelines.html
  705. *
  706. * Local variables:
  707. * c-basic-offset: 4
  708. * tab-width: 4
  709. * indent-tabs-mode: nil
  710. * End:
  711. *
  712. * vi: set shiftwidth=4 tabstop=4 expandtab:
  713. * :indentSize=4:tabSize=4:noTabs=true:
  714. */