summaryrefslogtreecommitdiff
path: root/lcmodule/source/cnh1606344_ldr_communication_module/config/audit_c.xsl
blob: fbc00fc68e6b34ec0cfa5a3e7af3206fdf480732 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Copyright (C) ST-Ericsson SA 2011
* License terms: 3-clause BSD license
-->
<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" >

<import href="common.xsl"/>

<output method="text"/>
<strip-space elements="*"/>
<param name="target" />

<param name="supportedCommands" />
<variable name="supported_commands" select="document($supportedCommands)/commandspec"/>

<template match="group/documentation" mode="array">
<variable name="group" select="../@number" />
<if test='$target="lcm" or $supported_commands/group[@number=$group]'>
/*
 * <value-of select="normalize-space(.)"/>
 */
</if>
</template>
  
<template match="group/documentation" mode="autharray">
<variable name="group" select="../@number" />
<if test='$target="lcm" or $supported_commands/group[@number=$group]'>
/*
 * <value-of select="normalize-space(.)"/>
 */
</if>
</template>
  
  
<template match="group/documentation" mode="staticarray">
<variable name="group" select="../@number" />
<if test='$target="lcm" or $supported_commands/group[@number=$group]'>
  /*
   * <value-of select="normalize-space(.)"/>
   */
</if>
</template>

<template name="staticarray">
<param name="name" />
<param name="direction" />
<choose>
<when test="name($direction)='input'">
  /* Command <value-of select="../@name" /> / <value-of select="@name" /> (<value-of select="../@number" /> / <value-of select="@number" />) */
</when>
<when test="name($direction)='output'">
  /* Response to <value-of select="../@name" /> / <value-of select="@name" /> (<value-of select="../@number" /> / <value-of select="@number" />) */
</when>
</choose>
  {
    <call-template name="groupid" ><with-param name="path" select=".."/></call-template>,
    <call-template name="commandid" />,
  <variable name="group" select="../@number" />
  <variable name="command" select="@number" />
    <choose>
      <when test='not($supported_commands/group[@number=$group]/command[@number=$command]/permissions)'>
    <choose>
      <when test="permissions"><text>  </text><apply-templates select="permissions/value" mode="permnumber" />,
  </when>
      <otherwise>  0,
  </otherwise>
  </choose>
    <choose>
      <when test="permissions">  PermArray_<value-of select="concat(../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />,
  </when>
      <otherwise>  NULL,
  </otherwise>
  </choose>
  </when>
  <otherwise>
    <choose>
      <when test="$supported_commands/group[@number=$group]/command[@number=$command]/permissions"><text>  </text><apply-templates select="$supported_commands/group[@number=$group]/command[@number=$command]/permissions/value" mode="permnumber" />,
  </when>
    <otherwise>  0,
  </otherwise>
  </choose>
    <choose>
      <when test="$supported_commands/group[@number=$group]/command[@number=$command]/permissions">  PermArray_<value-of select="concat(../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />,
  </when>
    <otherwise>  NULL,
  </otherwise>
  </choose>
  </otherwise>
  </choose>
    <choose>
      <when test="authentication"><text>  </text><apply-templates select="authentication/value" mode="authnumber" />,
  </when>
    <otherwise>  0,
  </otherwise>
  </choose>
    <choose>
    <when test="authentication">  AuthArray_<value-of select="concat(../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />,
  </when>
    <otherwise>  NULL,
  </otherwise>
  </choose>
    <choose>
    <when test="authentication">
      <choose>
        <when test="./authentication/@depandancy='and'">  1,
  </when>
        <when test="./authentication/@depandancy='or'">  2,
  </when>
        <when test="./authentication/@depandancy='xor'">  3,
  </when>
      </choose>
    </when>
    <otherwise>  0,
  </otherwise>
  </choose>
    <choose>
      <when test="authentication"><text>  </text><value-of select="./authentication/@factory"/>,
  </when>
    <otherwise>  FALSE,
  </otherwise>
  </choose>
    <choose>
      <when test="authentication"><text>  </text><value-of select="./authentication/@rd"/>,
  </when>
    <otherwise>  FALSE,
  </otherwise>
  </choose>
    <choose>
      <when test="authentication"><text>  </text><value-of select="./authentication/@product"/>,
  </when>
    <otherwise>  FALSE,
  </otherwise>
  </choose>
    <choose>
      <when test="authentication"><text>  </text><value-of select="./authentication/@service"/>,
  </when>
    <otherwise>  FALSE,
  </otherwise>
  </choose>  NULL
  },
</template>

  
<template match="/commandspec">/* $Copyright ST-Ericsson 2010 $ */
/* NOTE: This is an automatically generated file. DO NOT EDIT! */
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;

#include "t_command_protocol.h"
#include "r_debug.h"
#include "r_communication_service.h"
#include "commands.h"
#include "command_ids.h"
#include "commands_impl.h"
#include "error_codes.h"
#include "r_serialization.h"
#include "r_command_protocol.h"
#include "audit.h"

#ifdef CFG_ENABLE_AUDIT_CMD
#include "r_loader_sec_lib.h"
#endif

