<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2014 Tresys Technology, LLC. All rights reserved.
Developed by: Tresys Technology, LLC
http://www.tresys.com
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal with
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution.
3. Neither the names of Tresys Technology, nor the names of its contributors
may be used to endorse or promote products derived from this Software
without specific prior written permission.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
SOFTWARE.
-->
<!--
Version 1.1 pcap.dfdl.xsd
Change History
1.1: Support parsing link layer (ethernet), network layer (ipv4, ipv6, icmpv4)
and transport layer (tcp, udp)
This DFDL schema provides a DFDL model for PCAP v2.4 binary data, which
contains network packet capture data.
The message root is 'PCAP'.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:pcap="urn:pcap:2.4"
targetNamespace="urn:pcap:2.4">
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:defineVariable name="ByteOrder" type="xs:string" />
<dfdl:defineFormat name="defaults">
<dfdl:format alignment="1" alignmentUnits="bits"
binaryBooleanFalseRep="0" binaryBooleanTrueRep="1"
binaryCalendarEpoch="1970-01-01T00:00:00+00:00" binaryCalendarRep="bcd"
binaryDecimalVirtualPoint="0" binaryFloatRep="ieee"
binaryNumberCheckPolicy="lax" binaryNumberRep="binary"
binaryPackedSignCodes="C D F C" calendarCenturyStart="53"
calendarCheckPolicy="lax" calendarDaysInFirstWeek="4"
calendarFirstDayOfWeek="Monday" calendarLanguage="en-US"
calendarObserveDST="yes" calendarPatternKind="implicit"
calendarPattern="yyyy-MM-dd'T'HH:mm:ss" calendarTimeZone="UTC"
choiceLengthKind="implicit" decimalSigned="yes"
documentFinalTerminatorCanBeMissing="no" emptyValueDelimiterPolicy="none"
encoding="UTF-8" encodingErrorPolicy="replace" escapeSchemeRef=""
fillByte="0" floating="no" ignoreCase="no" initiatedContent="no"
initiator="" leadingSkip="0" lengthKind="implicit" lengthUnits="bits"
nilKind="literalValue" nilValueDelimiterPolicy="none" nilValue="NIL"
occursCountKind="implicit" outputNewLine="%CR;%LF;"
prefixIncludesPrefixLength="no" representation="binary" separator=""
separatorPosition="infix" sequenceKind="ordered" terminator=""
textBidi="no" textBooleanFalseRep="false" textBooleanJustification="left"
textBooleanPadCharacter="%SP;" textBooleanTrueRep="true"
textCalendarJustification="left" textCalendarPadCharacter="%SP;"
textNumberCheckPolicy="lax" textNumberJustification="right"
textNumberPadCharacter="0" textNumberPattern="#0" textNumberRep="standard"
textNumberRoundingIncrement="0.0" textNumberRoundingMode="roundUp"
textNumberRounding="pattern" textOutputMinLength="0" textPadKind="none"
textStandardBase="10" textStandardDecimalSeparator="."
textStandardGroupingSeparator="," textStandardInfinityRep="Inf"
textStandardNaNRep="NaN" textStandardZeroRep=""
textStringJustification="left" textStringPadCharacter="%SP;"
textTrimKind="none" textZonedSignStyle="asciiStandard" trailingSkip="0"
truncateSpecifiedLengthString="no" useNilForDefault="no" utf16Width="fixed"
bitOrder="mostSignificantBitFirst"/>
</dfdl:defineFormat>
<dfdl:format ref="pcap:defaults" byteOrder="{ $pcap:ByteOrder }" />
</xs:appinfo>
</xs:annotation>
<xs:simpleType name="uint16" dfdl:lengthKind="explicit" dfdl:length="16">
<xs:restriction base="xs:unsignedInt"/>
</xs:simpleType>
<xs:simpleType name="uint32" dfdl:lengthKind="explicit" dfdl:length="32">
<xs:restriction base="xs:unsignedInt"/>
</xs:simpleType>
<xs:simpleType name="int32" dfdl:lengthKind="explicit" dfdl:length="4" dfdl:lengthUnits="bytes">
<xs:restriction base="xs:int"/>
</xs:simpleType>
<xs:simpleType name="bit" dfdl:lengthKind="explicit" dfdl:byteOrder="bigEndian" dfdl:lengthUnits="bits">
<xs:restriction base="xs:unsignedInt" />
</xs:simpleType>
<xs:simpleType name="hexByte" dfdl:lengthKind="explicit" dfdl:byteOrder="bigEndian" dfdl:lengthUnits="bytes">
<xs:restriction base="xs:hexBinary" />
</xs:simpleType>
<xs:element name="PCAP">
<xs:complexType>
<xs:sequence>
<xs:element name="PCAPHeader">
<xs:complexType>
<xs:sequence>
<xs:element name="MagicNumber" type="xs:hexBinary" dfdl:lengthKind="explicit" dfdl:length="4" dfdl:lengthUnits="bytes" dfdl:byteOrder="bigEndian">
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:assert message="Magic number was not 0xA1B2C3D4 (for bigEndian) or 0xD4C3B2A1 (for littleEndian)."
test="{ (xs:string(.) eq 'A1B2C3D4') or (xs:string(.) eq 'D4C3B2A1') }" />
<dfdl:setVariable ref="pcap:ByteOrder" value="{ if (xs:string(.) eq 'A1B2C3D4') then 'bigEndian' else 'littleEndian' }" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Version">
<xs:complexType>
<xs:sequence>
<xs:element name="Major" type="pcap:uint16" />
<xs:element name="Minor" type="pcap:uint16" />
<xs:sequence>
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:assert message="PCAP version must be 2.4" test="{ (xs:unsignedInt(./Major) eq 2) and (xs:unsignedInt(./Minor) eq 4) }" />
</xs:appinfo>
</xs:annotation>
</xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Zone" type="pcap:int32" />
<xs:element name="SigFigs" type="pcap:uint32" />
<xs:element name="SnapLen" type="pcap:uint32" />
<xs:element name="Network" type="pcap:uint32" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Packet" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="PacketHeader">
<xs:complexType>
<xs:sequence>
<xs:element name="Seconds" type="pcap:uint32"/> <!-- TODO: ts_sec should be a dateTime -->
<xs:element name="USeconds" type="pcap:uint32"/>
<xs:element name="InclLen" type="pcap:uint32"/>
<xs:element name="OrigLen" type="pcap:uint32"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element ref="pcap:LinkLayer" dfdl:lengthUnits="bytes" dfdl:lengthKind="explicit" dfdl:length="{ ../PacketHeader/InclLen }"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- LINK LAYER -->
<xs:element name="LinkLayer">
<xs:complexType>
<xs:choice>
<xs:element ref="pcap:Ethernet" />
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="Ethernet">
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:discriminator message="Link layer type is not Ethernet" test="{ xs:unsignedInt(../../../PCAPHeader/Network) eq 1 }" />
</xs:appinfo>
</xs:annotation>
<xs:element name="MACDest" type="pcap:hexByte" dfdl:length="6" />
<xs:element name="MACSrc" type="pcap:hexByte" dfdl:length="6" />
<xs:element name="Ethertype" type="pcap:bit" dfdl:length="16" />
<xs:element ref="pcap:NetworkLayer" />
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- NETWORK LAYER -->
<xs:element name="NetworkLayer">
<xs:complexType>
<xs:choice>
<xs:element ref="pcap:IPv4" />
<xs:element ref="pcap:IPv6" />
</xs:choice>
</xs:complexType>
</xs:element>
<xs:simpleType name="IPSeg" dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="1">
<xs:restriction base="xs:unsignedInt"/>
</xs:simpleType>
<xs:group name="IPSrcGrp">
<xs:sequence>
<xs:element name="IPSrcByte" type="pcap:IPSeg" minOccurs="4" maxOccurs="4"/>
</xs:sequence>
</xs:group>
<xs:group name="IPDestGrp">
<xs:sequence>
<xs:element name="IPDestByte" type="pcap:IPSeg" minOccurs="4" maxOccurs="4"/>
</xs:sequence>
</xs:group>
<xs:element name="IPv4">
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:discriminator message="Ethertype is not IPv4" test="{ xs:unsignedInt(../../Ethertype) eq 2048 }" />
</xs:appinfo>
</xs:annotation>
<xs:element name='IPv4Header'>
<xs:complexType>
<xs:sequence>
<xs:element name="Version" type="pcap:bit" dfdl:length="4" />
<xs:element name="IHL" type="pcap:bit" dfdl:length="4" />
<xs:element name="DSCP" type="pcap:bit" dfdl:length="6" />
<xs:element name="ECN" type="pcap:bit" dfdl:length="2" />
<xs:element name="Length" type="pcap:bit" dfdl:length="16" />
<xs:element name="Identification" type="pcap:bit" dfdl:length="16" />
<xs:element name="Flags" type="pcap:bit" dfdl:length="3" />
<xs:element name="FragmentOffset" type="pcap:bit" dfdl:length="13" />
<xs:element name="TTL" type="pcap:bit" dfdl:length="8" />
<xs:element name="Protocol" type="pcap:bit" dfdl:length="8" />
<xs:element name="Checksum" type="pcap:bit" dfdl:length="16" />
<xs:sequence dfdl:hiddenGroupRef="pcap:IPSrcGrp"/>
<xs:element name="IPSrc" type="xs:string" dfdl:inputValueCalc="{ fn:concat(../IPSrcByte[1], '.', ../IPSrcByte[2], '.', ../IPSrcByte[3], '.', ../IPSrcByte[4]) }"/>
<xs:sequence dfdl:hiddenGroupRef="pcap:IPDestGrp"/>
<xs:element name="IPDest" type="xs:string" dfdl:inputValueCalc="{ fn:concat(../IPDestByte[1], '.', ../IPDestByte[2], '.', ../IPDestByte[3], '.', ../IPDestByte[4]) }"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="PayloadLength" type="xs:unsignedInt" dfdl:inputValueCalc="{ xs:unsignedInt(../IPv4Header/Length) - 20 }" />
<xs:element name="Protocol" type="xs:unsignedInt" dfdl:inputValueCalc="{ xs:unsignedInt(../IPv4Header/Protocol) }" />
<xs:choice>
<xs:element ref="pcap:TransportLayer" dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{ ../PayloadLength }" />
<xs:element ref="pcap:ICMPv4" dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{ ../PayloadLength }"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ICMPv4">
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:discriminator message="Protocol type is not ICMPv4" test="{ xs:unsignedInt(../Protocol) eq 1 }" />
</xs:appinfo>
</xs:annotation>
<xs:element name="Type" type="pcap:bit" dfdl:length="8" />
<xs:element name="Code" type="pcap:bit" dfdl:length="8" />
<xs:element name="Checksum" type="pcap:bit" dfdl:length="16" />
<xs:element name="Data" type="pcap:hexByte" dfdl:length="4" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="IPv6">
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:discriminator message="Ethertype is not IPv6" test="{ xs:unsignedInt(../../Ethertype) eq 34525 }" />
</xs:appinfo>
</xs:annotation>
<xs:element name='IPv6Header'>
<xs:complexType>
<xs:sequence>
<xs:element name="Version" type="pcap:bit" dfdl:length="4" />
<xs:element name="TrafficClass" type="pcap:bit" dfdl:length="8" />
<xs:element name="FlowLabel" type="pcap:bit" dfdl:length="20" />
<xs:element name="PayloadLength" type="pcap:bit" dfdl:length="16" />
<xs:element name="NextHeader" type="pcap:bit" dfdl:length="8" /> <!-- TODO: Add support for extension headers -->
<xs:element name="HopLimit" type="pcap:bit" dfdl:length="8" />
<xs:element name="IPSrc" type="pcap:hexByte" dfdl:length="16" />
<xs:element name="IPDest" type="pcap:hexByte" dfdl:length="16" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="PayloadLength" type="xs:unsignedInt" dfdl:inputValueCalc="{ xs:unsignedInt(../IPv6Header/PayloadLength) }" />
<xs:element name="Protocol" type="xs:unsignedInt" dfdl:inputValueCalc="{ xs:unsignedInt(../IPv6Header/NextHeader) }" />
<xs:element ref="pcap:TransportLayer" dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{ ../PayloadLength }" />
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- TRANSPORT LAYER -->
<xs:element name="TransportLayer">
<xs:complexType>
<xs:choice>
<xs:element ref="pcap:TCP" />
<xs:element ref="pcap:UDP" />
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="TCP">
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:discriminator message="Protocol type is not TCP" test="{ xs:unsignedInt(../../Protocol) eq 6 }" />
</xs:appinfo>
</xs:annotation>
<xs:element name='TCPHeader'>
<xs:complexType>
<xs:sequence>
<xs:element name="PortSRC" type="pcap:bit" dfdl:length="16" />
<xs:element name="PortDest" type="pcap:bit" dfdl:length="16" />
<xs:element name="Seq" type="pcap:bit" dfdl:length="32" />
<xs:element name="Ack" type="pcap:bit" dfdl:length="32" />
<xs:element name="DataOffset" type="pcap:bit" dfdl:length="4" />
<xs:element name="Reserved" type="pcap:bit" dfdl:length="3" />
<xs:element name="Flags" type="pcap:bit" dfdl:length="9" />
<xs:element name="WindowSize" type="pcap:bit" dfdl:length="16" />
<xs:element name="Checksum" type="pcap:bit" dfdl:length="16" />
<xs:element name="Urgent" type="pcap:bit" dfdl:length="16" />
<xs:element name="Options" type="pcap:hexByte" dfdl:length="{ (xs:unsignedInt(../DataOffset) - 5) * 4 }" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Data" type="pcap:hexByte" dfdl:length="{ xs:unsignedInt(../../../PayloadLength) - (xs:unsignedInt(../TCPHeader/DataOffset) * 4) }"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="UDP">
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:discriminator message="Protocol type is not UDP" test="{ xs:unsignedInt(../../Protocol) eq 17 }" />
</xs:appinfo>
</xs:annotation>
<xs:element name='UDPHeader'>
<xs:complexType>
<xs:sequence>
<xs:element name="PortSrc" type="pcap:bit" dfdl:length="16" />
<xs:element name="PortDest" type="pcap:bit" dfdl:length="16" />
<xs:element name="Length" type="pcap:bit" dfdl:length="16" />
<xs:element name="Checksum" type="pcap:bit" dfdl:length="16" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Data" type="pcap:hexByte" dfdl:length="{ xs:unsignedInt(../UDPHeader/Length) - 8 }"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema> |