proto_register_mswsp(void)
{
	expert_module_t* expert_mswsp = NULL;
	static hf_register_info hf[] = {
		{
			&hf_mswsp_hdr,
			{
				"Header", "mswsp.hdr",
				FT_NONE, BASE_NONE, NULL, 0,
				"Message header", HFILL
			}
		},
		{
			&hf_mswsp_hdr_msg,
			{
				"Msg id", "mswsp.hdr.id",
				FT_UINT32, BASE_HEX, VALS(msg_ids), 0,
				"Message id", HFILL
			}
		},
		{
			&hf_mswsp_hdr_status,
			{
				"Status", "mswsp.hdr.status",
				FT_UINT32, BASE_HEX, VALS(dcom_hresult_vals), 0,
				"Message Status", HFILL
			}
		},
		{
			&hf_mswsp_hdr_checksum,
			{
				"checksum", "mswsp.hdr.checksum",
				FT_UINT32, BASE_HEX, NULL, 0,
				"Message Checksum", HFILL
			}
		},
		{
			&hf_mswsp_hdr_reserved,
			{
				"Reserved", "mswsp.hdr.reserved",
				FT_UINT32, BASE_HEX, NULL, 0,
				"Reserved bytes", HFILL
			}
		},
		{
			&hf_mswsp_msg,
			{
				"msg", "mswsp.msg",
				FT_NONE, BASE_NONE, NULL, 0,
				"Message", HFILL
			}
		},
		{
			&hf_mswsp_msg_Connect_Version,
			{
				"Version", "mswsp.Connect.version",
				FT_UINT32, BASE_HEX, VALS(version_vals), 0,
				"OS Version", HFILL
			}
		},
		{
			&hf_mswsp_msg_ConnectIn_ClientIsRemote,
			{
				"Remote", "mswsp.ConnectIn.isRemote",
				FT_BOOLEAN, BASE_HEX, NULL, 0,
				"Client is remote",HFILL
			}
		},
		{
			&hf_mswsp_msg_ConnectIn_Blob1,
			{
				"Size", "mswsp.ConnectIn.propset.size",
				FT_UINT32, BASE_DEC, NULL, 0,
				"Size of PropSet fields",HFILL
			}
		},
		{
			&hf_mswsp_msg_ConnectIn_MachineName,
			{
				"Remote machine", "mswsp.ConnectIn.machine",
				FT_STRINGZ, BASE_NONE, NULL, 0,
				"Name of remote machine",HFILL
			}
		},
		{
			&hf_mswsp_msg_ConnectIn_UserName,
			{
				"User", "mswsp.ConnectIn.user",
				FT_STRINGZ, BASE_NONE, NULL, 0,
				"Name of remote user",HFILL
			}
		},
		{
			&hf_mswsp_msg_ConnectIn_PropSets_num,
			{
				"Num", "mswsp.ConnectIn.propset.num",
				FT_UINT32, BASE_DEC, NULL, 0,
				"Number of Property Sets", HFILL
			}
		},
		{
			&hf_mswsp_bool_options,
			{
				"uBooleanOptions", "mswsp.CPMCreateQuery.RowSetProperties.uBooleanOptions",
				FT_UINT32, BASE_HEX, NULL, 0, "Boolean options", HFILL
			}
		},
		{
			&hf_mswsp_bool_options_cursor,
			{
				"Cursor", "mswsp.CPMCreateQuery.RowSetProperties.uBooleanOptions.cursor", FT_UINT32,
				BASE_HEX, VALS(cursor_vals), 0x0000000007, "Cursor Type", HFILL
			}
		},
		{
			&hf_mswsp_bool_options_async,
			{
				"eAsynchronous", "mswsp.CPMCreateQuery.RowSetProperties.uBooleanOptions.eAsynchronous",
				FT_BOOLEAN, 32, NULL, eAsynchronous, "The client will not wait for execution completion", HFILL
			}
		},
		{
			&hf_mswsp_bool_options_firstrows,
			{
				"eFirstRows", "mswsp.CPMCreateQuery.RowSetProperties.uBooleanOptions.eFirstRows",
				FT_BOOLEAN, 32, NULL, eFirstRows, "Return the first rows encountered, not the best matches.", HFILL
			}
		},
		{
			&hf_mswsp_bool_options_holdrows,
			{
				"eHoldRows", "mswsp.CPMCreateQuery.RowSetProperties.uBooleanOptions.eHoldRows",
				FT_BOOLEAN, 32, NULL, eHoldRows, "The server MUST NOT discard rows until the client is done with a query.", HFILL
			}
		},
		{
			&hf_mswsp_bool_options_chaptered,
			{
				"eChaptered", "mswsp.CPMCreateQuery.RowSetProperties.uBooleanOptions.eChaptered",
				FT_BOOLEAN, 32, NULL, eChaptered, "The rowset supports chapters.", HFILL
			}
		},
		{
			&hf_mswsp_bool_options_useci,
			{
				"eUseCI", "mswsp.CPMCreateQuery.RowSetProperties.uBooleanOptions.eUseCI",
				FT_BOOLEAN, 32, NULL, eUseCI, "Use the inverted index to evaluate content restrictions even if it is out of date.", HFILL
			}
		},
		{
			&hf_mswsp_bool_options_defertrim,
			{
				"eDeferTrimming", "mswsp.CPMCreateQuery.RowSetProperties.uBooleanOptions.eDeferTrimming",
				FT_BOOLEAN, 32, NULL, eDeferTrimming, "Defer Non-indexed trimming operations like scoping or security checking which can be expensive.", HFILL
			}
		},
		{
			&hf_mswsp_bool_options_rowsetevents,
			{
				"eEnableRowsetEvents", "mswsp.RowSetProperties.CPMCreateQuery.uBooleanOptions.eEnableRowsetEvents",
				FT_BOOLEAN, 32, NULL, eEnableRowsetEvents, "Enables storage of rowset events on the server side.", HFILL
			}
		},
		{
			&hf_mswsp_bool_options_dontcomputeexpensive,
			{
				"eDoNotComputeExpensiveProps", "mswsp.CPMCreateQuery.RowSetProperties.uBooleanOptions.eDoNotComputeExpensiveProps",
				FT_BOOLEAN, 32, NULL, eDoNotComputeExpensiveProps, "Prevents computation of expensive properties.", HFILL
			}
		},
		{
			&hf_mswsp_guid_time_low,
			{
				"time-low", "mswsp.guid.time_low",
				FT_UINT32, BASE_HEX, NULL, 0, "time low value", HFILL
			}
		},
		{
			&hf_mswsp_guid_time_mid,
			{
				"time-mid", "mswsp.guid.time_mid",
				FT_UINT16, BASE_HEX, NULL, 0, "time mid value", HFILL
			}
		},
		{
			&hf_mswsp_guid_time_high,
			{
				"time-high", "mswsp.guid.time_high",
				FT_UINT16, BASE_HEX, NULL, 0, "time high value", HFILL
			}
		},
		{
			&hf_mswsp_guid_time_clock_hi,
			{
				"clock_seq_hi_and_reserved", "mswsp.guid.time_clock_high",
				FT_UINT8, BASE_HEX, NULL, 0, "time clock high value", HFILL
			}
		},
		{
			&hf_mswsp_guid_time_clock_low,
			{
				"clock_seq_low", "mswsp.guid.time_clock_low",
				FT_UINT8, BASE_HEX, NULL, 0, "time clock high low", HFILL
			}
		},
		{
			&hf_mswsp_guid_node,
			{
				"node", "mswsp.guid.node",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_lcid,
			{
				"lcid", "mswsp.lcid",
				FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_lcid_sortid,
			{
				"Sort ID", "mswsp.lcid.sortid",
				FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_lcid_langid,
			{
				"Language ID", "mswsp.lcid.langid",
				FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cscort_column,
			{
				"column", "mswsp.csort.column",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cscort_order,
			{
				"order", "mswsp.csort.order",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cscort_individual,
			{
				"individual", "mswsp.csort.individual",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cscortset_count,
			{
				"count", "mswsp.csortset.count",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ctablecolumn_vtype,
			{
				"vType", "mswsp.ctablecolumn.vtype",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ctablecolumn_aggused,
			{
				"AggregateUsed", "mswsp.ctablecolumn.aggused",
				FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ctablecolumn_aggtype,
			{
				"AggregateType", "mswsp.ctablecolumn.aggtype",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ctablecolumn_valused,
			{
				"ValueUsed", "mswsp.ctablecolumn.valused",
				FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ctablecolumn_valoffset,
			{
				"ValueOffset", "mswsp.ctablecolumn.valoffset",
				FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ctablecolumn_valsize,
			{
				"ValueSize", "mswsp.ctablecolumn.valsize",
				FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ctablecolumn_statused,
			{
				"StatusUsed", "mswsp.ctablecolumn.statused",
				FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ctablecolumn_statoffset,
			{
				"StatusOffset", "mswsp.ctablecolumn.statoffset",
				FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ctablecolumn_lenused,
			{
				"LengthUsed", "mswsp.ctablecolumn.lenused",
				FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ctablecolumn_lenoffset,
			{
				"LengthOffset", "mswsp.ctablecolumn.lenoffset",
				FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cfullpropspec_kind,
			{
				"ulKind", "mswsp.cfullpropspec.kind",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cfullpropspec_propid,
			{
				"propid", "mswsp.cfullpropspec.propid",
				FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cfullpropspec_propname,
			{
				"propname", "mswsp.cfullpropspec.propname",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cproprestrict_relop,
			{
				"relop", "mswsp.cproprestrict.relop",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ccoercerestrict_value,
			{
				"value", "mswsp.ccoercerestrict.value",
				FT_FLOAT, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ccontentrestrict_cc,
			{
				"cc", "mswsp.ccontentrestrict.cc",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ccontentrestrict_phrase,
			{
				"phrase", "mswsp.ccontentrestrict.phrase",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ccontentrestrict_method,
			{
				"method", "mswsp.ccontentrestrict.method",
				FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_natlangrestrict_cc,
			{
				"cc", "mswsp.ccontentrestrict.cc",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_natlangrestrict_phrase,
			{
				"phrase", "mswsp.ccontentrestrict.phrase",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crestrict_ultype,
			{
				"ulType", "mswsp.crestrict.ultype",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crestrict_weight,
			{
				"Weight", "mswsp.crestrict.weight",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crestrictarray_count,
			{
				"count", "mswsp.crestrictarray.count",
				FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crestrictarray_present,
			{
				"present", "mswsp.crestrictarray.present",
				FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cnoderestrict_cnode,
			{
				"Weight", "mswsp.cnoderestrict.cnode",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cbasestorvariant_vtype,
			{
				"vType", "mswsp.cbasestorvariant.vtype",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cbasestorvariant_vvalue,
			{
				"vValue", "mswsp.cbasestorvariant.vvalue",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cbasestorvariant_vdata1,
			{
				"vData1", "mswsp.cbasestorvariant.vdata1",
				FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cbasestorvariant_vdata2,
			{
				"vData2", "mswsp.cbasestorvariant.vdata2",
				FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cbasestorvariant_num,
			{
				"num", "mswsp.cbasestorvariant.num",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cbasestorvariant_cdims,
			{
				"cDims", "mswsp.cbasestorvariant.cdims",
				FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cbasestorvariant_ffeatures,
			{
				"fFeatures", "mswsp.cbasestorvariant.ffeatures",
				FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cbasestorvariant_cbelements,
			{
				"cbElements", "mswsp.cbasestorvariant.cbelements",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cbasestorvariant_rgsabound,
			{
				"Rgsabound", "mswsp.cbasestorvariant.rgsabound",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cdbcolid_ekind,
			{
				"eKind", "mswsp.cdbcolid.ekind",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cdbcolid_ulid,
			{
				"ulId", "mswsp.cdbcolid.ulid",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cdbcolid_vstring,
			{
				"vString", "mswsp.cdbcolid.vstring",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cdbprop_id,
			{
				"Id", "mswsp.cdbprop.id",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cdbprop_options,
			{
				"Options", "mswsp.cdbprop.options",
				FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cdbprop_status,
			{
				"Status", "mswsp.cdbprop.status",
				FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cdbpropset_cprops,
			{
				"cProperties", "mswsp.cdbpropset.cprops",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_rangeboundry_ultype,
			{
				"ulType", "mswsp.rangeboundry.ultype",
				FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_rangeboundry_labelpresent,
			{
				"labelPresent", "mswsp.rangeboundry.labelpresent",
				FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL
			}
		},
		{
			&hf_mswsp_rangeboundry_cclabel,
			{
				"ccLabel", "mswsp.rangeboundry.cclabel",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_rangeboundry_label,
			{
				"Label", "mswsp.rangeboundry.label",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crangecategspec_crange,
			{
				"cRange", "mswsp.crangecategspec.crange",
				FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ccategspec_type,
			{
				"type", "mswsp.ccategspec.type",
				FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_caggregspec_type,
			{
				"type", "mswsp.caggregspec.type",
				FT_UINT8, BASE_DEC, VALS(DBAGGTTYPE), 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_caggregspec_ccalias,
			{
				"ccAlias", "mswsp.caggregspec.ccalias",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_caggregspec_alias,
			{
				"Alias", "mswsp.caggregspec.alias",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_caggregspec_idcolumn,
			{
				"idColumn", "mswsp.caggregspec.idcolumn",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_caggregspec_ulmaxnumtoreturn,
			{
				"ulMaxNumToReturn",
				"mswsp.caggregspec.ulmaxnumtoreturn",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_caggregspec_idrepresentative,
			{
				"idRepresentative",
				"mswsp.caggregspec.idrepresentative",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_caggregset_count,
			{
				"count", "mswsp.caggregset.count",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_caggregsortkey_order,
			{
				"order", "mswsp.caggregsortkey.order",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_csortaggregset_count,
			{
				"count", "mswsp.csortaggregset.count",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cingroupsortaggregset_type,
			{
				"Type", "mswsp.cingroupsortaggregset.type",
				FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cingroupsortaggregsets_count,
			{
				"count", "mswsp.cingroupsortaggregsets.count",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_categorizationspec_cmaxres,
			{
				"cMaxResults", "mswsp.categorizationspec.cmaxres",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crowsetprops_ulmaxopenrows,
			{
				"ulMaxOpenRows (ignored)", "mswsp.crowsetprops.ulmaxopenrows",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crowsetprops_ulmemusage,
			{
				"ulMemUsage (ignored)", "mswsp.crowsetprops.ulmemusage",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crowsetprops_cmaxresults,
			{
				"cMaxResults", "mswsp.crowsetprops.cmaxresults",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crowsetprops_ccmdtimeout,
			{
				"cCmdTimeout", "mswsp.crowsetprops.ccmdtimeout",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_cpidmapper_count,
			{
				"count", "mswsp.cpidmapper.count",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ccolumngroup_count,
			{
				"count", "mswsp.ccolumngroup.count",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ccolumngroup_grouppid,
			{
				"groupPid", "mswsp.ccolumngroup.grouppid",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ccolumngroup_pid,
			{
				"pid", "mswsp.ccolumngroup.pid",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ccolumngrouparray_count,
			{
				"count", "mswsp.ccolumngrouparray.count",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_int32array_value,
			{
				"value", "mswsp.int32array.value",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crowseeknext_cskip,
			{
				"cskip", "mswsp.crowseeknext.cskip",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crowseekat_bmkoffset,
			{
				"bmkoffset", "mswsp.crowseekat.bmkoffset",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crowseekat_skip,
			{
				"skip", "mswsp.crowseekat.skip",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crowseekat_hregion,
			{
				"hregion", "mswsp.crowseekat.hregion",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crowseekatratio_ulnumerator,
			{
				"ulnumerator", "mswsp.crowseekatratio.ulnumerator",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crowseekatratio_uldenominator,
			{
				"uldenominator", "mswsp.crowseekatratio.uldenominator",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crowseekatratio_hregion,
			{
				"hregion", "mswsp.crowseekatratio.hregion",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crowseekbybookmark_cbookmarks,
			{
				"cbookmarks", "mswsp.crowseekbybookmark.cbookmarks",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crowseekbybookmark_maxret,
			{
				"maxret", "mswsp.crowseekbybookmark.maxret",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crowvariantinfo_count64,
			{
				"count", "mswsp.crowvariantinfo.count64",
				FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_arrayvector_address64,
			{
				"address of array", "mswsp.arrayvector.address64",
				FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_crowvariantinfo_count32,
			{
				"count", "mswsp.crowvariantinfo.count32",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_arrayvector_address32,
			{
				"address of array", "mswsp.arrayvector.address",
				FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_rowvariant_item_address64,
			{
				"address", "mswsp.rowvariant.item.address64",
				FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_rowvariant_item_address32,
			{
				"address", "mswsp.rowvariant.item.address32",
				FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_rowvariant_item_value,
			{
				"value", "mswsp.rowvariant.item.value",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_rowvariant_vtype,
			{
				"vtype", "mswsp.rowvariant.vtype",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_rowvariant_reserved1,
			{
				"reserved1", "mswsp.rowvariant.reserved1",
				FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_rowvariant_reserved2,
			{
				"reserved2", "mswsp.rowvariant.reserved2",
				FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ctablecolumn_status,
			{
				"status", "mswsp.ctablecolumn.name",
				FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_ctablecolumn_length,
			{
				"length", "mswsp.ctablecolumn.length",
				FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcreatequery_size,
			{
				"size", "mswsp.cpmcreatequery.size",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcreatequery_ccolumnsetpresent,
			{
				"CColumnSetPresent", "mswsp.cpmcreatequery.ccolumnsetpresent",
				FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcreatequery_crestrictionpresent,
			{
				"CRestrictionPresent", "mswsp.cpmcreatequery.crestrictionpresent",
				FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcreatequery_csortpresent,
			{
				"CSortPresent", "mswsp.cpmcreatequery.csortpresent",
				FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcreatequery_ccategpresent,
			{
				"CCategorizationSetPresent", "mswsp.cpmcreatequery.ccategpresent",
				FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcreatequery_ccateg_count,
			{
				"count", "mswsp.cpmcreatequery.ccateg.count",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcreatequery_trueseq,
			{
				"TrueSequential", "mswsp.cpmcreatequery.trueseq",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcreatequery_workid,
			{
				"WorkId", "mswsp.cpmcreatequery.workid",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcreatequery_cursors,
			{
				"Cursors", "mswsp.cpmcreatequery.cursors",
				FT_BYTES, SEP_SPACE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrows_hcursor,
			{
				"hCursor", "mswsp.msg.cpmgetrows.hcursor",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrows_rowstotransfer,
			{
				"cRowsToTransfer", "mswsp.msg.cpmgetrows.rowstotransfer",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrows_rowwidth,
			{
				"cbRowWidth", "mswsp.msg.cpmgetrows.rowswidth",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrows_cbseek,
			{
				"cbSeek", "mswsp.msg.cpmgetrows.cbseek",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrows_cbreserved,
			{
				"cbReserved", "mswsp.msg.cpmgetrows.cbreserved",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrows_cbreadbuffer,
			{
				"cbReadBuffer", "mswsp.msg.cpmgetrows.cbreadbuffer",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrows_ulclientbase,
			{
				"ulClientBase", "mswsp.msg.cpmgetrows.ulclientbase",
				FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrows_fbwdfetch,
			{
				"fBwdFetch", "mswsp.msg.cpmgetrows.fbwdfetch",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrows_etype,
			{
				"eType", "mswsp.msg.cpmgetrows.etype",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrows_chapt,
			{
				"chapt", "mswsp.msg.cpmgetrows.chapt",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrows_crowsreturned,
			{
				"cRowsReturned", "mswsp.msg.cpmgetrows.crowsreturned",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmratiofinished_hcursor,
			{
				"hCursor", "mswsp.msg.cpmratiofinished_hcursor",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmratiofinished_fquick,
			{
				"fQuick", "mswsp.msg.cpmratiofinished_fquick",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmratiofinished_ulnumerator,
			{
				"ulNumerator", "mswsp.msg.cpmratiofinished_ulnumerator",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmratiofinished_uldenominator,
			{
				"ulDenominator", "mswsp.msg.cpmratiofinished_uldenominator",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmratiofinished_crows,
			{
				"cRows", "mswsp.msg.cpmratiofinished_crows",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmratiofinished_fnewrows,
			{
				"fNewRows", "mswsp.msg.cpmratiofinished_fnewrows",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcomparebmk_hcursor,
			{
				"hCursor", "mswsp.msg.cpmcomparebmk.hcursor",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcomparebmk_chapt,
			{
				"chapt", "mswsp.msg.cpmcomparebmk.chapt",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcomparebmk_bmkfirst,
			{
				"bmkFirst", "mswsp.msg.cpmcomparebmk.bmkfirst",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcomparebmk_bmksecond,
			{
				"bmkSecond", "mswsp.msg.cpmcomparebmk.bmksecond",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcomparebmk_dwcomparison,
			{
				"dwComparison", "mswsp.msg.cpmcomparebmk.dwcomparison",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetapproxpos_hcursor,
			{
				"hCursor", "mswsp.msg.cpmgetapproxpos.hcursor",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetapproxpos_chapt,
			{
				"chapt", "mswsp.msg.cpmgetapproxpos.chapt",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetapproxpos_bmk,
			{
				"bmk", "mswsp.msg.cpmgetapproxpos.bmk",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetapproxpos_numerator,
			{
				"numerator", "mswsp.msg.cpmgetapproxpos.numerator",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetapproxpos_denominator,
			{
				"denominator", "mswsp.msg.cpmgetapproxpos.denominator",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmsetbinding_hcursor,
			{
				"hCursor", "mswsp.msg.cpmsetbinding.hcursor",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmsetbinding_cbrow,
			{
				"cBrow", "mswsp.msg.cpmsetbinding.cbrow",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmsetbinding_desc,
			{
				"cbBindingDesc", "mswsp.msg.cpmsetbinding.desc",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmsetbinding_dummy,
			{
				"dummy", "mswsp.msg.cpmsetbinding.dummy",
				FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmsetbinding_ccolumns,
			{
				"cColumns", "mswsp.msg.cpmsetbinding.ccolumns",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmsetbinding_acolumns,
			{
				"aColumns", "mswsp.msg.cpmsetbinding.acolumns",
				FT_BYTES, SEP_DOT, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmsendnotify_watchnotify,
			{
				"watchNotify", "mswsp.msg.cpmsendnotify.watchnotify",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetquerystatus_hcursor,
			{
				"hCursor", "mswsp.msg.cpmquerystatus.hcursor",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetquerystatus_qstatus,
			{
				"QStatus", "mswsp.msg.cpmquerystatus.qstatus",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcistate_cbstruct,
			{
				"cbStruct", "mswsp.msg.cpmcistate.cbstruct",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcistate_cwordlist,
			{
				"cbWordList", "mswsp.msg.cpmcistate.cbwordlist",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcistate_cpersistindex,
			{
				"cbPersistentIndex", "mswsp.msg.cpmcistate.cbpersistindex",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcistate_cqueries,
			{
				"cQueries", "mswsp.msg.cpmcistate.cqueries",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcistate_cfreshtest,
			{
				"cFreshTest", "mswsp.msg.cpmcistate.cfreshtest",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcistate_dwmergeprogress,
			{
				"dwMergeProgress", "mswsp.msg.cpmcistate.dwmergeprogress",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcistate_estate,
			{
				"eState", "mswsp.msg.cpmcistate.estate",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcistate_cfiltereddocs,
			{
				"cFilteredDocuments", "mswsp.msg.cpmcistate.cfiltereddocs",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcistate_ctotaldocs,
			{
				"cTotalDocuments", "mswsp.msg.cpmcistate.ctotaldocs",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcistate_cpendingscans,
			{
				"cPendingScans", "mswsp.msg.cpmcistate.cpendingscans",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcistate_dwindexsize,
			{
				"dwIndexSize", "mswsp.msg.cpmcistate.dwindexsize",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcistate_cuniquekeys,
			{
				"cUniqueKeys", "mswsp.msg.cpmcistate.cuniquekeys",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcistate_csecqdocuments,
			{
				"cSecQDocuments", "mswsp.msg.cpmcistate.csecqdocuments",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmcistate_dwpropcachesize,
			{
				"dwPropCacheSize", "mswsp.msg.cpmcistate.dwpropcachesize",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmfetchvalue_wid,
			{
				"wid", "mswsp.msg.cpmfetchvalue.wid",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmfetchvalue_cbsofar,
			{
				"cbSoFar", "mswsp.msg.cpmfetchvalue.cbsofar",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmfetchvalue_cbpropspec,
			{
				"cbPropSpec", "mswsp.msg.cpmfetchvalue.cbpropspec",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmfetchvalue_cbchunk,
			{
				"cbChunk", "mswsp.msg.cpmfetchvalue.chunk",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmfetchvalue_cbvalue,
			{
				"cbValue", "mswsp.msg.cpmfetchvalue.cbvalue",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmfetchvalue_fmoreexists,
			{
				"fMoreExists", "mswsp.msg.cpmfetchvalue.fmoreexists",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmfetchvalue_fvalueexists,
			{
				"fValueExists", "mswsp.msg.cpmfetchvalue.fvalueexists",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmfetchvalue_vvalue,
			{
				"vvalue", "mswsp.msg.cpmfetchvalue.vvalue",
				FT_BYTES, SEP_SPACE, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmquerystatusex_qstatus,
			{
				"qStatus", "mswsp.msg.cpmquerystatusex.qstatus",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmquerystatusex_hcursor,
			{
				"hCursor", "mswsp.msg.cpmquerystatusex.hcursor",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmquerystatusex_bmk,
			{
				"bmk", "mswsp.msg.cpmquerystatusex.bmk",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmquerystatusex_cfiltereddocs,
			{
				"cFilteredDocuments", "mswsp.msg.cpmquerystatusex.cfiltereddocs",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmquerystatusex_cdocstofilter,
			{
				"cDocumentsToFilter", "mswsp.msg.cpmquerystatusex.cdocstofilter",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmquerystatusex_dwratiodenom,
			{
				"dwRatioFinishedDenominator", "mswsp.msg.cpmquerystatusex.dwratiodenom",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmquerystatusex_dwrationumer,
			{
				"dwRatioFinishedNumerator", "mswsp.msg.cpmquerystatusex.dwrationumer",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmquerystatusex_irowbmk,
			{
				"iRowBmk", "mswsp.msg.cpmquerystatusex.irowbmk",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmquerystatusex_crowstotal,
			{
				"cRowsTotal", "mswsp.msg.cpmquerystatusex.crowstotal",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmquerystatusex_maxrank,
			{
				"maxRank", "mswsp.msg.cpmquerystatusex.maxrank",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmquerystatusex_cresultsfound,
			{
				"cResultsFound", "mswsp.msg.cpmquerystatusex.cresultsfound",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmquerystatusex_whereid,
			{
				"whereId", "mswsp.msg.cpmquerystatusex.whereid",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmrestartposition_hcursor,
			{
				"hCursor", "mswsp.msg.cpmrestartposition.hcursor",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmrestartposition_chapt,
			{
				"chapt", "mswsp.msg.cpmrestartposition.chapt",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrowsetnotify_wid,
			{
				"wid", "mswsp.msg.cpmgetrowsetnotify.wid",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrowsetnotify_moreevents,
			{
				"moreEvents", "mswsp.msg.cpmgetrowsetnotify.moreevents",
				FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrowsetnotify_eventtype,
			{
				"eventType", "mswsp.msg.cpmgetrowsetnotify.eventType",
				FT_UINT8, BASE_DEC, NULL, 0xFE, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrowsetnotify_rowsetitemstate,
			{
				"rowSetItemState", "mswsp.msg.cpmgetrowsetnotify.rowsetitemstate",
				FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrowsetnotify_changeditemstate,
			{
				"changedItemState", "mswsp.msg.cpmgetrowsetnotify.changeditemState",
				FT_UINT8, BASE_DEC, NULL, 0, 0, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrowsetnotify_rowsetevent,
			{
				"rowSetEvent", "mswsp.msg.cpmgetrowsetnotify.rowsetevent",
				FT_UINT8, BASE_DEC, NULL, 0, 0, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrowsetnotify_rowseteventdata1,
			{
				"rowSetEventdata1", "mswsp.msg.cpmgetrowsetnotify.rowseteventdata1",
				FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmgetrowsetnotify_rowseteventdata2,
			{
				"rowSetEventdata2", "mswsp.msg.cpmgetrowsetnotify.rowseteventdata2",
				FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmfindindices_cwids,
			{
				"cWids", "mswsp.msg.cpmfindindices.cwids",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmfindindices_cdepthprev,
			{
				"cDepthPrev", "mswsp.msg.cpmfindindices.cdepthprev",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmfindindices_cdepthnext,
			{
				"cDepthNext", "mswsp.msg.cpmfindindices.cdepthnext",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmsetscopeprioritization_priority,
			{
				"priority", "mswsp.msg.cpmsetscopeprioritization.priority",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmsetscopeprioritization_eventfreq,
			{
				"eventFrequency", "mswsp.msg.cpmsetscopeprioritization.eventfreq",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmsetscopestatisics_dwindexitems,
			{
				"dwIndexedItems", "mswsp.msg.cpmsetscopestatistics.dwindexitems",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmsetscopestatisics_dwoutstandingadds,
			{
				"dwOutstandingAdds", "mswsp.msg.cpmsetscopestatistics.dwoutstandingadds",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		},
		{
			&hf_mswsp_msg_cpmsetscopestatisics_dwoutstandingmodifies,
			{
				"dwOutstandingModifies", "mswsp.msg.cpmsetscopestatistics.dwoutstandingmodifies",
				FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL
			}
		}
	};

	static gint *ett[] = {
		&ett_mswsp,
		&ett_mswsp_hdr,
		&ett_mswsp_msg,
		&ett_mswsp_pad,
		&ett_mswsp_property_restriction,
		&ett_CRestrictionArray,
		&ett_CBaseStorageVariant,
		&ett_CBaseStorageVariant_Vector,
		&ett_CBaseStorageVariant_Array,
		&ett_CDbColId,
		&ett_GUID,
		&ett_CDbProp,
		&ett_CDbPropSet,
		&ett_CDbPropSet_Array,
		&ett_CRestriction,
		&ett_CNodeRestriction,
		&ett_CPropertyRestriction,
		&ett_CCoercionRestriction,
		&ett_CContentRestriction,
		&ett_RANGEBOUNDARY,
		&ett_CRangeCategSpec,
		&ett_CCategSpec,
		&ett_CAggregSpec,
		&ett_CAggregSet,
		&ett_CCategorizationSpec,
		&ett_CAggregSortKey,
		&ett_CSortAggregSet,
		&ett_CInGroupSortAggregSet,
		&ett_CInGroupSortAggregSets,
		&ett_CRowsetProperties,
		&ett_CFullPropSpec,
		&ett_CPidMapper,
		&ett_CSort,
		&ett_CSortSet,
		&ett_CNatLanguageRestriction,
		&ett_CColumnGroup,
		&ett_CColumnGroupArray,
		&ett_LCID,
		&ett_CTableColumn,
		&ett_Array,
		&ett_SeekDescription,
		&ett_CRowsSeekNext,
		&ett_CRowsSeekAt,
		&ett_CRowsSeekAtRatio,
		&ett_CRowsSeekByBookmark,
		&ett_GetRowsRow,
		&ett_GetRowsColumn,
		&ett_CRowVariant,
		&ett_CRowVariant_Vector,
		&ett_mswsp_bool_options,
		&ett_mswsp_uin32_array,
		&ett_mswsp_msg_padding,
		&ett_mswsp_msg_creusewhere
	};

	static ei_register_info ei[] = {
		{ &ei_mswsp_invalid_variant_type, { "mswsp.invalid_variant_type", PI_PROTOCOL, PI_ERROR, "Invalid variant type", EXPFILL }},
		{ &ei_missing_msg_context, { "mswsp.msg.cpmgetrows.missing_msg_context", PI_SEQUENCE, PI_WARN, "previous messages needed for context not captured", EXPFILL }},
		{ &ei_mswsp_msg_cpmsetbinding_ccolumns, { "mswsp.msg.cpmsetbinding.ccolumns.invalude", PI_PROTOCOL, PI_WARN, "Invalid number of cColumns for packet", EXPFILL }}
	};
	int i;

	proto_mswsp = proto_register_protocol("Windows Search Protocol",
										  "MS-WSP", "mswsp");

	proto_register_field_array(proto_mswsp, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));
	expert_mswsp = expert_register_protocol(proto_mswsp);
	expert_register_field_array(expert_mswsp, ei, array_length(ei));
	for (i=0; i<(int)array_length(GuidPropertySet); i++) {
		guids_add_guid(&GuidPropertySet[i].guid, GuidPropertySet[i].def);
	}
}


static int dissect_CPMSetScopePrioritization(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, gboolean in, void *data _U_)
{
	gint offset = 16;
	proto_item *item;
	proto_tree *tree;

	col_append_str(pinfo->cinfo, COL_INFO, "SetScopePrioritization");

	if (in) {
		item = proto_tree_add_item(parent_tree, hf_mswsp_msg, tvb, offset, -1, ENC_NA);
		tree = proto_item_add_subtree(item, ett_mswsp_msg);
		proto_item_set_text(item, "SetScopePrioritizationIn");
		proto_tree_add_item(tree, hf_mswsp_msg_cpmsetscopeprioritization_priority, tvb, offset, 4, ENC_LITTLE_ENDIAN);
		offset += 4;
		proto_tree_add_item(tree, hf_mswsp_msg_cpmsetscopeprioritization_eventfreq, tvb, offset, 4, ENC_LITTLE_ENDIAN);
	}
	return tvb_reported_length(tvb);
}


static int dissect_mswsp_smb2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
	smb2_info_t *si = (smb2_info_t*)data;
	gboolean in;
	char* fid_name = NULL;
	guint32     open_frame = 0, close_frame = 0;

	if (!si) {
		return 0;
	}

	if (si->saved) {
		dcerpc_fetch_polhnd_data(&si->saved->policy_hnd, &fid_name, NULL, &open_frame, &close_frame, pinfo->num);
	}

	if (!fid_name || g_ascii_strcasecmp(fid_name, "File: MsFteWds") != 0) {
		return 0;
	}

	in = !(si->flags & SMB2_FLAGS_RESPONSE);
	p_add_proto_data(wmem_file_scope(), pinfo, proto_mswsp, 0, (void*)&SMB2);
	return dissect_mswsp(tvb, pinfo, tree, in, data);
}


static int parse_relop(tvbuff_t *tvb, int offset,  proto_tree *tree, guint32 *relop, const char **str)
{
	const char *str1 = NULL, *str2 = NULL;
	guint32 tmp = tvb_get_letohl(tvb, offset);
	guint32 modifier = (tmp & 0xF00);
	DISSECTOR_ASSERT((tmp & 0xf) < PRSomeBits +1);

	switch(tmp & 0xf) {
		case PRLT:
			*relop = PRLT;
			break;
		case PRLE:
			*relop = PRLE;
			break;
		case PRGT:
			*relop = PRGT;
			break;
		case PRGE:
			*relop = PRGE;
			break;
		case PREQ:
			*relop = PREQ;
			break;
		case PRNE:
			*relop = PRNE;
			break;
		case PRRE:
			*relop = PRRE;
			break;
		case PRAllBits:
			*relop = PRAllBits;
			break;
		case PRSomeBits:
			*relop = PRSomeBits;
			break;
		default:
			break;
	}

	str2 = val_to_str(*relop, PR_VALS, "0x%04x");

	if (modifier) {
		switch (modifier) {
			case PRAll:
				*relop = *relop | PRAll;
				break;
			case PRAny:
				*relop |= PRAny;
				break;
			default:
				DISSECTOR_ASSERT(FALSE);
				break;
		}
		str1 = try_val_to_str((modifier), PR_VALS);
		if (str1) {
			str1 = wmem_strdup_printf(wmem_packet_scope(), "%s | ", str1);
			str2 = wmem_strdup_printf(wmem_packet_scope(), "%s%s", str1, str2);
		}
	}
	proto_tree_add_string_format_value(tree, hf_mswsp_cproprestrict_relop, tvb, offset, 4, str2, "%s (0x%04x)", str2[0]=='\0' ? "" : str2, *relop);

	if (str) {
		*str = str2;
	}
	return offset + 4;
}


int parse_CPidMapper(tvbuff_t *tvb, int offset, proto_tree *parent_tree, proto_tree *pad_tree, const char *fmt, ...)
{
	proto_item *item;
	proto_tree *tree;
	va_list ap;
	guint32 count, i;
	const char *txt;

	va_start(ap, fmt);
	txt = wmem_strdup_vprintf(wmem_packet_scope(), fmt, ap);
	va_end(ap);

	tree = proto_tree_add_subtree(parent_tree, tvb, offset, 0, ett_CPidMapper, &item, txt);

	count = tvb_get_letohl(tvb, offset);
	proto_tree_add_uint(tree, hf_mswsp_cpidmapper_count, tvb, offset, 4, count);
	offset += 4;

	offset = parse_padding(tvb, offset, 8, pad_tree, "CPidMapper_PropSpec");

	for (i=0; i<count; i++) {
		struct CFullPropSpec v;
		ZERO_STRUCT(v);
		/*at begin or end of loop???*/
		offset = parse_padding(tvb, offset, 4, pad_tree,
							   "CPidMapper_PropSpec[%u]", i);
		offset = parse_CFullPropSpec(tvb, offset, tree, pad_tree, &v, "PropSpec[%u]", i);
	}

	proto_item_set_end(item, tvb, offset);
	return offset;
}


static int parse_CRowSeekByBookmark(tvbuff_t *tvb, int offset, proto_tree *parent_tree, const char *fmt, ...)
{
	proto_tree *tree;
	proto_item *item;
	guint32 num;
	const char *txt;
	va_list ap;

	va_start(ap, fmt);
	txt = wmem_strdup_vprintf(wmem_packet_scope(), fmt, ap);
	va_end(ap);

	tree = proto_tree_add_subtree(parent_tree, tvb, offset, 0, ett_CRowsSeekByBookmark, &item, txt);

	num =  tvb_get_letohl(tvb,offset);
	proto_tree_add_item(tree, hf_mswsp_crowseekbybookmark_cbookmarks, tvb, offset, 4, ENC_LITTLE_ENDIAN);
	offset += 4;

	offset = parse_UInt32Array(tvb, offset, tree, num, "abookmark", "abookmarks");

	num =  tvb_get_letohl(tvb,offset);
	proto_tree_add_item(tree, hf_mswsp_crowseekbybookmark_maxret, tvb, offset, 4, ENC_LITTLE_ENDIAN);
	offset += 4;

	offset = parse_UInt32Array(tvb, offset, tree, num, "ascret", "ascret");

	proto_item_set_end(item, tvb, offset);
	return offset;
}


    Jp2Image::Jp2Image(BasicIo::AutoPtr io, bool create)
            : Image(ImageType::jp2, mdExif | mdIptc | mdXmp, io)
    {
        if (create)
        {
            if (io_->open() == 0)
            {
#ifdef EXIV2_DEBUG_MESSAGES
                std::cerr << "Exiv2::Jp2Image:: Creating JPEG2000 image to memory" << std::endl;
#endif
                IoCloser closer(*io_);
                if (io_->write(Jp2Blank, sizeof(Jp2Blank)) != sizeof(Jp2Blank))
                {
#ifdef EXIV2_DEBUG_MESSAGES
                    std::cerr << "Exiv2::Jp2Image:: Failed to create JPEG2000 image on memory" << std::endl;
#endif
                }
            }
        }
    } // Jp2Image::Jp2Image


externalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
	       const xmlChar *ExternalID, const xmlChar *SystemID)
{
    callbacks++;
    if (noout)
	return;
    fprintf(stdout, "SAX.externalSubset(%s,", name);
    if (ExternalID == NULL)
	fprintf(stdout, " ,");
    else
	fprintf(stdout, " %s,", ExternalID);
    if (SystemID == NULL)
	fprintf(stdout, " )\n");
    else
	fprintf(stdout, " %s)\n", SystemID);
}


errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
{
    va_list args;

    callbacks++;
    if (noout)
	return;
    va_start(args, msg);
    fprintf(stdout, "SAX.error: ");
    vfprintf(stdout, msg, args);
    va_end(args);
}


myFreeFunc(void *mem)
{
    xmlMemFree(mem);
}


notationDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
	     const xmlChar *publicId, const xmlChar *systemId)
{
    callbacks++;
    if (noout)
	return;
    fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n",
            (char *) name, (char *) publicId, (char *) systemId);
}


getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
{
    callbacks++;
    if (noout)
	return(NULL);
    fprintf(stdout, "SAX.getParameterEntity(%s)\n", name);
    return(NULL);
}


xmlFreeEntitiesTable(xmlEntitiesTablePtr table) {
    xmlHashFree(table, xmlFreeEntityWrapper);
}


xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
	  const xmlChar *ExternalID, const xmlChar *SystemID,
	  const xmlChar *content) {
    xmlDictPtr dict = NULL;
    xmlEntitiesTablePtr table = NULL;
    xmlEntityPtr ret, predef;

    if (name == NULL)
	return(NULL);
    if (dtd == NULL)
	return(NULL);
    if (dtd->doc != NULL)
        dict = dtd->doc->dict;

    switch (type) {
        case XML_INTERNAL_GENERAL_ENTITY:
        case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
        case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
            predef = xmlGetPredefinedEntity(name);
            if (predef != NULL) {
                int valid = 0;

                /* 4.6 Predefined Entities */
                if ((type == XML_INTERNAL_GENERAL_ENTITY) &&
                    (content != NULL)) {
                    int c = predef->content[0];

                    if (((content[0] == c) && (content[1] == 0)) &&
                        ((c == '>') || (c == '\'') || (c == '"'))) {
                        valid = 1;
                    } else if ((content[0] == '&') && (content[1] == '#')) {
                        if (content[2] == 'x') {
                            xmlChar *hex = BAD_CAST "0123456789ABCDEF";
                            xmlChar ref[] = "00;";

                            ref[0] = hex[c / 16 % 16];
                            ref[1] = hex[c % 16];
                            if (xmlStrcasecmp(&content[3], ref) == 0)
                                valid = 1;
                        } else {
                            xmlChar ref[] = "00;";

                            ref[0] = '0' + c / 10 % 10;
                            ref[1] = '0' + c % 10;
                            if (xmlStrEqual(&content[2], ref))
                                valid = 1;
                        }
                    }
                }
                if (!valid) {
                    xmlEntitiesErr(XML_ERR_ENTITY_PROCESSING,
                            "xmlAddEntity: invalid redeclaration of predefined"
                            " entity");
                    return(NULL);
                }
            }
	    if (dtd->entities == NULL)
		dtd->entities = xmlHashCreateDict(0, dict);
	    table = dtd->entities;
	    break;
        case XML_INTERNAL_PARAMETER_ENTITY:
        case XML_EXTERNAL_PARAMETER_ENTITY:
	    if (dtd->pentities == NULL)
		dtd->pentities = xmlHashCreateDict(0, dict);
	    table = dtd->pentities;
	    break;
        case XML_INTERNAL_PREDEFINED_ENTITY:
	    return(NULL);
    }
    if (table == NULL)
	return(NULL);
    ret = xmlCreateEntity(dict, name, type, ExternalID, SystemID, content);
    if (ret == NULL)
        return(NULL);
    ret->doc = dtd->doc;

    if (xmlHashAddEntry(table, name, ret)) {
	/*
	 * entity was already defined at another level.
	 */
        xmlFreeEntity(ret);
	return(NULL);
    }
    return(ret);
}


xmlXIncludeProcessFlags(xmlDocPtr doc, int flags) {
    return xmlXIncludeProcessFlagsData(doc, flags, NULL);
}


xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
    xmlNodePtr cur, end, list, tmp;

    if (ctxt == NULL)
	return(-1);
    if ((nr < 0) || (nr >= ctxt->incNr))
	return(-1);
    cur = ctxt->incTab[nr]->ref;
    if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
	return(-1);

    list = ctxt->incTab[nr]->inc;
    ctxt->incTab[nr]->inc = NULL;
    ctxt->incTab[nr]->emptyFb = 0;

    /*
     * Check against the risk of generating a multi-rooted document
     */
    if ((cur->parent != NULL) &&
	(cur->parent->type != XML_ELEMENT_NODE)) {
	int nb_elem = 0;

	tmp = list;
	while (tmp != NULL) {
	    if (tmp->type == XML_ELEMENT_NODE)
		nb_elem++;
	    tmp = tmp->next;
	}
	if (nb_elem > 1) {
	    xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
	                   XML_XINCLUDE_MULTIPLE_ROOT,
		       "XInclude error: would result in multiple root nodes\n",
			   NULL);
            xmlFreeNodeList(list);
	    return(-1);
	}
    }

    if (ctxt->parseFlags & XML_PARSE_NOXINCNODE) {
	/*
	 * Add the list of nodes
	 */
	while (list != NULL) {
	    end = list;
	    list = list->next;

	    xmlAddPrevSibling(cur, end);
	}
	xmlUnlinkNode(cur);
	xmlFreeNode(cur);
    } else {
        xmlNodePtr child, next;

	/*
	 * Change the current node as an XInclude start one, and add an
	 * XInclude end one
	 */
        if (ctxt->incTab[nr]->fallback)
            xmlUnsetProp(cur, BAD_CAST "href");
	cur->type = XML_XINCLUDE_START;
        /* Remove fallback children */
        for (child = cur->children; child != NULL; child = next) {
            next = child->next;
            xmlUnlinkNode(child);
            xmlFreeNode(child);
        }
	end = xmlNewDocNode(cur->doc, cur->ns, cur->name, NULL);
	if (end == NULL) {
	    xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
	                   XML_XINCLUDE_BUILD_FAILED,
			   "failed to build node\n", NULL);
            xmlFreeNodeList(list);
	    return(-1);
	}
	end->type = XML_XINCLUDE_END;
	xmlAddNextSibling(cur, end);

	/*
	 * Add the list of nodes
	 */
	while (list != NULL) {
	    cur = list;
	    list = list->next;

	    xmlAddPrevSibling(end, cur);
	}
    }

    return(0);
}


respip_views_apply_cfg(struct views* vs, struct config_file* cfg,
	int* have_view_respip_cfg)
{
	struct config_view* cv;
	struct view* v;
	int ret;

	for(cv = cfg->views; cv; cv = cv->next) {

		/** if no respip config for this view then there's
		  * nothing to do; note that even though respip data must go
		  * with respip action, we're checking for both here because
		  * we want to catch the case where the respip action is missing
		  * while the data is present */
		if(!cv->respip_actions && !cv->respip_data)
			continue;

		if(!(v = views_find_view(vs, cv->name, 1))) {
			log_err("view '%s' unexpectedly missing", cv->name);
			return 0;
		}
		if(!v->respip_set) {
			v->respip_set = respip_set_create();
			if(!v->respip_set) {
				log_err("out of memory");
				lock_rw_unlock(&v->lock);
				return 0;
			}
		}
		ret = respip_set_apply_cfg(v->respip_set, NULL, 0, NULL,
			cv->respip_actions, cv->respip_data);
		lock_rw_unlock(&v->lock);
		if(!ret) {
			log_err("Error while applying respip configuration "
				"for view '%s'", cv->name);
			return 0;
		}
		*have_view_respip_cfg = (*have_view_respip_cfg ||
			v->respip_set->ip_tree.count);
		cv->respip_actions = NULL;
		cv->respip_data = NULL;
	}
	return 1;
}


respip_enter_rr(struct regional* region, struct resp_addr* raddr,
		const char* rrstr, const char* netblock)
{
	uint8_t* nm;
	uint16_t rrtype = 0, rrclass = 0;
	time_t ttl = 0;
	uint8_t rr[LDNS_RR_BUF_SIZE];
	uint8_t* rdata = NULL;
	size_t rdata_len = 0;
	char buf[65536];
	char bufshort[64];
	struct packed_rrset_data* pd;
	struct sockaddr* sa;
	int ret;
	if(raddr->action != respip_redirect
		&& raddr->action != respip_inform_redirect) {
		log_err("cannot parse response-ip-data %s: response-ip "
			"action for %s is not redirect", rrstr, netblock);
		return 0;
	}
	ret = snprintf(buf, sizeof(buf), ". %s", rrstr);
	if(ret < 0 || ret >= (int)sizeof(buf)) {
		strlcpy(bufshort, rrstr, sizeof(bufshort));
		log_err("bad response-ip-data: %s...", bufshort);
		return 0;
	}
	if(!rrstr_get_rr_content(buf, &nm, &rrtype, &rrclass, &ttl, rr, sizeof(rr),
		&rdata, &rdata_len)) {
		log_err("bad response-ip-data: %s", rrstr);
		return 0;
	}
	free(nm);
	sa = (struct sockaddr*)&raddr->node.addr;
	if (rrtype == LDNS_RR_TYPE_CNAME && raddr->data) {
		log_err("CNAME response-ip data (%s) can not co-exist with other "
			"response-ip data for netblock %s", rrstr, netblock);
		return 0;
	} else if (raddr->data &&
		raddr->data->rk.type == htons(LDNS_RR_TYPE_CNAME)) {
		log_err("response-ip data (%s) can not be added; CNAME response-ip "
			"data already in place for netblock %s", rrstr, netblock);
		return 0;
	} else if((rrtype != LDNS_RR_TYPE_CNAME) &&
		((sa->sa_family == AF_INET && rrtype != LDNS_RR_TYPE_A) ||
		(sa->sa_family == AF_INET6 && rrtype != LDNS_RR_TYPE_AAAA))) {
		log_err("response-ip data %s record type does not correspond "
			"to netblock %s address family", rrstr, netblock);
		return 0;
	}

	if(!raddr->data) {
		raddr->data = new_rrset(region, rrtype, rrclass);
		if(!raddr->data)
			return 0;
	}
	pd = raddr->data->entry.data;
	return rrset_insert_rr(region, pd, rdata, rdata_len, ttl, rrstr);
}


dnsc_shared_secrets_delkeyfunc(void *k, void* ATTR_UNUSED(arg))
{
    struct shared_secret_cache_key* ssk = (struct shared_secret_cache_key*)k;
    lock_rw_destroy(&ssk->entry.lock);
    free(ssk);
}


dnscrypt_server_uncurve(struct dnsc_env* env,
                        const dnsccert *cert,
                        uint8_t client_nonce[crypto_box_HALF_NONCEBYTES],
                        uint8_t nmkey[crypto_box_BEFORENMBYTES],
                        struct sldns_buffer* buffer)
{
    size_t len = sldns_buffer_limit(buffer);
    uint8_t *const buf = sldns_buffer_begin(buffer);
    uint8_t nonce[crypto_box_NONCEBYTES];
    struct dnscrypt_query_header *query_header;
    // shared secret cache
    uint8_t key[DNSCRYPT_SHARED_SECRET_KEY_LENGTH];
    struct lruhash_entry* entry;
    uint32_t hash;

    uint32_t nonce_hash;

    if (len <= DNSCRYPT_QUERY_HEADER_SIZE) {
        return -1;
    }

    query_header = (struct dnscrypt_query_header *)buf;

    /* Detect replay attacks */
    nonce_hash = dnsc_nonce_cache_key_hash(
        query_header->nonce,
        cert->magic_query,
        query_header->publickey);

    lock_basic_lock(&env->nonces_cache_lock);
    entry = dnsc_nonces_lookup(
        env->nonces_cache,
        query_header->nonce,
        cert->magic_query,
        query_header->publickey,
        nonce_hash);

    if(entry) {
        lock_rw_unlock(&entry->lock);
        env->num_query_dnscrypt_replay++;
        lock_basic_unlock(&env->nonces_cache_lock);
        return -1;
    }

    dnsc_nonce_cache_insert(
        env->nonces_cache,
        query_header->nonce,
        cert->magic_query,
        query_header->publickey,
        nonce_hash);
    lock_basic_unlock(&env->nonces_cache_lock);

    /* Find existing shared secret */
    hash = dnsc_shared_secrets_cache_key(key,
                                         cert->es_version[1],
                                         query_header->publickey,
                                         cert->keypair->crypt_secretkey);
    entry = dnsc_shared_secrets_lookup(env->shared_secrets_cache,
                                       key,
                                       hash);

    if(!entry) {
        lock_basic_lock(&env->shared_secrets_cache_lock);
        env->num_query_dnscrypt_secret_missed_cache++;
        lock_basic_unlock(&env->shared_secrets_cache_lock);
        if(cert->es_version[1] == 2) {
#ifdef USE_DNSCRYPT_XCHACHA20
            if (crypto_box_curve25519xchacha20poly1305_beforenm(
                        nmkey, query_header->publickey,
                        cert->keypair->crypt_secretkey) != 0) {
                return -1;
            }
#else
            return -1;
#endif
    } else {
        if (crypto_box_beforenm(nmkey,
                                query_header->publickey,
                                cert->keypair->crypt_secretkey) != 0) {
            return -1;
        }
    }
    // Cache the shared secret we just computed.
    dnsc_shared_secret_cache_insert(env->shared_secrets_cache,
                                    key,
                                    hash,
                                    nmkey);
    } else {
        /* copy shared secret and unlock entry */
        memcpy(nmkey, entry->data, crypto_box_BEFORENMBYTES);
        lock_rw_unlock(&entry->lock);
    }

    memcpy(nonce, query_header->nonce, crypto_box_HALF_NONCEBYTES);
    memset(nonce + crypto_box_HALF_NONCEBYTES, 0, crypto_box_HALF_NONCEBYTES);

    if(cert->es_version[1] == 2) {
#ifdef USE_DNSCRYPT_XCHACHA20
        if (crypto_box_curve25519xchacha20poly1305_open_easy_afternm
                (buf,
                buf + DNSCRYPT_QUERY_BOX_OFFSET,
                len - DNSCRYPT_QUERY_BOX_OFFSET, nonce,
                nmkey) != 0) {
            return -1;
        }
#else
        return -1;
#endif
    } else {
        if (crypto_box_open_easy_afternm
            (buf,
             buf + DNSCRYPT_QUERY_BOX_OFFSET,
             len - DNSCRYPT_QUERY_BOX_OFFSET, nonce,
             nmkey) != 0) {
            return -1;
        }
    }

    len -= DNSCRYPT_QUERY_HEADER_SIZE;

    while (*sldns_buffer_at(buffer, --len) == 0)
        ;

    if (*sldns_buffer_at(buffer, len) != 0x80) {
        return -1;
    }

    memcpy(client_nonce, nonce, crypto_box_HALF_NONCEBYTES);

    sldns_buffer_set_position(buffer, 0);
    sldns_buffer_set_limit(buffer, len);

    return 0;
}


respip_action_cfg(struct respip_set* set, const char* ipstr,
	const char* actnstr)
{
	struct resp_addr* node;
	enum respip_action action;

	if(!(node=respip_find_or_create(set, ipstr, 1)))
		return 0;
	if(node->action != respip_none) {
		verbose(VERB_QUERY, "duplicate response-ip action for '%s', overridden.",
			ipstr);
	}
        if(strcmp(actnstr, "deny") == 0)
                action = respip_deny;
        else if(strcmp(actnstr, "redirect") == 0)
                action = respip_redirect;
        else if(strcmp(actnstr, "inform") == 0)
                action = respip_inform;
        else if(strcmp(actnstr, "inform_deny") == 0)
                action = respip_inform_deny;
        else if(strcmp(actnstr, "inform_redirect") == 0)
                action = respip_inform_redirect;
        else if(strcmp(actnstr, "always_transparent") == 0)
                action = respip_always_transparent;
        else if(strcmp(actnstr, "always_refuse") == 0)
                action = respip_always_refuse;
        else if(strcmp(actnstr, "always_nxdomain") == 0)
                action = respip_always_nxdomain;
        else {
                log_err("unknown response-ip action %s", actnstr);
                return 0;
        }
	node->action = action;
	return 1;
}


dnsc_parse_certs(struct dnsc_env *env, struct config_file *cfg)
{
	struct config_strlist *head, *head2;
	size_t signed_cert_id;
	size_t rotated_cert_id;
	char *nm;

	env->signed_certs_count = 0U;
	env->rotated_certs_count = 0U;
	for (head = cfg->dnscrypt_provider_cert; head; head = head->next) {
		env->signed_certs_count++;
	}
	for (head = cfg->dnscrypt_provider_cert_rotated; head; head = head->next) {
		env->rotated_certs_count++;
	}
	env->signed_certs = sodium_allocarray(env->signed_certs_count,
										  sizeof *env->signed_certs);

	env->rotated_certs = sodium_allocarray(env->rotated_certs_count,
										  sizeof env->signed_certs);
	signed_cert_id = 0U;
	rotated_cert_id = 0U;
	for(head = cfg->dnscrypt_provider_cert; head; head = head->next, signed_cert_id++) {
		nm = dnsc_chroot_path(cfg, head->str);
		if(dnsc_read_from_file(
				nm,
				(char *)(env->signed_certs + signed_cert_id),
				sizeof(struct SignedCert)) != 0) {
			fatal_exit("dnsc_parse_certs: failed to load %s: %s", head->str, strerror(errno));
		}
		for(head2 = cfg->dnscrypt_provider_cert_rotated; head2; head2 = head2->next) {
			if(strcmp(head->str, head2->str) == 0) {
				*(env->rotated_certs + rotated_cert_id) = env->signed_certs + signed_cert_id;
				rotated_cert_id++;
				verbose(VERB_OPS, "Cert %s is rotated and will not be distributed via DNS", head->str);
				break;
			}
		}
		verbose(VERB_OPS, "Loaded cert %s", head->str);
	}
	return signed_cert_id;
}


int inplace_cb_reply_call(struct module_env* env, struct query_info* qinfo,
	struct module_qstate* qstate, struct reply_info* rep, int rcode,
	struct edns_data* edns, struct comm_reply* repinfo, struct regional* region)
{
	return inplace_cb_reply_call_generic(
		env->inplace_cb_lists[inplace_cb_reply], inplace_cb_reply, qinfo,
		qstate, rep, rcode, edns, repinfo, region);
}


struct edns_option* edns_opt_list_find(struct edns_option* list, uint16_t code)
{
	struct edns_option* p;
	for(p=list; p; p=p->next) {
		if(p->opt_code == code)
			return p;
	}
	return NULL;
}


construct_reply_info_base(struct regional* region, uint16_t flags, size_t qd,
	time_t ttl, time_t prettl, time_t expttl, size_t an, size_t ns,
	size_t ar, size_t total, enum sec_status sec)
{
	struct reply_info* rep;
	/* rrset_count-1 because the first ref is part of the struct. */
	size_t s = sizeof(struct reply_info) - sizeof(struct rrset_ref) +
		sizeof(struct ub_packed_rrset_key*) * total;
	if(total >= RR_COUNT_MAX) return NULL; /* sanity check on numRRS*/
	if(region)
		rep = (struct reply_info*)regional_alloc(region, s);
	else	rep = (struct reply_info*)malloc(s +
			sizeof(struct rrset_ref) * (total));
	if(!rep)
		return NULL;
	rep->flags = flags;
	rep->qdcount = qd;
	rep->ttl = ttl;
	rep->prefetch_ttl = prettl;
	rep->serve_expired_ttl = expttl;
	rep->an_numrrsets = an;
	rep->ns_numrrsets = ns;
	rep->ar_numrrsets = ar;
	rep->rrset_count = total;
	rep->security = sec;
	rep->authoritative = 0;
	/* array starts after the refs */
	if(region)
		rep->rrsets = (struct ub_packed_rrset_key**)&(rep->ref[0]);
	else	rep->rrsets = (struct ub_packed_rrset_key**)&(rep->ref[total]);
	/* zero the arrays to assist cleanup in case of malloc failure */
	memset( rep->rrsets, 0, sizeof(struct ub_packed_rrset_key*) * total);
	if(!region)
		memset( &rep->ref[0], 0, sizeof(struct rrset_ref) * total);
	return rep;
}


struct ub_packed_rrset_key* reply_find_rrset(struct reply_info* rep,
	uint8_t* name, size_t namelen, uint16_t type, uint16_t dclass)
{
	size_t i;
	for(i=0; i<rep->rrset_count; i++) {
		struct ub_packed_rrset_key* s = rep->rrsets[i];
		if(ntohs(s->rk.type) == type &&
			ntohs(s->rk.rrset_class) == dclass &&
			namelen == s->rk.dname_len &&
			query_dname_compare(name, s->rk.dname) == 0) {
			return s;
		}
	}
	return NULL;
}


reply_check_cname_chain(struct query_info* qinfo, struct reply_info* rep)
{
	/* check only answer section rrs for matching cname chain.
	 * the cache may return changed rdata, but owner names are untouched.*/
	size_t i;
	uint8_t* sname = qinfo->qname;
	size_t snamelen = qinfo->qname_len;
	for(i=0; i<rep->an_numrrsets; i++) {
		uint16_t t = ntohs(rep->rrsets[i]->rk.type);
		if(t == LDNS_RR_TYPE_DNAME)
			continue; /* skip dnames; note TTL 0 not cached */
		/* verify that owner matches current sname */
		if(query_dname_compare(sname, rep->rrsets[i]->rk.dname) != 0){
			/* cname chain broken */
			return 0;
		}
		/* if this is a cname; move on */
		if(t == LDNS_RR_TYPE_CNAME) {
			get_cname_target(rep->rrsets[i], &sname, &snamelen);
		}
	}
	return 1;
}


int RGWSwiftWebsiteHandler::serve_errordoc(const int http_ret,
                                           const std::string error_doc)
{
  /* Try to throw it all away. */
  s->formatter->reset();

  class RGWGetErrorPage : public RGWGetObj_ObjStore_SWIFT {
  public:
    RGWGetErrorPage(RGWRados* const store,
                    RGWHandler_REST* const handler,
                    req_state* const s,
                    const int http_ret) {
      /* Calling a virtual from the base class is safe as the subobject should
       * be properly initialized and we haven't overridden the init method. */
      init(store, s, handler);
      set_get_data(true);
      set_custom_http_response(http_ret);
    }

    int error_handler(const int err_no,
                      std::string* const error_content) override {
      /* Enforce that any error generated while getting the error page will
       * not be send to a client. This allows us to recover from the double
       * fault situation by sending the original message. */
      return 0;
    }
  } get_errpage_op(store, handler, s, http_ret);

  s->object = std::to_string(http_ret) + error_doc;

  RGWOp* newop = &get_errpage_op;
  RGWRequest req(0);
  return rgw_process_authenticated(handler, newop, &req, s, true);
}


int RGWHandler_REST_SWIFT::init_from_header(struct req_state* const s,
                                            const std::string& frontend_prefix)
{
  string req;
  string first;

  s->prot_flags |= RGW_REST_SWIFT;

  char reqbuf[frontend_prefix.length() + s->decoded_uri.length() + 1];
  sprintf(reqbuf, "%s%s", frontend_prefix.c_str(), s->decoded_uri.c_str());
  const char *req_name = reqbuf;

  const char *p;

  if (*req_name == '?') {
    p = req_name;
  } else {
    p = s->info.request_params.c_str();
  }

  s->info.args.set(p);
  s->info.args.parse();

  /* Skip the leading slash of URL hierarchy. */
  if (req_name[0] != '/') {
    return 0;
  } else {
    req_name++;
  }

  if ('\0' == req_name[0]) {
    return g_conf()->rgw_swift_url_prefix == "/" ? -ERR_BAD_URL : 0;
  }

  req = req_name;

  size_t pos = req.find('/');
  if (std::string::npos != pos && g_conf()->rgw_swift_url_prefix != "/") {
    bool cut_url = g_conf()->rgw_swift_url_prefix.length();
    first = req.substr(0, pos);

    if (first.compare(g_conf()->rgw_swift_url_prefix) == 0) {
      if (cut_url) {
        /* Rewind to the "v1/..." part. */
        next_tok(req, first, '/');
      }
    }
  } else if (req.compare(g_conf()->rgw_swift_url_prefix) == 0) {
    s->formatter = new RGWFormatter_Plain;
    return -ERR_BAD_URL;
  } else {
    first = req;
  }

  std::string tenant_path;
  if (! g_conf()->rgw_swift_tenant_name.empty()) {
    tenant_path = "/AUTH_";
    tenant_path.append(g_conf()->rgw_swift_tenant_name);
  }

  /* verify that the request_uri conforms with what's expected */
  char buf[g_conf()->rgw_swift_url_prefix.length() + 16 + tenant_path.length()];
  int blen;
  if (g_conf()->rgw_swift_url_prefix == "/") {
    blen = sprintf(buf, "/v1%s", tenant_path.c_str());
  } else {
    blen = sprintf(buf, "/%s/v1%s",
                   g_conf()->rgw_swift_url_prefix.c_str(), tenant_path.c_str());
  }

  if (strncmp(reqbuf, buf, blen) != 0) {
    return -ENOENT;
  }

  int ret = allocate_formatter(s, RGW_FORMAT_PLAIN, true);
  if (ret < 0)
    return ret;

  string ver;

  next_tok(req, ver, '/');

  if (!tenant_path.empty() || g_conf()->rgw_swift_account_in_url) {
    string account_name;
    next_tok(req, account_name, '/');

    /* Erase all pre-defined prefixes like "AUTH_" or "KEY_". */
    const vector<string> skipped_prefixes = { "AUTH_", "KEY_" };

    for (const auto pfx : skipped_prefixes) {
      const size_t comp_len = min(account_name.length(), pfx.length());
      if (account_name.compare(0, comp_len, pfx) == 0) {
        /* Prefix is present. Drop it. */
        account_name = account_name.substr(comp_len);
        break;
      }
    }

    if (account_name.empty()) {
      return -ERR_PRECONDITION_FAILED;
    } else {
      s->account_name = account_name;
    }
  }

  next_tok(req, first, '/');

  dout(10) << "ver=" << ver << " first=" << first << " req=" << req << dendl;
  if (first.size() == 0)
    return 0;

  s->info.effective_uri = "/" + first;

  // Save bucket to tide us over until token is parsed.
  s->init_state.url_bucket = first;

  if (req.size()) {
    s->object =
      rgw_obj_key(req, s->info.env->get("HTTP_X_OBJECT_VERSION_ID", "")); /* rgw swift extension */
    s->info.effective_uri.append("/" + s->object.name);
  }

  return 0;
}


int RGWSwiftWebsiteHandler::retarget_object(RGWOp* op, RGWOp** new_op)
{
  ldout(s->cct, 10) << "Starting object retarget" << dendl;
  RGWOp* op_override = nullptr;

  /* In Swift static web content is served if the request is anonymous or
   * has X-Web-Mode HTTP header specified to true. */
  if (can_be_website_req() && is_web_dir()) {
    const auto& ws_conf = s->bucket_info.website_conf;
    const auto& index = s->bucket_info.website_conf.get_index_doc();

    if (s->decoded_uri.back() != '/') {
      op_override = get_ws_redirect_op();
    } else if (! index.empty() && is_index_present(index)) {
      op_override = get_ws_index_op();
    } else if (ws_conf.listing_enabled) {
      op_override = get_ws_listing_op();
    }
  } else {
    /* A regular request or the specified object isn't a subdirectory marker.
     * We don't need any re-targeting. Error handling (like sending a custom
     * error page) will be performed by error_handler of the actual RGWOp. */
    return 0;
  }

  if (op_override) {
    handler->put_op(op);
    op_override->init(store, s, handler);

    *new_op = op_override;
  } else {
    *new_op = op;
  }

  /* Return 404 Not Found if we aren't able to re-target for subdir marker. */
  return ! op_override ? -ENOENT : 0;
}


int RGWSwiftWebsiteHandler::error_handler(const int err_no,
                                          std::string* const error_content)
{
  const auto& ws_conf = s->bucket_info.website_conf;

  if (can_be_website_req() && ! ws_conf.error_doc.empty()) {
    set_req_state_err(s, err_no);
    return serve_errordoc(s->err.http_ret, ws_conf.error_doc);
  }

  /* Let's go to the default, no-op handler. */
  return err_no;
}


int RGWPutMetadataAccount_ObjStore_SWIFT::get_params()
{
  if (s->has_bad_meta) {
    return -EINVAL;
  }

  int ret = get_swift_account_settings(s,
                                       store,
                                       // FIXME: we need to carry unique_ptr in generic class
                                       // and allocate appropriate ACL class in the ctor
                                       static_cast<RGWAccessControlPolicy_SWIFTAcct *>(&policy),
                                       &has_policy);
  if (ret < 0) {
    return ret;
  }

  get_rmattrs_from_headers(s, ACCT_PUT_ATTR_PREFIX, ACCT_REMOVE_ATTR_PREFIX,
			   rmattr_names);
  return 0;
}


static void dump_container_metadata(struct req_state *s,
                                    const RGWBucketEnt& bucket,
                                    const RGWQuotaInfo& quota,
                                    const RGWBucketWebsiteConf& ws_conf)
{
  /* Adding X-Timestamp to keep align with Swift API */
  dump_header(s, "X-Timestamp", utime_t(s->bucket_info.creation_time));

  dump_header(s, "X-Container-Object-Count", bucket.count);
  dump_header(s, "X-Container-Bytes-Used", bucket.size);
  dump_header(s, "X-Container-Bytes-Used-Actual", bucket.size_rounded);

  if (s->object.empty()) {
    auto swift_policy = \
      static_cast<RGWAccessControlPolicy_SWIFT*>(s->bucket_acl.get());
    std::string read_acl, write_acl;
    swift_policy->to_str(read_acl, write_acl);

    if (read_acl.size()) {
      dump_header(s, "X-Container-Read", read_acl);
    }
    if (write_acl.size()) {
      dump_header(s, "X-Container-Write", write_acl);
    }
    if (!s->bucket_info.placement_rule.name.empty()) {
      dump_header(s, "X-Storage-Policy", s->bucket_info.placement_rule.name);
    }
    dump_header(s, "X-Storage-Class", s->bucket_info.placement_rule.get_storage_class());

    /* Dump user-defined metadata items and generic attrs. */
    const size_t PREFIX_LEN = sizeof(RGW_ATTR_META_PREFIX) - 1;
    map<string, bufferlist>::iterator iter;
    for (iter = s->bucket_attrs.lower_bound(RGW_ATTR_PREFIX);
         iter != s->bucket_attrs.end();
         ++iter) {
      const char *name = iter->first.c_str();
      map<string, string>::const_iterator geniter = rgw_to_http_attrs.find(name);

      if (geniter != rgw_to_http_attrs.end()) {
        dump_header(s, geniter->second, iter->second);
      } else if (strncmp(name, RGW_ATTR_META_PREFIX, PREFIX_LEN) == 0) {
        dump_header_prefixed(s, "X-Container-Meta-",
                             camelcase_dash_http_attr(name + PREFIX_LEN),
                             iter->second);
      }
    }
  }

  /* Dump container versioning info. */
  if (! s->bucket_info.swift_ver_location.empty()) {
    dump_header(s, "X-Versions-Location",
                url_encode(s->bucket_info.swift_ver_location));
  }

  /* Dump quota headers. */
  if (quota.enabled) {
    if (quota.max_size >= 0) {
      dump_header(s, "X-Container-Meta-Quota-Bytes", quota.max_size);
    }

    if (quota.max_objects >= 0) {
      dump_header(s, "X-Container-Meta-Quota-Count", quota.max_objects);
    }
  }

  /* Dump Static Website headers. */
  if (! ws_conf.index_doc_suffix.empty()) {
    dump_header(s, "X-Container-Meta-Web-Index", ws_conf.index_doc_suffix);
  }

  if (! ws_conf.error_doc.empty()) {
    dump_header(s, "X-Container-Meta-Web-Error", ws_conf.error_doc);
  }

  if (! ws_conf.subdir_marker.empty()) {
    dump_header(s, "X-Container-Meta-Web-Directory-Type",
                ws_conf.subdir_marker);
  }

  if (! ws_conf.listing_css_doc.empty()) {
    dump_header(s, "X-Container-Meta-Web-Listings-CSS",
                ws_conf.listing_css_doc);
  }

  if (ws_conf.listing_enabled) {
    dump_header(s, "X-Container-Meta-Web-Listings", "true");
  }

  /* Dump bucket's modification time. Compliance with the Swift API really
   * needs that. */
  dump_last_modified(s, s->bucket_mtime);
}


static int get_swift_container_settings(req_state * const s,
                                        RGWRados * const store,
                                        RGWAccessControlPolicy * const policy,
                                        bool * const has_policy,
                                        uint32_t * rw_mask,
                                        RGWCORSConfiguration * const cors_config,
                                        bool * const has_cors)
{
  const char * const read_list = s->info.env->get("HTTP_X_CONTAINER_READ");
  const char * const write_list = s->info.env->get("HTTP_X_CONTAINER_WRITE");

  *has_policy = false;

  if (read_list || write_list) {
    RGWAccessControlPolicy_SWIFT swift_policy(s->cct);
    const auto r = swift_policy.create(store,
                                       s->user->user_id,
                                       s->user->display_name,
                                       read_list,
                                       write_list,
                                       *rw_mask);
    if (r < 0) {
      return r;
    }

    *policy = swift_policy;
    *has_policy = true;
  }

  *has_cors = false;

  /*Check and update CORS configuration*/
  const char *allow_origins = s->info.env->get("HTTP_X_CONTAINER_META_ACCESS_CONTROL_ALLOW_ORIGIN");
  const char *allow_headers = s->info.env->get("HTTP_X_CONTAINER_META_ACCESS_CONTROL_ALLOW_HEADERS");
  const char *expose_headers = s->info.env->get("HTTP_X_CONTAINER_META_ACCESS_CONTROL_EXPOSE_HEADERS");
  const char *max_age = s->info.env->get("HTTP_X_CONTAINER_META_ACCESS_CONTROL_MAX_AGE");
  if (allow_origins) {
    RGWCORSConfiguration_SWIFT *swift_cors = new RGWCORSConfiguration_SWIFT;
    int r = swift_cors->create_update(allow_origins, allow_headers, expose_headers, max_age);
    if (r < 0) {
      dout(0) << "Error creating/updating the cors configuration" << dendl;
      delete swift_cors;
      return r;
    }
    *has_cors = true;
    *cors_config = *swift_cors;
    cors_config->dump();
    delete swift_cors;
  }

  return 0;
}


RGWOp *RGWHandler_REST_Obj_SWIFT::get_obj_op(bool get_data)
{
  if (is_acl_op()) {
    return new RGWGetACLs_ObjStore_SWIFT;
  }

  RGWGetObj_ObjStore_SWIFT *get_obj_op = new RGWGetObj_ObjStore_SWIFT;
  get_obj_op->set_get_data(get_data);
  return get_obj_op;
}


void RGWInfo_ObjStore_SWIFT::list_slo_data(Formatter& formatter,
                                            const ConfigProxy& config,
                                            RGWRados& store)
{
  formatter.open_object_section("slo");
  formatter.dump_int("max_manifest_segments", config->rgw_max_slo_entries);
  formatter.close_section();
}


void RGWGetCrossDomainPolicy_ObjStore_SWIFT::send_response()
{
  set_req_state_err(s, op_ret);
  dump_errno(s);
  end_header(s, this, "application/xml");

  std::stringstream ss;

  ss << R"(<?xml version="1.0"?>)" << "\n"
     << R"(<!DOCTYPE cross-domain-policy SYSTEM )"
     << R"("http://www.adobe.com/xml/dtds/cross-domain-policy.dtd" >)" << "\n"
     << R"(<cross-domain-policy>)" << "\n"
     << g_conf()->rgw_cross_domain_policy << "\n"
     << R"(</cross-domain-policy>)";

  dump_body(s, ss.str());
}


static bool usbredir_bulk_receiving_needed(void *priv)
{
    struct endp_data *endp = priv;

    return endp->bulk_receiving_started;
}


static int usbredir_put_bufpq(QEMUFile *f, void *priv, size_t unused,
                              const VMStateField *field, JSONWriter *vmdesc)
{
    struct endp_data *endp = priv;
    USBRedirDevice *dev = endp->dev;
    struct buf_packet *bufp;
    int len, i = 0;

    qemu_put_be32(f, endp->bufpq_size);
    QTAILQ_FOREACH(bufp, &endp->bufpq, next) {
        len = bufp->len - bufp->offset;
        DPRINTF("put_bufpq %d/%d len %d status %d\n", i + 1, endp->bufpq_size,
                len, bufp->status);
        qemu_put_be32(f, len);
        qemu_put_be32(f, bufp->status);
        qemu_put_buffer(f, bufp->data + bufp->offset, len);
        i++;
    }
    assert(i == endp->bufpq_size);

    return 0;
}


static void usbredir_ep_stopped(USBDevice *udev, USBEndpoint *uep)
{
    USBRedirDevice *dev = USB_REDIRECT(udev);

    usbredir_stop_ep(dev, USBEP2I(uep));
    usbredirparser_do_write(dev->parser);
}


static void usbredir_device_connect(void *priv,
    struct usb_redir_device_connect_header *device_connect)
{
    USBRedirDevice *dev = priv;
    const char *speed;

    if (timer_pending(dev->attach_timer) || dev->dev.attached) {
        ERROR("Received device connect while already connected\n");
        return;
    }

    switch (device_connect->speed) {
    case usb_redir_speed_low:
        speed = "low speed";
        dev->dev.speed = USB_SPEED_LOW;
        dev->compatible_speedmask &= ~USB_SPEED_MASK_FULL;
        dev->compatible_speedmask &= ~USB_SPEED_MASK_HIGH;
        break;
    case usb_redir_speed_full:
        speed = "full speed";
        dev->dev.speed = USB_SPEED_FULL;
        dev->compatible_speedmask &= ~USB_SPEED_MASK_HIGH;
        break;
    case usb_redir_speed_high:
        speed = "high speed";
        dev->dev.speed = USB_SPEED_HIGH;
        break;
    case usb_redir_speed_super:
        speed = "super speed";
        dev->dev.speed = USB_SPEED_SUPER;
        break;
    default:
        speed = "unknown speed";
        dev->dev.speed = USB_SPEED_FULL;
    }

    if (usbredirparser_peer_has_cap(dev->parser,
                                    usb_redir_cap_connect_device_version)) {
        INFO("attaching %s device %04x:%04x version %d.%d class %02x\n",
             speed, device_connect->vendor_id, device_connect->product_id,
             ((device_connect->device_version_bcd & 0xf000) >> 12) * 10 +
             ((device_connect->device_version_bcd & 0x0f00) >>  8),
             ((device_connect->device_version_bcd & 0x00f0) >>  4) * 10 +
             ((device_connect->device_version_bcd & 0x000f) >>  0),
             device_connect->device_class);
    } else {
        INFO("attaching %s device %04x:%04x class %02x\n", speed,
             device_connect->vendor_id, device_connect->product_id,
             device_connect->device_class);
    }

    dev->dev.speedmask = (1 << dev->dev.speed) | dev->compatible_speedmask;
    dev->device_info = *device_connect;

    if (usbredir_check_filter(dev)) {
        WARNING("Device %04x:%04x rejected by device filter, not attaching\n",
                device_connect->vendor_id, device_connect->product_id);
        return;
    }

    usbredir_check_bulk_receiving(dev);
    timer_mod(dev->attach_timer, dev->next_attach_time);
}


static void usbredir_iso_stream_status(void *priv, uint64_t id,
    struct usb_redir_iso_stream_status_header *iso_stream_status)
{
    USBRedirDevice *dev = priv;
    uint8_t ep = iso_stream_status->endpoint;

    DPRINTF("iso status %d ep %02X id %"PRIu64"\n", iso_stream_status->status,
            ep, id);

    if (!dev->dev.attached || !dev->endpoint[EP2I(ep)].iso_started) {
        return;
    }

    dev->endpoint[EP2I(ep)].iso_error = iso_stream_status->status;
    if (iso_stream_status->status == usb_redir_stall) {
        DPRINTF("iso stream stopped by peer ep %02X\n", ep);
        dev->endpoint[EP2I(ep)].iso_started = 0;
    }
}


static void usbredir_chardev_event(void *opaque, QEMUChrEvent event)
{
    USBRedirDevice *dev = opaque;

    switch (event) {
    case CHR_EVENT_OPENED:
        DPRINTF("chardev open\n");
        /* Make sure any pending closes are handled (no-op if none pending) */
        usbredir_chardev_close_bh(dev);
        qemu_bh_cancel(dev->chardev_close_bh);
        usbredir_create_parser(dev);
        break;
    case CHR_EVENT_CLOSED:
        DPRINTF("chardev close\n");
        qemu_bh_schedule(dev->chardev_close_bh);
        break;
    case CHR_EVENT_BREAK:
    case CHR_EVENT_MUX_IN:
    case CHR_EVENT_MUX_OUT:
        /* Ignore */
        break;
    }
}


static int packet_id_queue_remove(struct PacketIdQueue *q, uint64_t id)
{
    USBRedirDevice *dev = q->dev;
    struct PacketIdQueueEntry *e;

    QTAILQ_FOREACH(e, &q->head, next) {
        if (e->id == id) {
            DPRINTF("removing packet id %"PRIu64" from %s queue\n",
                    id, q->name);
            QTAILQ_REMOVE(&q->head, e, next);
            q->size--;
            g_free(e);
            return 1;
        }
    }
    return 0;
}


static void usbredir_set_pipeline(USBRedirDevice *dev, struct USBEndpoint *uep)
{
    if (uep->type != USB_ENDPOINT_XFER_BULK) {
        return;
    }
    if (uep->pid == USB_TOKEN_OUT) {
        uep->pipeline = true;
    }
    if (uep->pid == USB_TOKEN_IN && uep->max_packet_size != 0 &&
        usbredirparser_peer_has_cap(dev->parser,
                                    usb_redir_cap_32bits_bulk_length)) {
        uep->pipeline = true;
    }
}


static void usbredir_do_attach(void *opaque)
{
    USBRedirDevice *dev = opaque;
    Error *local_err = NULL;

    /* In order to work properly with XHCI controllers we need these caps */
    if ((dev->dev.port->speedmask & USB_SPEED_MASK_SUPER) && !(
        usbredirparser_peer_has_cap(dev->parser,
                                    usb_redir_cap_ep_info_max_packet_size) &&
        usbredirparser_peer_has_cap(dev->parser,
                                    usb_redir_cap_32bits_bulk_length) &&
        usbredirparser_peer_has_cap(dev->parser,
                                    usb_redir_cap_64bits_ids))) {
        ERROR("usb-redir-host lacks capabilities needed for use with XHCI\n");
        usbredir_reject_device(dev);
        return;
    }

    usb_device_attach(&dev->dev, &local_err);
    if (local_err) {
        error_report_err(local_err);
        WARNING("rejecting device due to speed mismatch\n");
        usbredir_reject_device(dev);
    }
}


static bool usbredir_stream_needed(void *priv)
{
    struct endp_data *endp = priv;

    return endp->max_streams;
}


static gboolean usbredir_write_unblocked(GIOChannel *chan, GIOCondition cond,
                                         void *opaque)
{
    USBRedirDevice *dev = opaque;

    dev->watch = 0;
    usbredirparser_do_write(dev->parser);

    return FALSE;
}


static void usbredir_bulk_receiving_status(void *priv, uint64_t id,
    struct usb_redir_bulk_receiving_status_header *bulk_receiving_status)
{
    USBRedirDevice *dev = priv;
    uint8_t ep = bulk_receiving_status->endpoint;

    DPRINTF("bulk recv status %d ep %02X id %"PRIu64"\n",
            bulk_receiving_status->status, ep, id);

    if (!dev->dev.attached || !dev->endpoint[EP2I(ep)].bulk_receiving_started) {
        return;
    }

    if (bulk_receiving_status->status == usb_redir_stall) {
        DPRINTF("bulk receiving stopped by peer ep %02X\n", ep);
        dev->endpoint[EP2I(ep)].bulk_receiving_started = 0;
    }
}


static void usbredir_set_interface(USBRedirDevice *dev, USBPacket *p,
                                   int interface, int alt)
{
    struct usb_redir_set_alt_setting_header set_alt;
    int i;

    DPRINTF("set interface %d alt %d id %"PRIu64"\n", interface, alt, p->id);

    for (i = 0; i < MAX_ENDPOINTS; i++) {
        if (dev->endpoint[i].interface == interface) {
            usbredir_stop_ep(dev, i);
        }
    }

    set_alt.interface = interface;
    set_alt.alt = alt;
    usbredirparser_send_set_alt_setting(dev->parser, p->id, &set_alt);
    usbredirparser_do_write(dev->parser);
    p->status = USB_RET_ASYNC;
}


static void usbredir_bulk_packet(void *priv, uint64_t id,
    struct usb_redir_bulk_packet_header *bulk_packet,
    uint8_t *data, int data_len)
{
    USBRedirDevice *dev = priv;
    uint8_t ep = bulk_packet->endpoint;
    int len = (bulk_packet->length_high << 16) | bulk_packet->length;
    USBPacket *p;

    DPRINTF("bulk-in status %d ep %02X stream %u len %d id %"PRIu64"\n",
            bulk_packet->status, ep, bulk_packet->stream_id, len, id);

    p = usbredir_find_packet_by_id(dev, ep, id);
    if (p) {
        size_t size = usb_packet_size(p);
        usbredir_handle_status(dev, p, bulk_packet->status);
        if (data_len > 0) {
            usbredir_log_data(dev, "bulk data in:", data, data_len);
            if (data_len > size) {
                ERROR("bulk got more data then requested (%d > %zd)\n",
                      data_len, p->iov.size);
                p->status = USB_RET_BABBLE;
                data_len = len = size;
            }
            usb_packet_copy(p, data, data_len);
        }
        p->actual_length = len;
        if (p->pid == USB_TOKEN_IN && p->ep->pipeline) {
            usb_combined_input_packet_complete(&dev->dev, p);
        } else {
            usb_packet_complete(&dev->dev, p);
        }
    }
    free(data);
}


static void usbredir_handle_buffered_bulk_in_data(USBRedirDevice *dev,
    USBPacket *p, uint8_t ep)
{
    /* Input bulk endpoint, buffered packet input */
    if (!dev->endpoint[EP2I(ep)].bulk_receiving_started) {
        int bpt;
        struct usb_redir_start_bulk_receiving_header start = {
            .endpoint = ep,
            .stream_id = 0,
            .no_transfers = 5,
        };
        /* Round bytes_per_transfer up to a multiple of max_packet_size */
        bpt = 512 + dev->endpoint[EP2I(ep)].max_packet_size - 1;
        bpt /= dev->endpoint[EP2I(ep)].max_packet_size;
        bpt *= dev->endpoint[EP2I(ep)].max_packet_size;
        start.bytes_per_transfer = bpt;
        /* No id, we look at the ep when receiving a status back */
        usbredirparser_send_start_bulk_receiving(dev->parser, 0, &start);
        usbredirparser_do_write(dev->parser);
        DPRINTF("bulk receiving started bytes/transfer %u count %d ep %02X\n",
                start.bytes_per_transfer, start.no_transfers, ep);
        dev->endpoint[EP2I(ep)].bulk_receiving_started = 1;
        /* We don't really want to drop bulk packets ever, but
           having some upper limit to how much we buffer is good. */
        dev->endpoint[EP2I(ep)].bufpq_target_size = 5000;
        dev->endpoint[EP2I(ep)].bufpq_dropping_packets = 0;
    }

    if (QTAILQ_EMPTY(&dev->endpoint[EP2I(ep)].bufpq)) {
        DPRINTF("bulk-token-in ep %02X, no bulkp\n", ep);
        assert(dev->endpoint[EP2I(ep)].pending_async_packet == NULL);
        dev->endpoint[EP2I(ep)].pending_async_packet = p;
        p->status = USB_RET_ASYNC;
        return;
    }
    usbredir_buffered_bulk_in_complete(dev, p, ep);
}


static void packet_id_queue_init(struct PacketIdQueue *q,
    USBRedirDevice *dev, const char *name)
{
    q->dev = dev;
    q->name = name;
    QTAILQ_INIT(&q->head);
    q->size = 0;
}


int flb_gzip_compress(void *in_data, size_t in_len,
                      void **out_data, size_t *out_len)
{
    int flush;
    int status;
    int footer_start;
    uint8_t *pb;
    size_t out_size;
    void *out_buf;
    z_stream strm;
    mz_ulong crc;

    /*
     * GZIP relies on an algorithm with worst-case expansion
     * of 5 bytes per 32KB data. This means we need to create a variable
     * length output, that depends on the input length.
     * See RFC 1951 for details.
     */
    int max_input_expansion = ((int)(in_len / 32000) + 1) * 5;

    /*
     * Max compressed size is equal to sum of:
     *   10 byte header
     *   8 byte foot
     *   max input expansion
     *   size of input
     */
    out_size = 10 + 8 + max_input_expansion + in_len;
    out_buf = flb_malloc(out_size);

    if (!out_buf) {
        flb_errno();
        flb_error("[gzip] could not allocate outgoing buffer");
        return -1;
    }

    /* Initialize streaming buffer context */
    memset(&strm, '\0', sizeof(strm));
    strm.zalloc    = Z_NULL;
    strm.zfree     = Z_NULL;
    strm.opaque    = Z_NULL;
    strm.next_in   = in_data;
    strm.avail_in  = in_len;
    strm.total_out = 0;

    /* Deflate mode */
    deflateInit2(&strm, Z_DEFAULT_COMPRESSION,
                 Z_DEFLATED, -Z_DEFAULT_WINDOW_BITS, 9, Z_DEFAULT_STRATEGY);

    /*
     * Miniz don't support GZip format directly, instead we will:
     *
     * - append manual GZip magic bytes
     * - deflate raw content
     * - append manual CRC32 data
     */
    gzip_header(out_buf);

    /* Header offset */
    pb = (uint8_t *) out_buf + FLB_GZIP_HEADER_OFFSET;

    flush = Z_NO_FLUSH;
    while (1) {
        strm.next_out  = pb + strm.total_out;
        strm.avail_out = out_size - (pb - (uint8_t *) out_buf);

        if (strm.avail_in == 0) {
            flush = Z_FINISH;
        }

        status = deflate(&strm, flush);
        if (status == Z_STREAM_END) {
            break;
        }
        else if (status != Z_OK) {
            deflateEnd(&strm);
            return -1;
        }
    }

    if (deflateEnd(&strm) != Z_OK) {
        flb_free(out_buf);
        return -1;
    }
    *out_len = strm.total_out;

    /* Construct the gzip checksum (CRC32 footer) */
    footer_start = FLB_GZIP_HEADER_OFFSET + *out_len;
    pb = (uint8_t *) out_buf + footer_start;

    crc = mz_crc32(MZ_CRC32_INIT, in_data, in_len);
    *pb++ = crc & 0xFF;
    *pb++ = (crc >> 8) & 0xFF;
    *pb++ = (crc >> 16) & 0xFF;
    *pb++ = (crc >> 24) & 0xFF;
    *pb++ = in_len & 0xFF;
    *pb++ = (in_len >> 8) & 0xFF;
    *pb++ = (in_len >> 16) & 0xFF;
    *pb++ = (in_len >> 24) & 0xFF;

    /* Set the real buffer size for the caller */
    *out_len += FLB_GZIP_HEADER_OFFSET + 8;
    *out_data = out_buf;

    return 0;
}


static unsigned int read_le16(const unsigned char *p)
{
    return ((unsigned int) p[0]) | ((unsigned int) p[1] << 8);
}


defaultnodes(void fn(struct node *))
{
	struct edge *e;
	struct node *n;
	size_t i;

	if (ndeftarg > 0) {
		for (i = 0; i < ndeftarg; ++i)
			fn(deftarg[i]);
	} else {
		/* by default build all nodes which are not used by any edges */
		for (e = alledges; e; e = e->allnext) {
			for (i = 0; i < e->nout; ++i) {
				n = e->out[i];
				if (n->nuse == 0)
					fn(n);
			}
		}
	}
}


xreallocarray(void *p, size_t n, size_t m)
{
	p = reallocarray(p, n, m);
	if (!p)
		fatal("reallocarray:");

	return p;
}


TEST(QueryProjectionTest, PositionalProjectionDoesNotPreserveParent) {
    auto proj = createFindProjection("{'a.b': {$elemMatch: {$eq: 0}}}", "{'a.b.$': 1}");
    ASSERT_FALSE(proj.isFieldRetainedExactly("a"));
}


TEST(QueryProjectionTest, ProjectionWithROOTNeedsWholeDocument) {
    auto proj = createProjection("{}", "{a: '$$ROOT'}");
    ASSERT_FALSE(proj.isSimple());
    ASSERT_TRUE(proj.requiresDocument());
}


TEST(QueryProjectionTest, ExclusionProjectionPreservesNonExcludedFields) {
    auto proj = createProjection("{}", "{a: 0}");
    ASSERT_TRUE(proj.isFieldRetainedExactly("c"));
}


void parseElement(ParseContext* ctx,
                  BSONElement elem,
                  boost::optional<FieldPath> fullPathToParent,
                  ProjectionPathASTNode* parent) {
    const bool hasPositional = hasPositionalOperator(elem.fieldNameStringData());

    // If there is a positional projection, find only features must be enabled.
    uassert(31324,
            "Cannot use positional projection in aggregation projection",
            (!hasPositional || ctx->policies.findOnlyFeaturesAllowed()));

    // Be sure that uses of positional projection that were correct in versions before 4.4 that are
    // now incorrect get a good error message.
    uassert(31394,
            "As of 4.4, it's illegal to specify positional operator in the middle of a path."
            "Positional projection may only be used at the end, for example: a.b.$. If the query "
            "previously used a form like a.b.$.d, remove the parts following the '$' and the "
            "results will be equivalent.",
            !str::contains(elem.fieldNameStringData(), ".$."));

    if (elem.type() == BSONType::Object) {
        BSONObj subObj = elem.embeddedObject();

        // Make sure this isn't a positional operator. It's illegal to combine positional with
        // any expression.
        uassert(31271,
                "positional projection cannot be used with an expression or sub object",
                !hasPositional);

        parseSubObject(ctx, elem.fieldNameStringData(), fullPathToParent, subObj, parent);
    } else if (isInclusionOrExclusionType(elem.type())) {
        if (elem.trueValue()) {
            parseInclusion(ctx, elem, parent, fullPathToParent);
        } else {
            uassert(31395, "positional projection cannot be used with exclusion", !hasPositional);
            parseExclusion(ctx, elem, parent);
        }
    } else {
        uassert(31308, "positional projection cannot be used with a literal", !hasPositional);

        parseLiteral(ctx, elem, parent);
    }
}


TEST(QueryProjectionTest, MakeEmptyProjection) {
    ASSERT_THROWS_CODE(createProjection("{}", "{}"), AssertionException, 51272);
}


TEST(QueryProjectionTest, InclusionProjectionPreservesField) {
    auto proj = createProjection("{}", "{a: 1}");
    ASSERT_TRUE(proj.isFieldRetainedExactly("a"));
}


TEST(QueryProjectionTest, IdInclusionProjectionDoesNotPreserveOtherFields) {
    auto proj = createProjection("{}", "{_id: 1}");
    ASSERT_FALSE(proj.isFieldRetainedExactly("a"));
}


TEST(QueryProjectionTest, MakeSingleFieldFalseIdBoolean) {
    Projection proj(createProjection("{}", "{_id: false, a: 1}"));
    ASSERT_FALSE(proj.requiresDocument());
    const auto& fields = proj.getRequiredFields();
    ASSERT_EQUALS(fields.size(), 1U);
    ASSERT_EQUALS(fields[0], "a");
}


TEST(QueryProjectionTest, InvalidPositionalOperatorProjections) {
    assertInvalidFindProjection("{a: 1}", "{'a.$': 0}", 31395);
    assertInvalidFindProjection("{a: 1}", "{'a.$.d.$': 1}", 31394);
    assertInvalidFindProjection("{a: 1}", "{'a.$.$': 1}", 31394);
    assertInvalidFindProjection("{a: [1, 2, 3]}", "{'.$': 1}", 5392900);
}


void msetGenericCommand(client *c, int nx) {
    int j;

    if ((c->argc % 2) == 0) {
        addReplyError(c,"wrong number of arguments for MSET");
        return;
    }

    /* Handle the NX flag. The MSETNX semantic is to return zero and don't
     * set anything if at least one key already exists. */
    if (nx) {
        for (j = 1; j < c->argc; j += 2) {
            if (lookupKeyWrite(c->db,c->argv[j]) != NULL) {
                addReply(c, shared.czero);
                return;
            }
        }
    }

    for (j = 1; j < c->argc; j += 2) {
        c->argv[j+1] = tryObjectEncoding(c->argv[j+1]);
        setKey(c,c->db,c->argv[j],c->argv[j+1]);
        notifyKeyspaceEvent(NOTIFY_STRING,"set",c->argv[j],c->db->id);
    }
    server.dirty += (c->argc-1)/2;
    addReply(c, nx ? shared.cone : shared.ok);
}