#ifdef CFG_ENABLE_ADBG_LOADER
#include "r_adbg_command.h"
#endif

/*
 * Command Permissions Vectors.
 */
<apply-templates select="group" mode="array"/>
/*
 * Command Authentication Vectors.
 */
<apply-templates select="group" mode="autharray"/>

CommandPermissionList_t CommandPermissionList[]=
{<apply-templates select="group" mode="staticarray"/>
  /* End of array */
  {
    0,
    (CommandId_e)0,
    0,
    NULL,
    0,
    NULL,
    0,
    FALSE,
    FALSE,
    FALSE,
    FALSE,
    NULL
  }
};

CommandPermissionList_t * GetAuditData(CommandData_t * CmdData_p)
{
/*
  boolean A1_Authentication = FALSE;
  boolean CA_Authentication = FALSE;

  boolean A1_Factory        = FALSE;
  boolean A1_RD             = FALSE;
  boolean A1_Product        = FALSE;
  boolean A1_Service        = FALSE;
  
  uint8 A1_depandancy       = 0x00;
  
  uint32 AuthenticationVector = 0; */
  int CounterList = 0;

  while(CommandPermissionList[CounterList].Group != 0)
  {
    if(CmdData_p-&gt;ApplicationNr==CommandPermissionList[CounterList].Group &amp;&amp; CmdData_p-&gt;CommandNr==CommandPermissionList[CounterList].Command)
    {
      CommandPermissionList[CounterList].DataParam_p = CmdData_p-&gt;Payload.Data_p;
      return (&amp;CommandPermissionList[CounterList]);
    }
    CounterList++;
  }
  return NULL;
}

#ifdef CFG_ENABLE_AUDIT_CMD
ErrorCode_e CommandAudit(CommandData_t * CmdData_p)
{
  ErrorCode_e ReturnValue = E_GENERAL_FATAL_ERROR;
  CommandPermissionList_t* CmdPermission_p = NULL;
   
  CmdPermission_p = GetAuditData(CmdData_p);
  if(NULL == CmdPermission_p)
  {
    ReturnValue = E_UNSUPPORTED_CMD;
    goto ErrorExit;
  }

  ReturnValue = (ErrorCode_e)Do_LoaderSecLib_Audit_Permission_Levels(CmdPermission_p);
  if(ReturnValue != E_SUCCESS)
  {
    ReturnValue = E_AUDITING_FAILED;
  }

ErrorExit:
  return ReturnValue;
}
#endif
</template>

<template match="group/command" mode="array">
<variable name="group" select="../@number" />
<variable name="command" select="@number" />
<if test='$target="lcm" or $supported_commands/group[@number=$group]/command[@number=$command]'>
  <variable name="group" select="../@number" />
  <variable name="command" select="@number" />
<if test="contains(@source, 'ME') and not(contains(@source, 'PC')) and permissions">
CommandPermission_e PermArray_<value-of select="concat(../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />[]  = 
{
  <choose>
  <when test='not($supported_commands/group[@number=$group]/command[@number=$command]/permissions)'><apply-templates select="permissions/value" mode="perm" />
  </when>
  <otherwise>
  <apply-templates select="$supported_commands/group[@number=$group]/command[@number=$command]/permissions/value" mode="perm" />
  </otherwise>
  </choose>
};
</if>
<if test="contains(@source, 'PC') and permissions">
CommandPermission_e PermArray_<value-of select="concat( ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />[] =
{
  <choose>
  <when test='not($supported_commands/group[@number=$group]/command[@number=$command]/permissions)'><apply-templates select="permissions/value" mode="perm" />
  </when>
  <otherwise>
  <apply-templates select="$supported_commands/group[@number=$group]/command[@number=$command]/permissions/value" mode="perm" />
  </otherwise>
  </choose>
};
</if>
</if>
</template>

<template match="group/command" mode="autharray">
<variable name="group" select="../@number" />
<variable name="command" select="@number" />
<if test='$target="lcm" or $supported_commands/group[@number=$group]/command[@number=$command]'>
<if test="contains(@source, 'ME') and not(contains(@source, 'PC')) and authentication">
CommandAuthentication_e AuthArray_<value-of select="concat(../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />[]  =
{
  <apply-templates select="authentication/value" mode="auth" />
};
</if>
<if test="contains(@source, 'PC') and authentication">
CommandAuthentication_e AuthArray_<value-of select="concat( ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />[] =
{
  <apply-templates select="authentication/value" mode="auth" />
};
</if>
</if>
</template>


<template match="group/command" mode="staticarray">
<variable name="group" select="../@number" />
<variable name="command" select="@number" />
<if test='$target="lcm" or $supported_commands/group[@number=$group]/command[@number=$command]'>
<if test="contains(@source, 'PC') and not(contains(@source, 'ME'))">
<call-template name="staticarray">
  <with-param name="name" select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
  <with-param name="direction" select="input" />
</call-template>
</if>
<if test="contains(@source, 'ME')">
<call-template name="staticarray">
  <with-param name="name" select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
  <with-param name="direction" select="output" />
</call-template>
</if>
</if>
</template>
  
</stylesheet>