generic_scenario.xsl 16.9 KB
Newer Older
gauthier's avatar
gauthier committed
1
<xsl:stylesheet version="1.0"
2
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
gauthier's avatar
gauthier committed
3
                
4
5
6
7
8
  <xsl:output
    method="xml"
    indent="yes"
    encoding="iso-8859-1"
  />
gauthier's avatar
gauthier committed
9

10
  <!-- Ugly but no time to find a better way in XSLT 1.0 (map/list)-->
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  <xsl:param name="enb0_s1c"   select="'0.0.0.0'"/>
  <xsl:param name="enb1_s1c"   select="'0.0.0.0'"/>
  <xsl:param name="enb2_s1c"   select="'0.0.0.0'"/>
  <xsl:param name="enb3_s1c"   select="'0.0.0.0'"/>
  <xsl:param name="enb4_s1c"   select="'0.0.0.0'"/>
  <xsl:param name="enb5_s1c"   select="'0.0.0.0'"/>
  <xsl:param name="enb6_s1c"   select="'0.0.0.0'"/>
  <xsl:param name="enb7_s1c"   select="'0.0.0.0'"/>
  <xsl:param name="mme0_s1c_0" select="'0.0.0.0'"/>
  <xsl:param name="mme0_s1c_1" select="'0.0.0.0'"/>
  <xsl:param name="mme0_s1c_2" select="'0.0.0.0'"/>
  <xsl:param name="mme0_s1c_3" select="'0.0.0.0'"/>
  <xsl:param name="mme1_s1c_0" select="'0.0.0.0'"/>
  <xsl:param name="mme1_s1c_1" select="'0.0.0.0'"/>
  <xsl:param name="mme1_s1c_2" select="'0.0.0.0'"/>
  <xsl:param name="mme1_s1c_3" select="'0.0.0.0'"/>
  <xsl:param name="mme2_s1c_0" select="'0.0.0.0'"/>
  <xsl:param name="mme2_s1c_1" select="'0.0.0.0'"/>
  <xsl:param name="mme2_s1c_2" select="'0.0.0.0'"/>
  <xsl:param name="mme2_s1c_3" select="'0.0.0.0'"/>
  <xsl:param name="mme3_s1c_0" select="'0.0.0.0'"/>
  <xsl:param name="mme3_s1c_1" select="'0.0.0.0'"/>
  <xsl:param name="mme3_s1c_2" select="'0.0.0.0'"/>
  <xsl:param name="mme3_s1c_3" select="'0.0.0.0'"/>
35
  <xsl:param name="ip_address" select="'0.0.0.0'"/>
gauthier's avatar
gauthier committed
36

37
38


