2 * Routines for the COPS (Common Open Policy Service) protocol dissection
3 * RFC2748 & COPS-PR extension RFC3084
5 * Copyright 2000, Heikki Vatiainen <hessu@cs.tut.fi>
7 * $Id: packet-cops.c,v 1.33 2003/02/21 00:11:31 guy Exp $
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@ethereal.com>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 #include <epan/packet.h>
39 #include "packet-ipv6.h"
40 #include "packet-tcp.h"
43 #include "format-oid.h"
46 #define TCP_PORT_COPS 3288
48 /* Variable to hold the tcp port preference */
49 static guint global_cops_tcp_port = TCP_PORT_COPS;
51 /* desegmentation of COPS */
52 static gboolean cops_desegment = TRUE;
54 /* Variable to allow for proper deletion of dissector registration
55 * when the user changes port from the gui
58 static guint cops_tcp_port = 0;
60 static gchar *last_decoded_prid=NULL;
62 #define COPS_OBJECT_HDR_SIZE 4
64 /* Null string of type "guchar[]". */
65 static const guchar nullstring[] = "";
67 #define SAFE_STRING(s) (((s) != NULL) ? (s) : nullstring)
71 #define COPS_IPA 0 /* IP Address */
72 #define COPS_U32 2 /* Unsigned 32*/
73 #define COPS_TIT 3 /* TimeTicks */
74 #define COPS_OPQ 4 /* Opaque */
75 #define COPS_I64 10 /* Integer64 */
76 #define COPS_U64 11 /* Uinteger64 */
81 #define COPS_INTEGER 1 /* l */
82 #define COPS_OCTETSTR 2 /* c */
83 #define COPS_OBJECTID 3 /* ul */
84 #define COPS_IPADDR 4 /* uc */
85 #define COPS_UNSIGNED32 5 /* ul */
86 #define COPS_TIMETICKS 7 /* ul */
87 #define COPS_OPAQUE 8 /* c */
88 #define COPS_INTEGER64 10 /* ll */
89 #define COPS_UNSIGNED64 11 /* ull */
92 typedef struct _COPS_CNV COPS_CNV;
102 static COPS_CNV CopsCnv [] =
104 {ASN1_UNI, ASN1_NUL, COPS_NULL, "NULL"},
105 {ASN1_UNI, ASN1_INT, COPS_INTEGER, "INTEGER"},
106 {ASN1_UNI, ASN1_OTS, COPS_OCTETSTR, "OCTET STRING"},
107 {ASN1_UNI, ASN1_OJI, COPS_OBJECTID, "OBJECTID"},
108 {ASN1_APL, COPS_IPA, COPS_IPADDR, "IPADDR"},
109 {ASN1_APL, COPS_U32, COPS_UNSIGNED32,"UNSIGNED32"},
110 {ASN1_APL, COPS_TIT, COPS_TIMETICKS, "TIMETICKS"},
111 {ASN1_APL, COPS_OPQ, COPS_OPAQUE, "OPAQUE"},
112 {ASN1_APL, COPS_I64, COPS_INTEGER64, "INTEGER64"},
113 {ASN1_APL, COPS_U64, COPS_UNSIGNED64, "UNSIGNED64"},
118 cops_tag_cls2syntax ( guint tag, guint cls, gushort *syntax)
123 while (cnv->syntax != -1)
125 if (cnv->tag == tag && cnv->class == cls)
127 *syntax = cnv->syntax;
135 static const value_string cops_flags_vals[] = {
137 { 0x01, "Solicited Message Flag Bit" },
141 /* The different COPS message types */
143 COPS_NO_MSG, /* Not a COPS Message type */
145 COPS_MSG_REQ, /* Request (REQ) */
146 COPS_MSG_DEC, /* Decision (DEC) */
147 COPS_MSG_RPT, /* Report State (RPT) */
148 COPS_MSG_DRQ, /* Delete Request State (DRQ) */
149 COPS_MSG_SSQ, /* Synchronize State Req (SSQ) */
150 COPS_MSG_OPN, /* Client-Open (OPN) */
151 COPS_MSG_CAT, /* Client-Accept (CAT) */
152 COPS_MSG_CC, /* Client-Close (CC) */
153 COPS_MSG_KA, /* Keep-Alive (KA) */
154 COPS_MSG_SSC, /* Synchronize Complete (SSC) */
156 COPS_LAST_OP_CODE /* For error checking */
159 static const value_string cops_op_code_vals[] = {
160 { COPS_MSG_REQ, "Request (REQ)" },
161 { COPS_MSG_DEC, "Decision (DEC)" },
162 { COPS_MSG_RPT, "Report State (RPT)" },
163 { COPS_MSG_DRQ, "Delete Request State (DRQ)" },
164 { COPS_MSG_SSQ, "Synchronize State Req (SSQ)" },
165 { COPS_MSG_OPN, "Client-Open (OPN)" },
166 { COPS_MSG_CAT, "Client-Accept (CAT)" },
167 { COPS_MSG_CC, "Client-Close (CC)" },
168 { COPS_MSG_KA, "Keep-Alive (KA)" },
169 { COPS_MSG_SSC, "Synchronize Complete (SSC)" },
174 /* The different objects in COPS messages */
176 COPS_NO_OBJECT, /* Not a COPS Object type */
178 COPS_OBJ_HANDLE, /* Handle Object (Handle) */
179 COPS_OBJ_CONTEXT, /* Context Object (Context) */
180 COPS_OBJ_IN_INT, /* In-Interface Object (IN-Int) */
181 COPS_OBJ_OUT_INT, /* Out-Interface Object (OUT-Int) */
182 COPS_OBJ_REASON, /* Reason Object (Reason) */
183 COPS_OBJ_DECISION, /* Decision Object (Decision) */
184 COPS_OBJ_LPDPDECISION, /* LPDP Decision Object (LPDPDecision) */
185 COPS_OBJ_ERROR, /* Error Object (Error) */
186 COPS_OBJ_CLIENTSI, /* Client Specific Information Object (ClientSI) */
187 COPS_OBJ_KATIMER, /* Keep-Alive Timer Object (KATimer) */
188 COPS_OBJ_PEPID, /* PEP Identification Object (PEPID) */
189 COPS_OBJ_REPORT_TYPE, /* Report-Type Object (Report-Type) */
190 COPS_OBJ_PDPREDIRADDR, /* PDP Redirect Address Object (PDPRedirAddr) */
191 COPS_OBJ_LASTPDPADDR, /* Last PDP Address (LastPDPaddr) */
192 COPS_OBJ_ACCTTIMER, /* Accounting Timer Object (AcctTimer) */
193 COPS_OBJ_INTEGRITY, /* Message Integrity Object (Integrity) */
194 COPS_LAST_C_NUM /* For error checking */
197 static const value_string cops_c_num_vals[] = {
198 { COPS_OBJ_HANDLE, "Handle Object (Handle)" },
199 { COPS_OBJ_CONTEXT, "Context Object (Context)" },
200 { COPS_OBJ_IN_INT, "In-Interface Object (IN-Int)" },
201 { COPS_OBJ_OUT_INT, "Out-Interface Object (OUT-Int)" },
202 { COPS_OBJ_REASON, "Reason Object (Reason)" },
203 { COPS_OBJ_DECISION, "Decision Object (Decision)" },
204 { COPS_OBJ_LPDPDECISION, "LPDP Decision Object (LPDPDecision)" },
205 { COPS_OBJ_ERROR, "Error Object (Error)" },
206 { COPS_OBJ_CLIENTSI, "Client Specific Information Object (ClientSI)" },
207 { COPS_OBJ_KATIMER, "Keep-Alive Timer Object (KATimer)" },
208 { COPS_OBJ_PEPID, "PEP Identification Object (PEPID)" },
209 { COPS_OBJ_REPORT_TYPE, "Report-Type Object (Report-Type)" },
210 { COPS_OBJ_PDPREDIRADDR, "PDP Redirect Address Object (PDPRedirAddr)" },
211 { COPS_OBJ_LASTPDPADDR, "Last PDP Address (LastPDPaddr)" },
212 { COPS_OBJ_ACCTTIMER, "Accounting Timer Object (AcctTimer)" },
213 { COPS_OBJ_INTEGRITY, "Message Integrity Object (Integrity)" },
218 /* The different objects in COPS-PR messages */
220 COPS_NO_PR_OBJECT, /* Not a COPS-PR Object type */
221 COPS_OBJ_PRID, /* Provisioning Instance Identifier (PRID) */
222 COPS_OBJ_PPRID, /* Prefix Provisioning Instance Identifier (PPRID) */
223 COPS_OBJ_EPD, /* Encoded Provisioning Instance Data (EPD) */
224 COPS_OBJ_GPERR, /* Global Provisioning Error Object (GPERR) */
225 COPS_OBJ_CPERR, /* PRC Class Provisioning Error Object (CPERR) */
226 COPS_OBJ_ERRPRID, /* Error Provisioning Instance Identifier (ErrorPRID)*/
228 COPS_LAST_S_NUM /* For error checking */
232 static const value_string cops_s_num_vals[] = {
233 { COPS_OBJ_PRID, "Provisioning Instance Identifier (PRID)" },
234 { COPS_OBJ_PPRID, "Prefix Provisioning Instance Identifier (PPRID)" },
235 { COPS_OBJ_EPD, "Encoded Provisioning Instance Data (EPD)" },
236 { COPS_OBJ_GPERR, "Global Provisioning Error Object (GPERR)" },
237 { COPS_OBJ_CPERR, "PRC Class Provisioning Error Object (CPERR)" },
238 { COPS_OBJ_ERRPRID, "Error Provisioning Instance Identifier (ErrorPRID)" },
243 /* R-Type is carried within the Context Object */
244 static const value_string cops_r_type_vals[] = {
245 { 0x01, "Incoming-Message/Admission Control request" },
246 { 0x02, "Resource-Allocation request" },
247 { 0x04, "Outgoing-Message request" },
248 { 0x08, "Configuration request" },
251 /* S-Type is carried within the ClientSI Object for COPS-PR*/
252 static const value_string cops_s_type_vals[] = {
257 /* Reason-Code is carried within the Reason object */
258 static const value_string cops_reason_vals[] = {
259 { 1, "Unspecified" },
261 { 3, "Preempted (Another request state takes precedence)" },
262 { 4, "Tear (Used to communicate a signaled state removal)" },
263 { 5, "Timeout (Local state has timed-out)" },
264 { 6, "Route Change (Change invalidates request state)" },
265 { 7, "Insufficient Resources (No local resource available)" },
266 { 8, "PDP's Directive (PDP decision caused the delete)" },
267 { 9, "Unsupported decision (PDP decision not supported)" },
268 { 10, "Synchronize Handle Unknown" },
269 { 11, "Transient Handle (stateless event)" },
270 { 12, "Malformed Decision (could not recover)" },
271 { 13, "Unknown COPS Object from PDP" },
275 /* Command-Code is carried within the Decision object if C-Type is 1 */
276 static const value_string cops_dec_cmd_code_vals[] = {
277 { 0, "NULL Decision (No configuration data available)" },
278 { 1, "Install (Admit request/Install configuration)" },
279 { 2, "Remove (Remove request/Remove configuration)" },
283 /* Decision flags are also carried with the Decision object if C-Type is 1 */
284 static const value_string cops_dec_cmd_flag_vals[] = {
285 { 0x00, "<None set>" },
286 { 0x01, "Trigger Error (Trigger error message if set)" },
290 /* Error-Code from Error object */
291 static const value_string cops_error_vals[] = {
293 {2, "Invalid handle reference" },
294 {3, "Bad message format (Malformed Message)" },
295 {4, "Unable to process (server gives up on query)" },
296 {5, "Mandatory client-specific info missing" },
297 {6, "Unsupported client" },
298 {7, "Mandatory COPS object missing" },
299 {8, "Client Failure" },
300 {9, "Communication Failure" },
301 {10, "Unspecified" },
302 {11, "Shutting down" },
303 {12, "Redirect to Preferred Server" },
304 {13, "Unknown COPS Object" },
305 {14, "Authentication Failure" },
306 {15, "Authentication Required" },
309 /* Error-Code from GPERR object */
310 static const value_string cops_gperror_vals[] = {
312 {2, "AvailMemExhausted" },
313 {3, "unknownASN.1Tag" },
314 {4, "maxMsgSizeExceeded" },
315 {5, "unknownError" },
316 {6, "maxRequestStatesOpen" },
317 {7, "invalidASN.1Length" },
318 {8, "invalidObjectPad" },
319 {9, "unknownPIBData" },
320 {10, "unknownCOPSPRObject" },
321 {11, "malformedDecision" },
325 /* Error-Code from CPERR object */
326 static const value_string cops_cperror_vals[] = {
327 {1, "priSpaceExhausted" },
328 {2, "priInstanceInvalid" },
329 {3, "attrValueInvalid" },
330 {4, "attrValueSupLimited" },
331 {5, "attrEnumSupLimited" },
332 {6, "attrMaxLengthExceeded" },
333 {7, "attrReferenceUnknown" },
334 {8, "priNotifyOnly" },
336 {10, "tooFewAttrs" },
337 {11, "invalidAttrType" },
338 {12, "deletedInRef" },
339 {13, "priSpecificError" },
344 /* Report-Type from Report-Type object */
345 static const value_string cops_report_type_vals[] = {
346 {1, " Success : Decision was successful at the PEP" },
347 {2, " Failure : Decision could not be completed by PEP" },
348 {3, " Accounting: Accounting update for an installed state" },
352 /* Initialize the protocol and registered fields */
353 static gint proto_cops = -1;
354 static gint hf_cops_ver_flags = -1;
355 static gint hf_cops_version = -1;
356 static gint hf_cops_flags = -1;
358 static gint hf_cops_op_code = -1;
359 static gint hf_cops_client_type = -1;
360 static gint hf_cops_msg_len = -1;
362 static gint hf_cops_obj_len = -1;
363 static gint hf_cops_obj_c_num = -1;
364 static gint hf_cops_obj_c_type = -1;
366 static gint hf_cops_obj_s_num = -1;
367 static gint hf_cops_obj_s_type = -1;
369 static gint hf_cops_r_type_flags = -1;
370 static gint hf_cops_m_type_flags = -1;
372 static gint hf_cops_in_int_ipv4 = -1;
373 static gint hf_cops_in_int_ipv6 = -1;
374 static gint hf_cops_out_int_ipv4 = -1;
375 static gint hf_cops_out_int_ipv6 = -1;
376 static gint hf_cops_int_ifindex = -1;
378 static gint hf_cops_reason = -1;
379 static gint hf_cops_reason_sub = -1;
381 static gint hf_cops_dec_cmd_code = -1;
382 static gint hf_cops_dec_flags = -1;
384 static gint hf_cops_error = -1;
385 static gint hf_cops_error_sub = -1;
387 static gint hf_cops_gperror = -1;
388 static gint hf_cops_gperror_sub = -1;
390 static gint hf_cops_cperror = -1;
391 static gint hf_cops_cperror_sub = -1;
393 static gint hf_cops_katimer = -1;
395 static gint hf_cops_pepid = -1;
397 static gint hf_cops_report_type = -1;
399 static gint hf_cops_pdprediraddr_ipv4 = -1;
400 static gint hf_cops_pdprediraddr_ipv6 = -1;
401 static gint hf_cops_lastpdpaddr_ipv4 = -1;
402 static gint hf_cops_lastpdpaddr_ipv6 = -1;
403 static gint hf_cops_pdp_tcp_port = -1;
405 static gint hf_cops_accttimer = -1;
407 static gint hf_cops_key_id = -1;
408 static gint hf_cops_seq_num = -1;
410 /* Initialize the subtree pointers */
411 static gint ett_cops = -1;
412 static gint ett_cops_ver_flags = -1;
413 static gint ett_cops_obj = -1;
414 static gint ett_cops_pr_obj = -1;
415 static gint ett_cops_obj_data = -1;
416 static gint ett_cops_r_type_flags = -1;
417 static gint ett_cops_itf = -1;
418 static gint ett_cops_reason = -1;
419 static gint ett_cops_decision = -1;
420 static gint ett_cops_error = -1;
421 static gint ett_cops_clientsi = -1;
422 static gint ett_cops_asn1 = -1;
423 static gint ett_cops_gperror = -1;
424 static gint ett_cops_cperror = -1;
425 static gint ett_cops_pdp = -1;
427 void proto_reg_handoff_cops(void);
429 static guint get_cops_pdu_len(tvbuff_t *tvb, int offset);
430 static void dissect_cops_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
432 static int dissect_cops_object(tvbuff_t *tvb, guint32 offset, proto_tree *tree);
433 static void dissect_cops_object_data(tvbuff_t *tvb, guint32 offset, proto_tree *tree,
434 guint8 c_num, guint8 c_type, guint16 len);
436 static void dissect_cops_pr_objects(tvbuff_t *tvb, guint32 offset, proto_tree *tree, guint16 pr_len);
437 static int dissect_cops_pr_object_data(tvbuff_t *tvb, guint32 offset, proto_tree *tree,
438 guint8 s_num, guint8 s_type, guint16 len);
440 /* Code to actually dissect the packets */
442 dissect_cops(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
444 tcp_dissect_pdus(tvb, pinfo, tree, cops_desegment, 8,
445 get_cops_pdu_len, dissect_cops_pdu);
449 get_cops_pdu_len(tvbuff_t *tvb, int offset)
452 * Get the length of the COPS message.
454 return tvb_get_ntohl(tvb, offset + 4);
458 dissect_cops_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
463 if (check_col(pinfo->cinfo, COL_PROTOCOL))
464 col_set_str(pinfo->cinfo, COL_PROTOCOL, "COPS");
465 if (check_col(pinfo->cinfo, COL_INFO))
466 col_clear(pinfo->cinfo, COL_INFO);
468 op_code = tvb_get_guint8(tvb, 1);
469 if (check_col(pinfo->cinfo, COL_INFO))
470 col_add_fstr(pinfo->cinfo, COL_INFO, "COPS %s",
471 val_to_str(op_code, cops_op_code_vals, "Unknown Op Code"));
475 proto_tree *cops_tree, *ver_flags_tree;
481 ti = proto_tree_add_item(tree, proto_cops, tvb, offset, -1, FALSE);
482 cops_tree = proto_item_add_subtree(ti, ett_cops);
484 /* Version and flags share the same byte, put them in a subtree */
485 ver_flags = tvb_get_guint8(tvb, offset);
486 tv = proto_tree_add_uint_format(cops_tree, hf_cops_ver_flags, tvb, offset, 1,
487 ver_flags, "Version: %u, Flags: %s",
488 hi_nibble(ver_flags),
489 val_to_str(lo_nibble(ver_flags), cops_flags_vals, "Unknown"));
490 ver_flags_tree = proto_item_add_subtree(tv, ett_cops_ver_flags);
491 proto_tree_add_uint(ver_flags_tree, hf_cops_version, tvb, offset, 1, ver_flags);
492 proto_tree_add_uint(ver_flags_tree, hf_cops_flags, tvb, offset, 1, ver_flags);
495 proto_tree_add_item(cops_tree, hf_cops_op_code, tvb, offset, 1, FALSE);
497 proto_tree_add_item(cops_tree, hf_cops_client_type, tvb, offset, 2, FALSE);
500 msg_len = tvb_get_ntohl(tvb, offset);
501 proto_tree_add_uint(cops_tree, hf_cops_msg_len, tvb, offset, 4, msg_len);
504 while (tvb_reported_length_remaining(tvb, offset) >= COPS_OBJECT_HDR_SIZE) {
505 object_len = dissect_cops_object(tvb, offset, cops_tree);
508 offset += object_len;
511 garbage = tvb_length_remaining(tvb, offset);
513 proto_tree_add_text(cops_tree, tvb, offset, garbage,
514 "Trailing garbage: %d byte%s", garbage,
515 plurality(garbage, "", "s"));
519 static char *cops_c_type_to_str(guint8 c_num, guint8 c_type)
522 case COPS_OBJ_HANDLE:
524 return "Client Handle";
526 case COPS_OBJ_IN_INT:
527 case COPS_OBJ_OUT_INT:
529 return "IPv4 Address + Interface";
530 else if (c_type == 2)
531 return "IPv6 Address + Interface";
533 case COPS_OBJ_DECISION:
534 case COPS_OBJ_LPDPDECISION:
536 return "Decision Flags (Mandatory)";
537 else if (c_type == 2)
538 return "Stateless Data";
539 else if (c_type == 3)
540 return "Replacement Data";
541 else if (c_type == 4)
542 return "Client Specific Decision Data";
543 else if (c_type == 5)
544 return "Named Decision Data";
546 case COPS_OBJ_CLIENTSI:
548 return "Signaled ClientSI";
549 else if (c_type == 2)
550 return "Named ClientSI";
552 case COPS_OBJ_KATIMER:
554 return "Keep-alive timer value";
556 case COPS_OBJ_PDPREDIRADDR:
557 case COPS_OBJ_LASTPDPADDR:
559 return "IPv4 Address + TCP Port";
560 else if (c_type == 2)
561 return "IPv6 Address + TCP Port";
563 case COPS_OBJ_ACCTTIMER:
565 return "Accounting timer value";
567 case COPS_OBJ_INTEGRITY:
569 return "HMAC digest";
576 static int dissect_cops_object(tvbuff_t *tvb, guint32 offset, proto_tree *tree)
578 int object_len, contents_len;
579 guint8 c_num, c_type;
581 proto_tree *obj_tree;
584 object_len = tvb_get_ntohs(tvb, offset);
585 if (object_len < COPS_OBJECT_HDR_SIZE) {
587 proto_tree_add_text(tree, tvb, offset, 2,
588 "Bad COPS object length: %u, should be at least %u\n",
589 object_len, COPS_OBJECT_HDR_SIZE);
592 c_num = tvb_get_guint8(tvb, offset + 2);
593 c_type = tvb_get_guint8(tvb, offset + 3);
595 ti = proto_tree_add_uint_format(tree, hf_cops_obj_c_num, tvb, offset, object_len, c_num,
596 "%s: %s", val_to_str(c_num, cops_c_num_vals, "Unknown"),
597 cops_c_type_to_str(c_num, c_type));
598 obj_tree = proto_item_add_subtree(ti, ett_cops_obj);
600 proto_tree_add_uint(obj_tree, hf_cops_obj_len, tvb, offset, 2, object_len);
603 proto_tree_add_uint(obj_tree, hf_cops_obj_c_num, tvb, offset, 1, c_num);
606 type_str = cops_c_type_to_str(c_num, c_type);
607 proto_tree_add_text(obj_tree, tvb, offset, 1, "C-Type: %s%s%u%s",
609 strlen(type_str) ? " (" : "",
611 strlen(type_str) ? ")" : "");
614 contents_len = object_len - COPS_OBJECT_HDR_SIZE;
615 dissect_cops_object_data(tvb, offset, obj_tree, c_num, c_type, contents_len);
617 /* Pad to 32bit boundary */
618 if (object_len % sizeof (guint32))
619 object_len += (sizeof (guint32) - object_len % sizeof (guint32));
624 static void dissect_cops_pr_objects(tvbuff_t *tvb, guint32 offset, proto_tree *tree, guint16 pr_len)
626 int object_len, contents_len;
627 guint8 s_num, s_type;
630 proto_tree *cops_pr_tree, *obj_tree;
633 cops_pr_tree = proto_item_add_subtree(tree, ett_cops_pr_obj);
635 while (pr_len >= COPS_OBJECT_HDR_SIZE) {
636 object_len = tvb_get_ntohs(tvb, offset);
637 if (object_len < COPS_OBJECT_HDR_SIZE) {
639 proto_tree_add_text(tree, tvb, offset, 2,
640 "Bad COPS PR object length: %u, should be at least %u\n",
641 object_len, COPS_OBJECT_HDR_SIZE);
644 s_num = tvb_get_guint8(tvb, offset + 2);
646 ti = proto_tree_add_uint_format(cops_pr_tree, hf_cops_obj_s_num, tvb, offset, object_len, s_num,
647 "%s", val_to_str(s_num, cops_s_num_vals, "Unknown"));
648 obj_tree = proto_item_add_subtree(cops_pr_tree, ett_cops_pr_obj);
650 proto_tree_add_uint(obj_tree, hf_cops_obj_len, tvb, offset, 2, object_len);
654 proto_tree_add_uint(obj_tree, hf_cops_obj_s_num, tvb, offset, 1, s_num);
658 s_type = tvb_get_guint8(tvb, offset);
659 type_str = val_to_str(s_type, cops_s_type_vals, "Unknown");
660 proto_tree_add_text(obj_tree, tvb, offset, 1, "S-Type: %s%s%u%s",
662 strlen(type_str) ? " (" : "",
664 strlen(type_str) ? ")" : "");
668 contents_len = object_len - COPS_OBJECT_HDR_SIZE;
669 ret = dissect_cops_pr_object_data(tvb, offset, obj_tree, s_num, s_type, contents_len);
673 /*Pad to 32bit boundary */
674 if (object_len % sizeof (guint32))
675 object_len += (sizeof (guint32) - object_len % sizeof (guint32));
677 pr_len -= object_len - COPS_OBJECT_HDR_SIZE;
678 offset += object_len - COPS_OBJECT_HDR_SIZE;
682 static void dissect_cops_object_data(tvbuff_t *tvb, guint32 offset, proto_tree *tree,
683 guint8 c_num, guint8 c_type, guint16 len)
686 proto_tree *r_type_tree, *itf_tree, *reason_tree, *dec_tree, *error_tree, *clientsi_tree, *pdp_tree;
687 guint16 r_type, m_type, reason, reason_sub, cmd_code, cmd_flags, error, error_sub, tcp_port;
688 guint32 ipv4addr, ifindex;
689 struct e_in6_addr ipv6addr;
692 case COPS_OBJ_CONTEXT:
693 r_type = tvb_get_ntohs(tvb, offset);
694 m_type = tvb_get_ntohs(tvb, offset + 2);
695 ti = proto_tree_add_text(tree, tvb, offset, 4, "Contents: R-Type: %s, M-Type: %u",
696 val_to_str(r_type, cops_r_type_vals, "Unknown"),
699 r_type_tree = proto_item_add_subtree(ti, ett_cops_r_type_flags);
700 proto_tree_add_uint(r_type_tree, hf_cops_r_type_flags, tvb, offset, 2, r_type);
702 proto_tree_add_uint(r_type_tree, hf_cops_m_type_flags, tvb, offset, 2, m_type);
705 case COPS_OBJ_IN_INT:
706 case COPS_OBJ_OUT_INT:
707 if (c_type == 1) { /* IPv4 */
708 tvb_memcpy(tvb, (guint8 *)&ipv4addr, offset, 4);
709 ifindex = tvb_get_ntohl(tvb, offset + 4);
710 ti = proto_tree_add_text(tree, tvb, offset, 8, "Contents: IPv4 address %s, ifIndex: %u",
711 ip_to_str((guint8 *)&ipv4addr), ifindex);
712 itf_tree = proto_item_add_subtree(ti, ett_cops_itf);
713 proto_tree_add_ipv4(itf_tree,
714 (c_num == COPS_OBJ_IN_INT) ? hf_cops_in_int_ipv4 : hf_cops_out_int_ipv4,
715 tvb, offset, 4, ipv4addr);
717 } else if (c_type == 2) { /* IPv6 */
718 tvb_memcpy(tvb, (guint8 *)&ipv6addr, offset, sizeof ipv6addr);
719 ifindex = tvb_get_ntohl(tvb, offset + sizeof ipv6addr);
720 ti = proto_tree_add_text(tree, tvb, offset, 20, "Contents: IPv6 address %s, ifIndex: %u",
721 ip6_to_str(&ipv6addr), ifindex);
722 itf_tree = proto_item_add_subtree(ti, ett_cops_itf);
723 proto_tree_add_ipv6(itf_tree,
724 (c_num == COPS_OBJ_IN_INT) ? hf_cops_in_int_ipv6 : hf_cops_out_int_ipv6,
725 tvb, offset, 16, (guint8 *)&ipv6addr);
730 proto_tree_add_uint(itf_tree, hf_cops_int_ifindex, tvb, offset, 4, ifindex);
733 case COPS_OBJ_REASON:
734 reason = tvb_get_ntohs(tvb, offset);
735 reason_sub = tvb_get_ntohs(tvb, offset + 2);
736 ti = proto_tree_add_text(tree, tvb, offset, 4, "Contents: Reason-Code: %s, Reason Sub-code: 0x%04x",
737 val_to_str(reason, cops_reason_vals, "<Unknown value>"), reason_sub);
738 reason_tree = proto_item_add_subtree(ti, ett_cops_reason);
739 proto_tree_add_uint(reason_tree, hf_cops_reason, tvb, offset, 2, reason);
742 proto_tree_add_text(reason_tree, tvb, offset, 2, "Reason Sub-code: "
743 "Unknown object's C-Num %u, C-Type %u",
744 tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset + 1));
746 proto_tree_add_uint(reason_tree, hf_cops_reason_sub, tvb, offset, 2, reason_sub);
749 case COPS_OBJ_DECISION:
750 case COPS_OBJ_LPDPDECISION:
752 cmd_code = tvb_get_ntohs(tvb, offset);
753 cmd_flags = tvb_get_ntohs(tvb, offset + 2);
754 ti = proto_tree_add_text(tree, tvb, offset, 4, "Contents: Command-Code: %s, Flags: %s",
755 val_to_str(cmd_code, cops_dec_cmd_code_vals, "<Unknown value>"),
756 val_to_str(cmd_flags, cops_dec_cmd_flag_vals, "<Unknown flag>"));
757 dec_tree = proto_item_add_subtree(ti, ett_cops_decision);
758 proto_tree_add_uint(dec_tree, hf_cops_dec_cmd_code, tvb, offset, 2, cmd_code);
760 proto_tree_add_uint(dec_tree, hf_cops_dec_flags, tvb, offset, 2, cmd_flags);
761 } else if (c_type == 5) { /*COPS-PR Data*/
762 ti = proto_tree_add_text(tree, tvb, offset, 4, "Contents: %u bytes", len);
763 dec_tree = proto_item_add_subtree(ti, ett_cops_decision);
764 dissect_cops_pr_objects(tvb, offset, dec_tree, len);
772 error = tvb_get_ntohs(tvb, offset);
773 error_sub = tvb_get_ntohs(tvb, offset + 2);
774 ti = proto_tree_add_text(tree, tvb, offset, 4, "Contents: Error-Code: %s, Error Sub-code: 0x%04x",
775 val_to_str(error, cops_error_vals, "<Unknown value>"), error_sub);
776 error_tree = proto_item_add_subtree(ti, ett_cops_error);
777 proto_tree_add_uint(error_tree, hf_cops_error, tvb, offset, 2, error);
780 proto_tree_add_text(error_tree, tvb, offset, 2, "Error Sub-code: "
781 "Unknown object's C-Num %u, C-Type %u",
782 tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset + 1));
784 proto_tree_add_uint(error_tree, hf_cops_error_sub, tvb, offset, 2, error_sub);
787 case COPS_OBJ_CLIENTSI:
789 if (c_type != 2) /*Not COPS-PR data*/
792 ti = proto_tree_add_text(tree, tvb, offset, 4, "Contents: %u bytes", len);
793 clientsi_tree = proto_item_add_subtree(ti, ett_cops_clientsi);
795 dissect_cops_pr_objects(tvb, offset, clientsi_tree, len);
798 case COPS_OBJ_KATIMER:
802 proto_tree_add_item(tree, hf_cops_katimer, tvb, offset + 2, 2, FALSE);
803 if (tvb_get_ntohs(tvb, offset + 2) == 0)
804 proto_tree_add_text(tree, tvb, offset, 0, "Value of zero implies infinity.");
811 if (tvb_strnlen(tvb, offset, len) == -1)
812 proto_tree_add_text(tree, tvb, offset, len, "<PEP Id is not a NUL terminated ASCII string>");
814 proto_tree_add_item(tree, hf_cops_pepid, tvb, offset,
815 tvb_strnlen(tvb, offset, len) + 1, FALSE);
818 case COPS_OBJ_REPORT_TYPE:
822 proto_tree_add_item(tree, hf_cops_report_type, tvb, offset, 2, FALSE);
825 case COPS_OBJ_PDPREDIRADDR:
826 case COPS_OBJ_LASTPDPADDR:
827 if (c_type == 1) { /* IPv4 */
828 tvb_memcpy(tvb, (guint8 *)&ipv4addr, offset, 4);
829 tcp_port = tvb_get_ntohs(tvb, offset + 4 + 2);
830 ti = proto_tree_add_text(tree, tvb, offset, 8, "Contents: IPv4 address %s, TCP Port Number: %u",
831 ip_to_str((guint8 *)&ipv4addr), tcp_port);
832 pdp_tree = proto_item_add_subtree(ti, ett_cops_pdp);
833 proto_tree_add_ipv4(pdp_tree,
834 (c_num == COPS_OBJ_PDPREDIRADDR) ? hf_cops_pdprediraddr_ipv4 : hf_cops_lastpdpaddr_ipv4,
835 tvb, offset, 4, ipv4addr);
837 } else if (c_type == 2) { /* IPv6 */
838 tvb_memcpy(tvb, (guint8 *)&ipv6addr, offset, sizeof ipv6addr);
839 tcp_port = tvb_get_ntohs(tvb, offset + sizeof ipv6addr + 2);
840 ti = proto_tree_add_text(tree, tvb, offset, 20, "Contents: IPv6 address %s, TCP Port Number: %u",
841 ip6_to_str(&ipv6addr), tcp_port);
842 pdp_tree = proto_item_add_subtree(ti, ett_cops_pdp);
843 proto_tree_add_ipv6(pdp_tree,
844 (c_num == COPS_OBJ_PDPREDIRADDR) ? hf_cops_pdprediraddr_ipv6 : hf_cops_lastpdpaddr_ipv6,
845 tvb, offset, 16, (guint8 *)&ipv6addr);
851 proto_tree_add_uint(pdp_tree, hf_cops_pdp_tcp_port, tvb, offset, 2, tcp_port);
854 case COPS_OBJ_ACCTTIMER:
858 proto_tree_add_item(tree, hf_cops_accttimer, tvb, offset + 2, 2, FALSE);
859 if (tvb_get_ntohs(tvb, offset + 2) == 0)
860 proto_tree_add_text(tree, tvb, offset, 0, "Value of zero means "
861 "there SHOULD be no unsolicited accounting updates.");
864 case COPS_OBJ_INTEGRITY:
866 break; /* Not HMAC digest */
868 proto_tree_add_item(tree, hf_cops_key_id, tvb, offset, 4, FALSE);
869 proto_tree_add_item(tree, hf_cops_seq_num, tvb, offset + 4, 4, FALSE);
870 proto_tree_add_text(tree, tvb, offset + 8 , len - 8, "Contents: Keyed Message Digest");
874 proto_tree_add_text(tree, tvb, offset, len, "Contents: %u bytes", len);
881 /*convert hex to binary string (1010....)*/
882 static gchar* xtobstr(guint8 *hex, guint len) {
884 guint i=0,j=0,k=0, bit=0;
888 binstr = g_malloc(8*sizeof(gchar)*len);
890 for (i=0; i < len; i++) {
891 for ( j=0; j<8; j++ ) { /* for each bit */
892 bit = (mask & hex[i]) ? 1 : 0; /* bit is 1 or 0 */
893 sprintf(&binstr[k++],"%d",bit); /*put it in string */
894 mask >>= 1; /* shift mask right */
902 * XXX - we should perhaps support reading PIBs, as we support reading
903 * MIBs, and use the PIBs we read to understand how to display COPS data
904 * just as we use the MIBs we read to understand how to display SNMP
907 static int decode_cops_pr_asn1_data(tvbuff_t *tvb, guint32 offset,
908 proto_tree *tree, guint epdlen, gboolean inepd)
922 gint32 vb_integer_value;
923 guint32 vb_uinteger_value;
925 guint8 *vb_octet_string;
930 gchar *vb_display_string;
936 while (epdlen > 0) { /*while there is stuff to be decoded*/
937 asn1_open(&asn1, tvb, offset);
939 /* parse the type of the object */
943 ret = asn1_header_decode (&asn1, &cls, &con, &tag, &def,
945 if (ret != ASN1_ERR_NOERROR)
948 return ASN1_ERR_LENGTH_NOT_DEFINITE;
950 /* Convert the class, constructed flag, and tag to a type. */
951 vb_type_name = cops_tag_cls2syntax(tag, cls, &vb_type);
952 if (vb_type_name == NULL) {
955 * Dissect the value as an opaque string of octets.
957 vb_type_name = "unsupported type";
958 vb_type = COPS_OPAQUE;
961 /* parse the value */
966 ret = asn1_int32_value_decode(&asn1, vb_length,
968 if (ret != ASN1_ERR_NOERROR)
970 length = asn1.offset - start;
972 proto_tree_add_text(tree, asn1.tvb, offset, length,
973 "Value: %s: %d (%#x)", vb_type_name,
974 vb_integer_value, vb_integer_value);
978 case COPS_UNSIGNED32:
980 ret = asn1_uint32_value_decode(&asn1, vb_length,
982 if (ret != ASN1_ERR_NOERROR)
984 length = asn1.offset - start;
986 proto_tree_add_text(tree, asn1.tvb, offset, length,
987 "Value: %s: %u (%#x)", vb_type_name,
988 vb_uinteger_value, vb_uinteger_value);
995 case COPS_UNSIGNED64:
997 ret = asn1_string_value_decode (&asn1, vb_length,
999 if (ret != ASN1_ERR_NOERROR)
1001 length = asn1.offset - start;
1003 /* if this EPD belongs to ipFilter or
1004 frwkPrcSupport Entries print it correctly) */
1005 if ((strncmp(last_decoded_prid,"1.3.6.1.2.2.2.3.2.1",19)==0) || (strncmp(last_decoded_prid,"1.3.6.1.2.2.2.1.1.1",19)==0)) {
1006 if(strncmp(last_decoded_prid,"1.3.6.1.2.2.2.3.2.1",19)==0) {
1007 i=0;/* EPD belongs to
1009 bytes (IPv6 not printed
1013 frwkPrcSupportEntry,
1014 convert hex byte(s) to
1017 xtobstr(vb_octet_string,
1020 proto_tree_add_text(tree, asn1.tvb,
1022 "Value: %s: %s", vb_type_name,
1025 g_free(vb_octet_string);
1026 g_free(vb_display_string);
1031 /* EPD doesn't belong to ipFilter or
1032 frwkPrcSupport Entries;
1033 check for unprintable characters*/
1035 for (i = 0; i < vb_length; i++) {
1036 if (!(isprint(vb_octet_string[i])
1037 ||isspace(vb_octet_string[i])))
1043 * If some characters are not printable,
1044 * display the string as bytes.
1046 if (i < vb_length) {
1048 * We stopped, due to a non-printable
1049 * character, before we got to the end
1053 g_malloc(4*vb_length);
1054 buf = &vb_display_string[0];
1055 len = sprintf(buf, "%03u",
1056 vb_octet_string[0]);
1058 for (i = 1; i < vb_length; i++) {
1059 len = sprintf(buf, ".%03u",
1060 vb_octet_string[i]);
1063 proto_tree_add_text(tree,
1064 asn1.tvb, offset, length,
1065 "Value: %s: %s", vb_type_name,
1067 g_free(vb_display_string);
1069 proto_tree_add_text(tree,
1070 asn1.tvb, offset, length,
1071 "Value: %s: %.*s", vb_type_name,
1073 SAFE_STRING(vb_octet_string));
1076 g_free(vb_octet_string);
1080 ret = asn1_null_decode (&asn1, vb_length);
1081 if (ret != ASN1_ERR_NOERROR)
1083 length = asn1.offset - start;
1085 proto_tree_add_text(tree, asn1.tvb, offset, length,
1086 "Value: %s", vb_type_name);
1091 ret = asn1_oid_value_decode (&asn1, vb_length, &vb_oid,
1093 if (ret != ASN1_ERR_NOERROR)
1095 length = asn1.offset - start;
1098 vb_display_string = format_oid(vb_oid,
1100 proto_tree_add_text(tree, asn1.tvb, offset, length,
1101 "Value: %s: %s", vb_type_name,
1105 /* we're decoding EPD */
1106 g_free(vb_display_string);
1108 /* we're decoding PRID, so let's store
1109 the OID of the PRID so that later
1110 when we're decoding this PRID's EPD
1111 we can finetune the output. */
1112 if (last_decoded_prid)
1113 g_free(last_decoded_prid);
1114 last_decoded_prid = vb_display_string;
1121 g_assert_not_reached();
1122 return ASN1_ERR_WRONG_TYPE;
1125 asn1_close(&asn1,&offset);
1132 static int dissect_cops_pr_object_data(tvbuff_t *tvb, guint32 offset, proto_tree *tree,
1133 guint8 s_num, guint8 s_type, guint16 len)
1136 proto_tree *asn1_object_tree, *gperror_tree, *cperror_tree;
1137 guint16 gperror=0, gperror_sub=0, cperror=0, cperror_sub=0;
1141 if (s_type != 1) /* Not Provisioning Instance Identifier (PRID) */
1144 ti=proto_tree_add_text(tree, tvb, offset, len, "Contents:");
1145 asn1_object_tree = proto_item_add_subtree(ti, ett_cops_asn1);
1147 decode_cops_pr_asn1_data(tvb, offset, asn1_object_tree, len, FALSE);
1150 case COPS_OBJ_PPRID:
1151 if (s_type != 1) /* Not Prefix Provisioning Instance Identifier (PPRID) */
1154 ti = proto_tree_add_text(tree, tvb, offset, len, "Contents:");
1155 asn1_object_tree = proto_item_add_subtree(ti, ett_cops_asn1);
1157 decode_cops_pr_asn1_data(tvb, offset, asn1_object_tree, len, FALSE);
1161 if (s_type != 1) /* Not Encoded Provisioning Instance Data (EPD) */
1164 ti = proto_tree_add_text(tree, tvb, offset, len, "Contents:");
1165 asn1_object_tree = proto_item_add_subtree(ti, ett_cops_asn1);
1167 decode_cops_pr_asn1_data(tvb, offset, asn1_object_tree, len, TRUE);
1170 case COPS_OBJ_GPERR:
1171 if (s_type != 1) /* Not Global Provisioning Error Object (GPERR) */
1174 gperror = tvb_get_ntohs(tvb, offset);
1175 gperror_sub = tvb_get_ntohs(tvb, offset + 2);
1176 ti = proto_tree_add_text(tree, tvb, offset, 4, "Contents: Error-Code: %s, Error Sub-code: 0x%04x",
1177 val_to_str(gperror, cops_gperror_vals, "<Unknown value>"), gperror_sub);
1178 gperror_tree = proto_item_add_subtree(ti, ett_cops_gperror);
1179 proto_tree_add_uint(gperror_tree, hf_cops_gperror, tvb, offset, 2, gperror);
1181 if (cperror == 13) {
1182 proto_tree_add_text(gperror_tree, tvb, offset, 2, "Error Sub-code: "
1183 "Unknown object's C-Num %u, C-Type %u",
1184 tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset + 1));
1186 proto_tree_add_uint(gperror_tree, hf_cops_gperror_sub, tvb, offset, 2, gperror_sub);
1189 case COPS_OBJ_CPERR:
1190 if (s_type != 1) /*Not PRC Class Provisioning Error Object (CPERR) */
1195 cperror = tvb_get_ntohs(tvb, offset);
1196 cperror_sub = tvb_get_ntohs(tvb, offset + 2);
1197 ti = proto_tree_add_text(tree, tvb, offset, 4, "Contents: Error-Code: %s, Error Sub-code: 0x%04x",
1198 val_to_str(cperror, cops_cperror_vals, "<Unknown value>"), cperror_sub);
1199 cperror_tree = proto_item_add_subtree(ti, ett_cops_cperror);
1200 proto_tree_add_uint(cperror_tree, hf_cops_cperror, tvb, offset, 2, cperror);
1202 if (cperror == 13) {
1203 proto_tree_add_text(cperror_tree, tvb, offset, 2, "Error Sub-code: "
1204 "Unknown object's S-Num %u, C-Type %u",
1205 tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset + 1));
1207 proto_tree_add_uint(cperror_tree, hf_cops_cperror_sub, tvb, offset, 2, cperror_sub);
1210 case COPS_OBJ_ERRPRID:
1211 if (s_type != 1) /*Not Error Provisioning Instance Identifier (ErrorPRID)*/
1214 ti = proto_tree_add_text(tree, tvb, offset, len, "Contents:");
1215 asn1_object_tree = proto_item_add_subtree(ti, ett_cops_asn1);
1217 decode_cops_pr_asn1_data(tvb, offset, asn1_object_tree, len, FALSE);
1221 proto_tree_add_text(tree, tvb, offset, len, "Contents: %u bytes", len);
1229 /* Register the protocol with Ethereal */
1230 void proto_register_cops(void)
1232 /* Setup list of header fields */
1233 static hf_register_info hf[] = {
1234 { &hf_cops_ver_flags,
1235 { "Version and Flags", "cops.ver_flags",
1236 FT_UINT8, BASE_HEX, NULL, 0x0,
1237 "Version and Flags in COPS Common Header", HFILL }
1240 { "Version", "cops.version",
1241 FT_UINT8, BASE_DEC, NULL, 0xF0,
1242 "Version in COPS Common Header", HFILL }
1245 { "Flags", "cops.flags",
1246 FT_UINT8, BASE_HEX, VALS(cops_flags_vals), 0x0F,
1247 "Flags in COPS Common Header", HFILL }
1250 { "Op Code", "cops.op_code",
1251 FT_UINT8, BASE_DEC, VALS(cops_op_code_vals), 0x0,
1252 "Op Code in COPS Common Header", HFILL }
1254 { &hf_cops_client_type,
1255 { "Client Type", "cops.client_type",
1256 FT_UINT16, BASE_DEC, NULL, 0x0,
1257 "Client Type in COPS Common Header", HFILL }
1260 { "Message Length", "cops.msg_len",
1261 FT_UINT32, BASE_DEC, NULL, 0x0,
1262 "Message Length in COPS Common Header", HFILL }
1265 { "Object Length", "cops.obj.len",
1266 FT_UINT32, BASE_DEC, NULL, 0x0,
1267 "Object Length in COPS Object Header", HFILL }
1269 { &hf_cops_obj_c_num,
1270 { "C-Num", "cops.c_num",
1271 FT_UINT8, BASE_DEC, VALS(cops_c_num_vals), 0x0,
1272 "C-Num in COPS Object Header", HFILL }
1274 { &hf_cops_obj_c_type,
1275 { "C-Type", "cops.c_type",
1276 FT_UINT8, BASE_DEC, NULL, 0x0,
1277 "C-Type in COPS Object Header", HFILL }
1280 { &hf_cops_obj_s_num,
1281 { "S-Num", "cops.s_num",
1282 FT_UINT8, BASE_DEC, VALS(cops_s_num_vals), 0x0,
1283 "S-Num in COPS-PR Object Header", HFILL }
1285 { &hf_cops_obj_s_type,
1286 { "S-Type", "cops.s_type",
1287 FT_UINT8, BASE_DEC, NULL, 0x0,
1288 "S-Type in COPS-PR Object Header", HFILL }
1291 { &hf_cops_r_type_flags,
1292 { "R-Type", "cops.context.r_type",
1293 FT_UINT16, BASE_HEX, VALS(cops_r_type_vals), 0xFFFF,
1294 "R-Type in COPS Context Object", HFILL }
1296 { &hf_cops_m_type_flags,
1297 { "M-Type", "cops.context.m_type",
1298 FT_UINT16, BASE_HEX, NULL, 0xFFFF,
1299 "M-Type in COPS Context Object", HFILL }
1301 { &hf_cops_in_int_ipv4,
1302 { "IPv4 address", "cops.in-int.ipv4",
1303 FT_IPv4, 0, NULL, 0xFFFF,
1304 "IPv4 address in COPS IN-Int object", HFILL }
1306 { &hf_cops_in_int_ipv6,
1307 { "IPv6 address", "cops.in-int.ipv6",
1308 FT_IPv6, 0, NULL, 0xFFFF,
1309 "IPv6 address in COPS IN-Int object", HFILL }
1311 { &hf_cops_out_int_ipv4,
1312 { "IPv4 address", "cops.out-int.ipv4",
1313 FT_IPv4, 0, NULL, 0xFFFF,
1314 "IPv4 address in COPS OUT-Int object", HFILL }
1316 { &hf_cops_out_int_ipv6,
1317 { "IPv6 address", "cops.out-int.ipv6",
1318 FT_IPv6, 0, NULL, 0xFFFF,
1319 "IPv6 address in COPS OUT-Int", HFILL }
1321 { &hf_cops_int_ifindex,
1322 { "ifIndex", "cops.in-out-int.ifindex",
1323 FT_UINT32, BASE_DEC, NULL, 0x0,
1324 "If SNMP is supported, corresponds to MIB-II ifIndex", HFILL }
1327 { "Reason", "cops.reason",
1328 FT_UINT16, BASE_DEC, VALS(cops_reason_vals), 0,
1329 "Reason in Reason object", HFILL }
1331 { &hf_cops_reason_sub,
1332 { "Reason Sub-code", "cops.reason_sub",
1333 FT_UINT16, BASE_HEX, NULL, 0,
1334 "Reason Sub-code in Reason object", HFILL }
1336 { &hf_cops_dec_cmd_code,
1337 { "Command-Code", "cops.decision.cmd",
1338 FT_UINT16, BASE_DEC, VALS(cops_dec_cmd_code_vals), 0,
1339 "Command-Code in Decision/LPDP Decision object", HFILL }
1341 { &hf_cops_dec_flags,
1342 { "Flags", "cops.decision.flags",
1343 FT_UINT16, BASE_HEX, VALS(cops_dec_cmd_flag_vals), 0xffff,
1344 "Flags in Decision/LPDP Decision object", HFILL }
1347 { "Error", "cops.error",
1348 FT_UINT16, BASE_DEC, VALS(cops_error_vals), 0,
1349 "Error in Error object", HFILL }
1351 { &hf_cops_error_sub,
1352 { "Error Sub-code", "cops.error_sub",
1353 FT_UINT16, BASE_HEX, NULL, 0,
1354 "Error Sub-code in Error object", HFILL }
1357 { "Contents: KA Timer Value", "cops.katimer.value",
1358 FT_UINT16, BASE_DEC, NULL, 0,
1359 "Keep-Alive Timer Value in KATimer object", HFILL }
1362 { "Contents: PEP Id", "cops.pepid.id",
1363 FT_STRING, BASE_NONE, NULL, 0,
1364 "PEP Id in PEPID object", HFILL }
1366 { &hf_cops_report_type,
1367 { "Contents: Report-Type", "cops.report_type",
1368 FT_UINT16, BASE_DEC, VALS(cops_report_type_vals), 0,
1369 "Report-Type in Report-Type object", HFILL }
1371 { &hf_cops_pdprediraddr_ipv4,
1372 { "IPv4 address", "cops.pdprediraddr.ipv4",
1373 FT_IPv4, 0, NULL, 0xFFFF,
1374 "IPv4 address in COPS PDPRedirAddr object", HFILL }
1376 { &hf_cops_pdprediraddr_ipv6,
1377 { "IPv6 address", "cops.pdprediraddr.ipv6",
1378 FT_IPv6, 0, NULL, 0xFFFF,
1379 "IPv6 address in COPS PDPRedirAddr object", HFILL }
1381 { &hf_cops_lastpdpaddr_ipv4,
1382 { "IPv4 address", "cops.lastpdpaddr.ipv4",
1383 FT_IPv4, 0, NULL, 0xFFFF,
1384 "IPv4 address in COPS LastPDPAddr object", HFILL }
1386 { &hf_cops_lastpdpaddr_ipv6,
1387 { "IPv6 address", "cops.lastpdpaddr.ipv6",
1388 FT_IPv6, 0, NULL, 0xFFFF,
1389 "IPv6 address in COPS LastPDPAddr object", HFILL }
1391 { &hf_cops_pdp_tcp_port,
1392 { "TCP Port Number", "cops.pdp.tcp_port",
1393 FT_UINT32, BASE_DEC, NULL, 0x0,
1394 "TCP Port Number of PDP in PDPRedirAddr/LastPDPAddr object", HFILL }
1396 { &hf_cops_accttimer,
1397 { "Contents: ACCT Timer Value", "cops.accttimer.value",
1398 FT_UINT16, BASE_DEC, NULL, 0,
1399 "Accounting Timer Value in AcctTimer object", HFILL }
1402 { "Contents: Key ID", "cops.integrity.key_id",
1403 FT_UINT32, BASE_DEC, NULL, 0,
1404 "Key ID in Integrity object", HFILL }
1407 { "Contents: Sequence Number", "cops.integrity.seq_num",
1408 FT_UINT32, BASE_DEC, NULL, 0,
1409 "Sequence Number in Integrity object", HFILL }
1412 { "Error", "cops.gperror",
1413 FT_UINT16, BASE_DEC, VALS(cops_gperror_vals), 0,
1414 "Error in Error object", HFILL }
1416 { &hf_cops_gperror_sub,
1417 { "Error Sub-code", "cops.gperror_sub",
1418 FT_UINT16, BASE_HEX, NULL, 0,
1419 "Error Sub-code in Error object", HFILL }
1422 { "Error", "cops.cperror",
1423 FT_UINT16, BASE_DEC, VALS(cops_cperror_vals), 0,
1424 "Error in Error object", HFILL }
1426 { &hf_cops_cperror_sub,
1427 { "Error Sub-code", "cops.cperror_sub",
1428 FT_UINT16, BASE_HEX, NULL, 0,
1429 "Error Sub-code in Error object", HFILL }
1434 /* Setup protocol subtree array */
1435 static gint *ett[] = {
1437 &ett_cops_ver_flags,
1441 &ett_cops_r_type_flags,
1453 module_t* cops_module;
1455 /* Register the protocol name and description */
1456 proto_cops = proto_register_protocol("Common Open Policy Service",
1459 /* Required function calls to register the header fields and subtrees used */
1460 proto_register_field_array(proto_cops, hf, array_length(hf));
1461 proto_register_subtree_array(ett, array_length(ett));
1463 /* Register our configuration options for cops,
1464 * particularly our ports
1466 cops_module = prefs_register_protocol(proto_cops,
1467 proto_reg_handoff_cops);
1468 prefs_register_uint_preference(cops_module,"tcp.cops_port",
1470 "Set the TCP port for COPS messages",
1471 10,&global_cops_tcp_port);
1472 prefs_register_bool_preference(cops_module, "desegment",
1473 "Desegment all COPS messages spanning multiple TCP segments",
1474 "Whether the COPS dissector should desegment all messages spanning multiple TCP segments",
1479 proto_reg_handoff_cops(void)
1481 static int cops_prefs_initialized = FALSE;
1482 static dissector_handle_t cops_handle;
1484 if (!cops_prefs_initialized) {
1485 cops_handle = create_dissector_handle(dissect_cops, proto_cops);
1486 cops_prefs_initialized = TRUE;
1488 dissector_delete("tcp.port",cops_tcp_port,cops_handle);
1490 /* Set our port numbers for future use */
1491 cops_tcp_port = global_cops_tcp_port;
1493 dissector_add("tcp.port", cops_tcp_port, cops_handle);