39
40
41
  <xsl:template name="reverse_ip">
    <xsl:param name="ip_address"/>
      <xsl:choose>
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
        <xsl:when test="$ip_address=$enb0_s1c">enb0_s1c</xsl:when>
        <xsl:when test="$ip_address=$enb1_s1c">enb1_s1c</xsl:when>
        <xsl:when test="$ip_address=$enb2_s1c">enb2_s1c</xsl:when>
        <xsl:when test="$ip_address=$enb3_s1c">enb3_s1c</xsl:when>
        <xsl:when test="$ip_address=$enb4_s1c">enb4_s1c</xsl:when>
        <xsl:when test="$ip_address=$enb5_s1c">enb5_s1c</xsl:when>
        <xsl:when test="$ip_address=$enb6_s1c">enb6_s1c</xsl:when>
        <xsl:when test="$ip_address=$enb7_s1c">enb7_s1c</xsl:when>
        <xsl:when test="$ip_address=$mme0_s1c_0">mme0_s1c_0</xsl:when>
        <xsl:when test="$ip_address=$mme0_s1c_1">mme0_s1c_1</xsl:when>
        <xsl:when test="$ip_address=$mme0_s1c_2">mme0_s1c_2</xsl:when>
        <xsl:when test="$ip_address=$mme0_s1c_3">mme0_s1c_3</xsl:when>
        <xsl:when test="$ip_address=$mme1_s1c_0">mme1_s1c_0</xsl:when>
        <xsl:when test="$ip_address=$mme1_s1c_1">mme1_s1c_1</xsl:when>
        <xsl:when test="$ip_address=$mme1_s1c_2">mme1_s1c_2</xsl:when>
        <xsl:when test="$ip_address=$mme1_s1c_3">mme1_s1c_3</xsl:when>
        <xsl:when test="$ip_address=$mme2_s1c_0">mme2_s1c_0</xsl:when>
        <xsl:when test="$ip_address=$mme2_s1c_1">mme2_s1c_1</xsl:when>
        <xsl:when test="$ip_address=$mme2_s1c_2">mme2_s1c_2</xsl:when>
        <xsl:when test="$ip_address=$mme2_s1c_3">mme2_s1c_3</xsl:when>
        <xsl:when test="$ip_address=$mme3_s1c_0">mme3_s1c_0</xsl:when>
        <xsl:when test="$ip_address=$mme3_s1c_1">mme3_s1c_1</xsl:when>
        <xsl:when test="$ip_address=$mme3_s1c_2">mme3_s1c_2</xsl:when>
        <xsl:when test="$ip_address=$mme3_s1c_3">mme3_s1c_3</xsl:when>
66
67
68
69
70
71
        <xsl:otherwise>
          <xsl:message terminate="yes">ERROR: Cannot reverse resolv IP <xsl:value-of select="."/> !
          </xsl:message>
        </xsl:otherwise>
      </xsl:choose> 
  </xsl:template>
72

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
  <xsl:template name="enb_ip_2_enb_instance">
    <xsl:param name="ip_address"/>
      <xsl:choose>
        <xsl:when test="$ip_address=$enb0_s1c">0</xsl:when>
        <xsl:when test="$ip_address=$enb1_s1c">1</xsl:when>
        <xsl:when test="$ip_address=$enb2_s1c">2</xsl:when>
        <xsl:when test="$ip_address=$enb3_s1c">3</xsl:when>
        <xsl:when test="$ip_address=$enb4_s1c">4</xsl:when>
        <xsl:when test="$ip_address=$enb5_s1c">5</xsl:when>
        <xsl:when test="$ip_address=$enb6_s1c">6</xsl:when>
        <xsl:when test="$ip_address=$enb7_s1c">7</xsl:when>
        <xsl:otherwise>
          <xsl:message terminate="yes">ERROR: Cannot set eNB instance <xsl:value-of select="."/> !
          </xsl:message>
        </xsl:otherwise>
      </xsl:choose> 
  </xsl:template>



93
94
  <xsl:template name="chunktype2str">
    <xsl:param name="chunk_type"/>
95
    <xsl:choose>
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
      <xsl:when test="$chunk_type='00'">DATA</xsl:when>
      <xsl:when test="$chunk_type='01'">INIT</xsl:when>
      <xsl:when test="$chunk_type='02'">INIT_ACK</xsl:when>
      <xsl:when test="$chunk_type='03'">SACK</xsl:when>
      <xsl:when test="$chunk_type='04'">HEARTBEAT</xsl:when>
      <xsl:when test="$chunk_type='05'">HEARTBEAT_ACK</xsl:when>
      <xsl:when test="$chunk_type='06'">ABORT</xsl:when>
      <xsl:when test="$chunk_type='07'">SHUTDOWN</xsl:when>
      <xsl:when test="$chunk_type='08'">SHUTDOWN_ACK</xsl:when>
      <xsl:when test="$chunk_type='09'">ERROR</xsl:when>
      <xsl:when test="$chunk_type='0a'">COOKIE_ECHO</xsl:when>
      <xsl:when test="$chunk_type='0b'">COOKIE_ACK</xsl:when>
      <xsl:when test="$chunk_type='0c'">ECNE</xsl:when>
      <xsl:when test="$chunk_type='0d'">CWR</xsl:when>
      <xsl:when test="$chunk_type='0e'">SHUTDOWN_COMPLETE</xsl:when>
      <xsl:otherwise>
        <xsl:message terminate="yes">ERROR: UNKNOWN CHUNK TYPE <xsl:value-of select="."/> !
        </xsl:message>
      </xsl:otherwise>
115
    </xsl:choose> 
116
  </xsl:template>
117
118


119
  <xsl:strip-space elements="pdml packet proto field"/>
120

121
  <xsl:template match="/">
122
    <scenario name="{$test_name}">
123
      <xsl:apply-templates/>
124
    </scenario>
125
  </xsl:template>
gauthier's avatar
gauthier committed
126

127
  <xsl:template match="proto[@name='frame']">
gauthier's avatar
gauthier committed
128
    <xsl:variable name="time_relative" select="field[@name='frame.time_relative']/@show"/>
gauthier's avatar
gauthier committed
129
    <xsl:variable name="frame_number" select="field[@name='frame.number']/@show"/>
gauthier's avatar
gauthier committed
130
    <xsl:variable name="ip" select="proto[@name='ip']"/>
131
132
133
134
    <xsl:variable name="ip_src">
      <xsl:call-template name="reverse_ip">
        <xsl:with-param name="ip_address" select="$ip/field[@name='ip.src']/@show"/>
      </xsl:call-template>
135
    </xsl:variable>
136
137
138
139
140
141
142
    <xsl:variable name="ip_dst">
      <xsl:call-template name="reverse_ip">
        <xsl:with-param name="ip_address" select="$ip/field[@name='ip.dst']/@show"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="action">
      <xsl:choose>
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
        <xsl:when test="starts-with($ip_src,'enb')">SEND</xsl:when>
        <xsl:when test="starts-with($ip_src,'mme')">RECEIVE</xsl:when>
        <xsl:otherwise>
          <xsl:message terminate="yes">ERROR: UNKNOWN ACTION <xsl:value-of select="."/> !
          </xsl:message>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="enb_instance">
      <xsl:choose>
        <xsl:when test="starts-with($ip_src,'enb')">
          <xsl:call-template name="enb_ip_2_enb_instance">
            <xsl:with-param name="ip_address" select="$ip/field[@name='ip.src']/@show"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:when test="starts-with($ip_dst,'enb')">
          <xsl:call-template name="enb_ip_2_enb_instance">
            <xsl:with-param name="ip_address" select="$ip/field[@name='ip.dst']/@show"/>
          </xsl:call-template>
        </xsl:when>
163
164
165
166
167
        <xsl:otherwise>
          <xsl:message terminate="yes">ERROR: UNKNOWN ACTION <xsl:value-of select="."/> !
          </xsl:message>
        </xsl:otherwise>
      </xsl:choose>
168
    </xsl:variable>
gauthier's avatar
gauthier committed
169
170
    
    <xsl:for-each select="$ip/proto[@name='sctp']">
171
172
      <xsl:variable name="sctp_data_sid"               select="./field/field[@name='sctp.data_sid']/@show"/>
      <!-- TODO resolv problem of 2 SCTP packets in 1 IP packet: src and dst ports are not in the 2nd SCTP packet -->
gauthier's avatar
gauthier committed
173
174
175
176
      <!--xsl:variable name="sctp_srcport"                select="./field[@name='sctp.srcport']/@show"/-->
      <!--xsl:variable name="sctp_dstport"                select="./field[@name='sctp.dstport']/@show"/-->
      <!--xsl:variable name="sctp_data_ssn"               select="./field/field[@name='sctp.data_ssn']/@show"/-->
      <!--xsl:variable name="sctp_data_payload_proto_id"  select="./field/field[@name='sctp.data_payload_proto_id']/@show"/-->
177
178
179
180
181
182
      <xsl:variable name="sctp_chunk_type_str">
        <xsl:call-template name="chunktype2str">
          <xsl:with-param name="chunk_type" select="./field/field[@name='sctp.chunk_type']/@value"/>
        </xsl:call-template>
      </xsl:variable>
      <xsl:variable name="sctp_pos_offset" select="./@pos"/>
gauthier's avatar
gauthier committed
183
      <xsl:variable name="sctp_node" select="."/>
184

185
186
187
      <xsl:choose>
        <xsl:when test="$sctp_chunk_type_str='DATA'">
          <xsl:for-each select="./proto[@name='s1ap']">
188
            <xsl:variable name="s1ap_pos_offset" select="./@pos"/>
gauthier's avatar
gauthier committed
189
            <packet name="{$sctp_chunk_type_str}" action="{$action}">
190
              <frame.time_relative        value="{$time_relative}"/>
gauthier's avatar
gauthier committed
191
              <frame.number               value="{$frame_number}"/>
192
               
193
194
195
196
              <!-- TODO: pos_offset(substract it from all pos_offsets in s1ap, may depend on which test scenario protocol target S1AP/NAS or NAS only...)-->
              <pos_offset                 value="{$s1ap_pos_offset}"/>
              <ip.src                     value="{$ip_src}"/>
              <ip.dst                     value="{$ip_dst}"/>
197
              <eNB.instance               value="{$enb_instance}"/>
gauthier's avatar
gauthier committed
198
199
200
201
202
              <!--sctp.data_sid              value="{$sctp_data_sid}"/-->
              <!--sctp.srcport               value="{$sctp_srcport}"/-->
              <!--sctp.dstport               value="{$sctp_dstport}"/-->
              <!--sctp.data_ssn              value="{$sctp_data_ssn}"/-->
              <!--sctp.data_payload_proto_id value="{$sctp_data_payload_proto_id}"/-->
203
              <sctp.chunk_type_str        value="{$sctp_chunk_type_str}"/>
gauthier's avatar
gauthier committed
204
              <xsl:copy-of select="$sctp_node"/>
gauthier's avatar
gauthier committed
205
            </packet>
206
207
208
          </xsl:for-each>
        </xsl:when>
        <xsl:when test="$sctp_chunk_type_str='INIT'">
gauthier's avatar
gauthier committed
209
210
211
          <!--xsl:variable name="sctp_init_nr_out_streams"  select="./field/field[@name='sctp.init_nr_out_streams']/@show"/-->
          <!--xsl:variable name="sctp_init_nr_in_streams"   select="./field/field[@name='sctp.init_nr_in_streams']/@show"/-->
          <!--xsl:variable name="sctp_init_initial_tsn"     select="./field/field[@name='sctp.init_initial_tsn']/@show"/-->
gauthier's avatar
gauthier committed
212
          <packet name="{$sctp_chunk_type_str}" action="{$action}">
213
            <frame.time_relative        value="{$time_relative}"/>
gauthier's avatar
gauthier committed
214
            <frame.number               value="{$frame_number}"/>
215
216
217
218
            <!-- TODO: pos_offset(substract it from all pos_offsets in s1ap, may depend on which test scenario protocol target S1AP/NAS or NAS only...)-->
            <pos_offset                 value="{$sctp_pos_offset}"/>
            <ip.src                     value="{$ip_src}"/>
            <ip.dst                     value="{$ip_dst}"/>
219
            <eNB.instance               value="{$enb_instance}"/>
gauthier's avatar
gauthier committed
220
221
222
223
224
            <!--sctp.srcport               value="{$sctp_srcport}"/-->
            <!--sctp.dstport               value="{$sctp_dstport}"/-->
            <!--sctp.init_nr_in_streams    value="{$sctp_init_nr_in_streams}"/-->
            <!--sctp.init_nr_out_streams   value="{$sctp_init_nr_out_streams}"/-->
            <!--sctp.init_initial_tsn      value="{$sctp_init_initial_tsn}"/-->
225
            <sctp.chunk_type_str        value="{$sctp_chunk_type_str}"/>
gauthier's avatar
gauthier committed
226
            <xsl:copy-of select="$sctp_node"/>
gauthier's avatar
gauthier committed
227
          </packet>
228
229
        </xsl:when>
        <xsl:when test="$sctp_chunk_type_str='INIT_ACK'">
gauthier's avatar
gauthier committed
230
231
232
          <!--xsl:variable name="sctp_initack_nr_out_streams"  select="./field/field[@name='sctp.initack_nr_out_streams']/@show"/-->
          <!--xsl:variable name="sctp_initack_nr_in_streams"   select="./field/field[@name='sctp.initack_nr_in_streams']/@show"/-->
          <!--xsl:variable name="sctp_initack_initial_tsn"     select="./field/field[@name='sctp.initack_initial_tsn']/@show"/-->
gauthier's avatar
gauthier committed
233
          <packet name="{$sctp_chunk_type_str}" action="{$action}">
234
            <frame.time_relative        value="{$time_relative}"/>
gauthier's avatar
gauthier committed
235
            <frame.number               value="{$frame_number}"/>
236
237
238
239
            <!-- TODO: pos_offset(substract it from all pos_offsets in s1ap, may depend on which test scenario protocol target S1AP/NAS or NAS only...)-->
            <pos_offset                 value="{$sctp_pos_offset}"/>
            <ip.src                     value="{$ip_src}"/>
            <ip.dst                     value="{$ip_dst}"/>
240
            <eNB.instance               value="{$enb_instance}"/>
gauthier's avatar
gauthier committed
241
242
243
244
245
246
            <!--sctp.data_sid              value="{$sctp_data_sid}"/-->
            <!--sctp.srcport               value="{$sctp_srcport}"/-->
            <!--sctp.dstport               value="{$sctp_dstport}"/-->
            <!--sctp.initack_nr_in_streams  value="{$sctp_initack_nr_in_streams}"/-->
            <!--sctp.initack_nr_out_streams value="{$sctp_initack_nr_out_streams}"/-->
            <!--sctp.initack_initial_tsn   value="{$sctp_initack_initial_tsn}"/-->
247
            <sctp.chunk_type_str        value="{$sctp_chunk_type_str}"/>
gauthier's avatar
gauthier committed
248
            <xsl:copy-of select="$sctp_node"/>
gauthier's avatar
gauthier committed
249
          </packet>
250
251
252
253
254
        </xsl:when>
        <!--xsl:when test="$sctp_chunk_type_str='SACK'">       </xsl:when-->
        <!--xsl:when test="$sctp_chunk_type_str='HEARTBEAT'"></xsl:when-->
        <!--xsl:when test="$sctp_chunk_type_str='HEARTBEAT_ACK'"></xsl:when-->
        <xsl:when test="$sctp_chunk_type_str='ABORT'">
gauthier's avatar
gauthier committed
255
          <packet name="{$sctp_chunk_type_str}" action="{$action}">
256
            <frame.time_relative        value="{$time_relative}"/>
gauthier's avatar
gauthier committed
257
            <frame.number               value="{$frame_number}"/>
258
259
260
261
            <!-- TODO: pos_offset(substract it from all pos_offsets in s1ap, may depend on which test scenario protocol target S1AP/NAS or NAS only...)-->
            <pos_offset                 value="{$sctp_pos_offset}"/>
            <ip.src                     value="{$ip_src}"/>
            <ip.dst                     value="{$ip_dst}"/>
262
            <eNB.instance               value="{$enb_instance}"/>
gauthier's avatar
gauthier committed
263
264
265
            <!--sctp.data_sid              value="{$sctp_data_sid}"/-->
            <!--sctp.srcport               value="{$sctp_srcport}"/-->
            <!--sctp.dstport               value="{$sctp_dstport}"/-->
266
            <sctp.chunk_type_str        value="{$sctp_chunk_type_str}"/>
gauthier's avatar
gauthier committed
267
            <xsl:copy-of select="$sctp_node"/>
gauthier's avatar
gauthier committed
268
          </packet>
269
270
        </xsl:when>
        <xsl:when test="$sctp_chunk_type_str='SHUTDOWN'">
gauthier's avatar
gauthier committed
271
          <packet name="{$sctp_chunk_type_str}" action="{$action}">
272
            <frame.time_relative        value="{$time_relative}"/>
gauthier's avatar
gauthier committed
273
            <frame.number               value="{$frame_number}"/>
274
275
276
277
            <!-- TODO: pos_offset(substract it from all pos_offsets in s1ap, may depend on which test scenario protocol target S1AP/NAS or NAS only...)-->
            <pos_offset                 value="{$sctp_pos_offset}"/>
            <ip.src                     value="{$ip_src}"/>
            <ip.dst                     value="{$ip_dst}"/>
278
            <eNB.instance               value="{$enb_instance}"/>
gauthier's avatar
gauthier committed
279
280
281
            <!--sctp.data_sid              value="{$sctp_data_sid}"/-->
            <!--sctp.srcport               value="{$sctp_srcport}"/-->
            <!--sctp.dstport               value="{$sctp_dstport}"/-->
282
            <sctp.chunk_type_str        value="{$sctp_chunk_type_str}"/>
gauthier's avatar
gauthier committed
283
            <xsl:copy-of select="$sctp_node"/>
gauthier's avatar
gauthier committed
284
          </packet>
285
286
287
        </xsl:when>
        <!--xsl:when test="$sctp_chunk_type_str='SHUTDOWN_ACK'"></xsl:when-->
        <xsl:when test="$sctp_chunk_type_str='ERROR'">
gauthier's avatar
gauthier committed
288
          <packet name="{$sctp_chunk_type_str}" action="{$action}">
289
            <frame.time_relative        value="{$time_relative}"/>
gauthier's avatar
gauthier committed
290
            <frame.number               value="{$frame_number}"/>
291
292
293
294
            <!-- TODO: pos_offset(substract it from all pos_offsets in s1ap, may depend on which test scenario protocol target S1AP/NAS or NAS only...)-->
            <pos_offset                 value="{$sctp_pos_offset}"/>
            <ip.src                     value="{$ip_src}"/>
            <ip.dst                     value="{$ip_dst}"/>
295
            <eNB.instance               value="{$enb_instance}"/>
gauthier's avatar
gauthier committed
296
297
298
            <!--sctp.data_sid              value="{$sctp_data_sid}"/-->
            <!--sctp.srcport               value="{$sctp_srcport}"/-->
            <!--sctp.dstport               value="{$sctp_dstport}"/-->
299
            <sctp.chunk_type_str        value="{$sctp_chunk_type_str}"/>
gauthier's avatar
gauthier committed
300
            <xsl:copy-of select="$sctp_node"/>
gauthier's avatar
gauthier committed
301
          </packet>
302
303
304
305
306
307
308
309
        </xsl:when>
        <!--xsl:when test="$sctp_chunk_type_str='COOKIE_ECHO'">            </xsl:when-->
        <!--xsl:when test="$sctp_chunk_type_str='COOKIE_ACK'">            </xsl:when-->
        <!--xsl:when test="$sctp_chunk_type_str='ECNE'">            </xsl:when-->
        <!--xsl:when test="$sctp_chunk_type_str='CWR'">            </xsl:when-->
        <!--xsl:when test="$sctp_chunk_type_str='SHUTDOWN_COMPLETE'">            </xsl:when-->
        <xsl:otherwise></xsl:otherwise>
      </xsl:choose> 
gauthier's avatar
gauthier committed
310
    </xsl:for-each>
311
  </xsl:template>
gauthier's avatar
gauthier committed
312
</xsl:stylesheet>