~ubuntu-branches/ubuntu/oneiric/osptoolkit/oneiric

« back to all changes in this revision

Viewing changes to src/ospauthreq.c

  • Committer: Bazaar Package Importer
  • Author(s): TransNexus, Inc.
  • Date: 2007-12-30 20:37:26 UTC
  • Revision ID: james.westby@ubuntu.com-20071230203726-dysah2e93yqd3vbp
Tags: upstream-3.4.2
ImportĀ upstreamĀ versionĀ 3.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************
 
2
*** COPYRIGHT (c) 2002 by TransNexus, Inc.                              ***
 
3
***                                                                     ***
 
4
*** This software is property of TransNexus, Inc.                       ***
 
5
*** This software is freely available under license from TransNexus.    ***
 
6
*** The license terms and conditions for free use of this software by   ***
 
7
*** third parties are defined in the OSP Toolkit Software License       ***
 
8
*** Agreement (LICENSE.txt).  Any use of this software by third         ***
 
9
*** parties, which does not comply with the terms and conditions of the ***
 
10
*** OSP Toolkit Software License Agreement is prohibited without        ***
 
11
*** the prior, express, written consent of TransNexus, Inc.             ***
 
12
***                                                                     ***
 
13
*** Thank you for using the OSP ToolKit(TM).  Please report any bugs,   ***
 
14
*** suggestions or feedback to support@transnexus.com                   ***
 
15
***                                                                     ***
 
16
**************************************************************************/
 
17
 
 
18
 
 
19
 
 
20
 
 
21
 
 
22
 
 
23
 
 
24
 
 
25
/*
 
26
 *  ospauthreq.c - OSP authorisation request functions
 
27
 */
 
28
 
 
29
#include "osp/osp.h"
 
30
#include "osp/osperrno.h"
 
31
#include "osp/ospbfr.h"
 
32
#include "osp/ospxmlattr.h"
 
33
#include "osp/ospxmlelem.h"
 
34
#include "osp/ospmsgattr.h"
 
35
#include "osp/ospmsgelem.h"
 
36
#include "osp/ospcallid.h"
 
37
#include "osp/ospauthreq.h"
 
38
#include "osp/osputils.h"
 
39
#include "osp/osptrans.h"
 
40
 
 
41
/* */
 
42
/*-----------------------------------------------------------------------*
 
43
 * OSPPAuthReqHasTimestamp() - Does authorisation request have a valid timestamp?
 
44
 *-----------------------------------------------------------------------*/
 
45
unsigned                                   /* returns non-zero if time */
 
46
OSPPAuthReqHasTimestamp(
 
47
    OSPTAUTHREQ *ospvAuthReq               /* authorisation request in question */
 
48
)
 
49
{
 
50
    unsigned ospvHasTimestamp = OSPC_FALSE;
 
51
 
 
52
    if (ospvAuthReq != OSPC_OSNULL)
 
53
    {
 
54
        ospvHasTimestamp = ((ospvAuthReq)->ospmAuthReqTimestamp != OSPC_TIMEMIN);
 
55
    }
 
56
    return(ospvHasTimestamp);
 
57
}
 
58
 
 
59
/* */
 
60
/*-----------------------------------------------------------------------*
 
61
 * OSPPAuthReqSetTimestamp() - sets the timestamp for an authorisation request
 
62
 *-----------------------------------------------------------------------*/
 
63
void                                       /* nothing returned */
 
64
OSPPAuthReqSetTimestamp(
 
65
    OSPTAUTHREQ *ospvAuthReq,
 
66
    OSPTTIME  ospvTime
 
67
)
 
68
{
 
69
    if (ospvAuthReq != OSPC_OSNULL)
 
70
    {
 
71
        (ospvAuthReq)->ospmAuthReqTimestamp = (ospvTime);
 
72
    }
 
73
}
 
74
 
 
75
/* */
 
76
/*-----------------------------------------------------------------------*
 
77
 * OSPPAuthReqGetTimestamp() - returns timestamp for an authorisation request
 
78
 *-----------------------------------------------------------------------*/
 
79
OSPTTIME                                   /* returns the time value */
 
80
    OSPPAuthReqGetTimestamp(
 
81
    OSPTAUTHREQ *ospvAuthReq               /* authorisation request */
 
82
    )
 
83
{
 
84
    OSPTTIME ospvTimestamp = 0;
 
85
 
 
86
    if (ospvAuthReq != OSPC_OSNULL)
 
87
    {
 
88
        ospvTimestamp = (ospvAuthReq)->ospmAuthReqTimestamp;
 
89
    }
 
90
    return(ospvTimestamp);
 
91
}
 
92
 
 
93
/* */
 
94
/*-----------------------------------------------------------------------*
 
95
 * OSPPAuthReqHasCallId() - does an authorisation request have a Call ID?
 
96
 *-----------------------------------------------------------------------*/
 
97
unsigned                                   /* returns non-zero if exists */
 
98
OSPPAuthReqHasCallId(
 
99
    OSPTAUTHREQ *ospvAuthReq                  /* authorisation request */
 
100
)
 
101
{
 
102
    unsigned ospvHasCallId = OSPC_FALSE;
 
103
 
 
104
    if (ospvAuthReq != OSPC_OSNULL)
 
105
    {
 
106
        ospvHasCallId = (OSPPAuthReqFirstCallId(ospvAuthReq) != OSPC_OSNULL);
 
107
    }
 
108
    return(ospvHasCallId);
 
109
}
 
110
 
 
111
/* */
 
112
/*-----------------------------------------------------------------------*
 
113
 * OSPPAuthReqFirstCallId() - gets the First call ID for an authorisation request
 
114
 *-----------------------------------------------------------------------*/
 
115
OSPTCALLID *                               /* returns call ID pointer */
 
116
    OSPPAuthReqFirstCallId(
 
117
    OSPTAUTHREQ *ospvAuthReq               /* authorisation request */
 
118
    )
 
119
{
 
120
    OSPTCALLID *ospvCallId = OSPC_OSNULL;
 
121
 
 
122
    if (ospvAuthReq != OSPC_OSNULL)
 
123
    {
 
124
        ospvCallId = (OSPTCALLID *)OSPPListFirst(&(ospvAuthReq->ospmAuthReqCallId));
 
125
    }
 
126
    return(ospvCallId);
 
127
}
 
128
 
 
129
/* */
 
130
/*-----------------------------------------------------------------------*
 
131
 * OSPPAuthReqNextCallId() - gets the next call ID for an authorisation request
 
132
 *-----------------------------------------------------------------------*/
 
133
OSPTCALLID *                               /* returns call ID pointer */
 
134
    OSPPAuthReqNextCallId(
 
135
    OSPTAUTHREQ *ospvAuthReq,               /* authorisation request */
 
136
    OSPTCALLID  *ospvCallId                 /* current callid */
 
137
    )
 
138
{
 
139
    OSPTCALLID *nextcallid = OSPC_OSNULL;
 
140
 
 
141
    if (ospvAuthReq != OSPC_OSNULL)
 
142
    {
 
143
        nextcallid = (OSPTCALLID *)OSPPListNext(&(ospvAuthReq->ospmAuthReqCallId), ospvCallId);
 
144
    }
 
145
    return(nextcallid);
 
146
}
 
147
 
 
148
/* */
 
149
/*-----------------------------------------------------------------------*
 
150
 * OSPPAuthReqHasSourceNumber() - does the authorisation request have
 
151
 * a source number?
 
152
 *-----------------------------------------------------------------------*/
 
153
unsigned                            /* returns non-zero if number exists */
 
154
OSPPAuthReqHasSourceNumber(
 
155
    OSPTAUTHREQ *ospvAuthReq        /* authorisation request effected */
 
156
)
 
157
{
 
158
    unsigned ospvHasNumber = OSPC_FALSE;
 
159
 
 
160
    if (ospvAuthReq != OSPC_OSNULL)
 
161
    {
 
162
        ospvHasNumber = ((ospvAuthReq)->ospmAuthReqSourceNumber[0] != '\0');
 
163
    }
 
164
    return(ospvHasNumber);
 
165
}
 
166
 
 
167
/* */
 
168
/*-----------------------------------------------------------------------*
 
169
 * OSPPAuthReqSetSourceNumber() - set the source number for an
 
170
 * authorisation request
 
171
 *-----------------------------------------------------------------------*/
 
172
void                                       /* nothing returned */
 
173
OSPPAuthReqSetSourceNumber(
 
174
    OSPTAUTHREQ         *ospvAuthReq,      /* authorisation request  to set */
 
175
    const unsigned char *ospvNum           /* source number (as string) */
 
176
)
 
177
{
 
178
    if (ospvAuthReq != OSPC_OSNULL)
 
179
    {
 
180
        if (ospvNum  != OSPC_OSNULL)
 
181
        {
 
182
            OSPM_STRNCPY((char *)(ospvAuthReq)->ospmAuthReqSourceNumber, 
 
183
                (const char *)(ospvNum), 
 
184
                tr_min(OSPM_STRLEN((const char *)ospvNum)+1,OSPC_E164NUMSIZE-1));
 
185
        }
 
186
    }
 
187
}
 
188
 
 
189
/* */
 
190
/*-----------------------------------------------------------------------*
 
191
 * OSPPAuthReqGetSourceNumber() - returns the source number for an 
 
192
 * authorisation request
 
193
 *-----------------------------------------------------------------------*/
 
194
unsigned char *                      /* returns number as string */
 
195
OSPPAuthReqGetSourceNumber(
 
196
    OSPTAUTHREQ *ospvAuthReq               /* authorisation request */
 
197
)
 
198
{
 
199
    unsigned char *ospvNum = OSPC_OSNULL;
 
200
 
 
201
    if (ospvAuthReq != OSPC_OSNULL)
 
202
    {
 
203
        ospvNum = (ospvAuthReq->ospmAuthReqSourceNumber);
 
204
    }
 
205
    return(ospvNum);
 
206
}
 
207
 
 
208
/* */
 
209
/*-----------------------------------------------------------------------*
 
210
 * OSPPAuthReqHasSourceAlt() - does an authorisation request have a 
 
211
 * Source Alternate?
 
212
 *-----------------------------------------------------------------------*/
 
213
unsigned                                   /* returns non-zero if exists */
 
214
OSPPAuthReqHasSourceAlt(
 
215
    OSPTAUTHREQ *ospvAuthReq                  /* authorisation request */
 
216
)
 
217
{
 
218
    unsigned ospvHasSourceAlt = OSPC_FALSE;
 
219
 
 
220
    if (ospvAuthReq != OSPC_OSNULL)
 
221
    {
 
222
        ospvHasSourceAlt = (OSPPAuthReqFirstSourceAlt(ospvAuthReq) != OSPC_OSNULL);
 
223
    }
 
224
    return(ospvHasSourceAlt);
 
225
}
 
226
 
 
227
/* */
 
228
/*-----------------------------------------------------------------------*
 
229
 * OSPPAuthReqFirstSourceAlt() - gets the First Source alternate for an 
 
230
 * authorisation request
 
231
 *-----------------------------------------------------------------------*/
 
232
OSPTALTINFO *                              /* returns alt info pointer */
 
233
    OSPPAuthReqFirstSourceAlt(
 
234
    OSPTAUTHREQ *ospvAuthReq               /* authorisation request */
 
235
    )
 
236
{
 
237
    OSPTALTINFO *ospvAltInfo = OSPC_OSNULL;
 
238
 
 
239
    if (ospvAuthReq != OSPC_OSNULL)
 
240
    {
 
241
        ospvAltInfo = 
 
242
            (OSPTALTINFO *)OSPPListFirst(&((ospvAuthReq)->ospmAuthReqSourceAlternate));
 
243
    }
 
244
    return(ospvAltInfo);
 
245
}
 
246
 
 
247
/* */
 
248
/*-----------------------------------------------------------------------*
 
249
 * OSPPAuthReqNextSourceAlt() - gets the next source alternate for an 
 
250
 * authorisation request
 
251
 *-----------------------------------------------------------------------*/
 
252
OSPTALTINFO *                               /* returns alt info pointer */
 
253
    OSPPAuthReqNextSourceAlt(
 
254
    OSPTAUTHREQ *ospvAuthReq,               /* authorisation request */
 
255
    OSPTALTINFO  *ospvAltInfo
 
256
    )
 
257
{
 
258
    OSPTALTINFO *altinfo = OSPC_OSNULL;
 
259
 
 
260
    if (ospvAuthReq != OSPC_OSNULL)
 
261
    {
 
262
        altinfo = 
 
263
            (OSPTALTINFO *)OSPPListNext(&((ospvAuthReq)->ospmAuthReqSourceAlternate), 
 
264
            ospvAltInfo);
 
265
    }
 
266
    return(altinfo);
 
267
}
 
268
 
 
269
/* */
 
270
/*-----------------------------------------------------------------------*
 
271
 * OSPPAuthReqHasDestinationAlt() - does an authorisation request have a 
 
272
 * Destination Alternate?
 
273
 *-----------------------------------------------------------------------*/
 
274
unsigned                                   /* returns non-zero if exists */
 
275
OSPPAuthReqHasDestinationAlt(
 
276
    OSPTAUTHREQ *ospvAuthReq                  /* authorisation request */
 
277
)
 
278
{
 
279
    unsigned ospvHasDestinationAlt = OSPC_FALSE;
 
280
 
 
281
    if (ospvAuthReq != OSPC_OSNULL)
 
282
    {
 
283
        ospvHasDestinationAlt = (OSPPAuthReqFirstDestinationAlt(ospvAuthReq) != OSPC_OSNULL);
 
284
    }
 
285
    return(ospvHasDestinationAlt);
 
286
}
 
287
 
 
288
/* */
 
289
/*-----------------------------------------------------------------------*
 
290
 * OSPPAuthReqFirstDestinationAlt() - gets the First Destination alternate for an 
 
291
 * authorisation request
 
292
 *-----------------------------------------------------------------------*/
 
293
OSPTALTINFO *                              /* returns alt info pointer */
 
294
    OSPPAuthReqFirstDestinationAlt(
 
295
    OSPTAUTHREQ *ospvAuthReq               /* authorisation request */
 
296
    )
 
297
{
 
298
    OSPTALTINFO *ospvAltInfo = OSPC_OSNULL;
 
299
 
 
300
    if (ospvAuthReq != OSPC_OSNULL)
 
301
    {
 
302
        ospvAltInfo = 
 
303
            (OSPTALTINFO *)OSPPListFirst(&((ospvAuthReq)->ospmAuthReqDestinationAlternate));
 
304
    }
 
305
    return(ospvAltInfo);
 
306
}
 
307
 
 
308
/* */
 
309
/*-----------------------------------------------------------------------*
 
310
 * OSPPAuthReqNextDestinationAlt() - gets the next Destination alternate for an 
 
311
 * authorisation request
 
312
 *-----------------------------------------------------------------------*/
 
313
OSPTALTINFO *                               /* returns alt info pointer */
 
314
    OSPPAuthReqNextDestinationAlt(
 
315
    OSPTAUTHREQ *ospvAuthReq,               /* authorisation request */
 
316
    OSPTALTINFO  *ospvAltInfo
 
317
    )
 
318
{
 
319
    OSPTALTINFO *altinfo = OSPC_OSNULL;
 
320
 
 
321
    if (ospvAuthReq != OSPC_OSNULL)
 
322
    {
 
323
        altinfo = 
 
324
            (OSPTALTINFO *)OSPPListNext(&((ospvAuthReq)->ospmAuthReqDestinationAlternate), 
 
325
            ospvAltInfo);
 
326
    }
 
327
    return(altinfo);
 
328
}
 
329
 
 
330
/* */
 
331
/*-----------------------------------------------------------------------*
 
332
 * OSPPAuthReqHasDestNumber() - does the authorisation request include a
 
333
 * dest number?
 
334
 *-----------------------------------------------------------------------*/
 
335
unsigned                            /* returns non-zero if number exists */
 
336
OSPPAuthReqHasDestNumber(
 
337
    OSPTAUTHREQ *ospvAuthReq        /* authorisation request effected */
 
338
)
 
339
{
 
340
    unsigned ospvHasNumber = OSPC_FALSE;
 
341
 
 
342
    if (ospvAuthReq != OSPC_OSNULL)
 
343
    {
 
344
        ospvHasNumber = ((ospvAuthReq)->ospmAuthReqDestNumber[0] != '\0');
 
345
    }
 
346
    return(ospvHasNumber);
 
347
}
 
348
 
 
349
/* */
 
350
/*-----------------------------------------------------------------------*
 
351
 * OSPPAuthReqSetDestNumber() - set the destination number for an
 
352
 * authorisation request
 
353
 *-----------------------------------------------------------------------*/
 
354
void                                       /* nothing returned */
 
355
OSPPAuthReqSetDestNumber(
 
356
    OSPTAUTHREQ         *ospvAuthReq,      /* authorisation request to set */
 
357
    const unsigned char *ospvNum           /* destination number (as string) */
 
358
)
 
359
{
 
360
    if (ospvAuthReq != OSPC_OSNULL)
 
361
    {
 
362
        if (ospvNum  != OSPC_OSNULL)
 
363
        {
 
364
            OSPM_STRNCPY((char *)(ospvAuthReq)->ospmAuthReqDestNumber, 
 
365
                (const char *)(ospvNum), 
 
366
                tr_min(OSPM_STRLEN((const char *)ospvNum)+1,OSPC_E164NUMSIZE-1));
 
367
        }
 
368
    }
 
369
}
 
370
 
 
371
/* */
 
372
/*-----------------------------------------------------------------------*
 
373
 * OSPPAuthReqGetDestNumber() - returns the destination number for an
 
374
 * authorisation request
 
375
 *-----------------------------------------------------------------------*/
 
376
unsigned char *                      /* returns number as string */
 
377
OSPPAuthReqGetDestNumber(
 
378
    OSPTAUTHREQ *ospvAuthReq               /* authorisation request */
 
379
)
 
380
{
 
381
    unsigned char *ospvDestNum = OSPC_OSNULL;
 
382
 
 
383
    if (ospvAuthReq != OSPC_OSNULL)
 
384
    {
 
385
        ospvDestNum = ((ospvAuthReq)->ospmAuthReqDestNumber);
 
386
    }
 
387
    return(ospvDestNum);
 
388
}
 
389
 
 
390
/* */
 
391
/*-----------------------------------------------------------------------*
 
392
 * OSPPAuthReqSetMaxDest() - set the maximum destinations for an
 
393
 * authorisation request
 
394
 *-----------------------------------------------------------------------*/
 
395
void                                       /* nothing returned */
 
396
OSPPAuthReqSetMaxDest(
 
397
    OSPTAUTHREQ         *ospvAuthReq,      /* authorisation request to set */
 
398
    unsigned             ospvNum           /* maximum destinations */
 
399
)
 
400
{
 
401
    if (ospvAuthReq != OSPC_OSNULL)
 
402
    {
 
403
        if (ospvNum  != 0)
 
404
        {
 
405
            (ospvAuthReq)->ospmAuthReqMaxDest = ospvNum;
 
406
        }
 
407
    }
 
408
}
 
409
 
 
410
/* */
 
411
/*-----------------------------------------------------------------------*
 
412
 * OSPPAuthReqGetMaxDest() - returns the maximum destinations for an
 
413
 * authorisation request
 
414
 *-----------------------------------------------------------------------*/
 
415
unsigned                                  /* returns maximum destionations */
 
416
OSPPAuthReqGetMaxDest(
 
417
    OSPTAUTHREQ *ospvAuthReq               /* authorisation request */
 
418
)
 
419
{
 
420
    unsigned ospvNum = 0;
 
421
 
 
422
    if (ospvAuthReq != OSPC_OSNULL)
 
423
    {
 
424
        ospvNum = ((ospvAuthReq)->ospmAuthReqMaxDest);
 
425
    }
 
426
    return(ospvNum);
 
427
}
 
428
/* */
 
429
/*-----------------------------------------------------------------------*
 
430
 * OSPPAuthReqHasTNCustId() - Does request have a TransNexus Customer Id?
 
431
 *-----------------------------------------------------------------------*/
 
432
unsigned                                   /* returns non-zero if time */
 
433
OSPPAuthReqHasTNCustId(
 
434
    OSPTAUTHREQ *ospvAuthReq               /* authorisation request in question */
 
435
)
 
436
{
 
437
    unsigned ospvHasTNCustId = OSPC_FALSE;
 
438
 
 
439
    if (ospvAuthReq != OSPC_OSNULL)
 
440
    {
 
441
        ospvHasTNCustId = ((ospvAuthReq)->ospmAuthReqTNCustId != 0L);
 
442
    }
 
443
    return(ospvHasTNCustId);
 
444
}
 
445
 
 
446
/* */
 
447
/*-----------------------------------------------------------------------*
 
448
 * OSPPAuthReqSetTNCustId() - Set TransNexus Customer Id
 
449
 *-----------------------------------------------------------------------*/
 
450
void                                       /* nothing returned */
 
451
OSPPAuthReqSetTNCustId(
 
452
    OSPTAUTHREQ   *ospvAuthReq,
 
453
    unsigned long ospvTNCustId
 
454
)
 
455
{
 
456
    if (ospvAuthReq != OSPC_OSNULL)
 
457
    {
 
458
        (ospvAuthReq)->ospmAuthReqTNCustId = (ospvTNCustId);
 
459
    }
 
460
}
 
461
 
 
462
/* */
 
463
/*-----------------------------------------------------------------------*
 
464
 * OSPPAuthReqGetTNCustId() - returns TN Customer Id for an auth request
 
465
 *-----------------------------------------------------------------------*/
 
466
unsigned long                              /* returns the time value */
 
467
    OSPPAuthReqGetTNCustId(
 
468
    OSPTAUTHREQ *ospvAuthReq               /* authorisation request */
 
469
    )
 
470
{
 
471
    unsigned long ospvTNCustId = 0L;
 
472
 
 
473
    if (ospvAuthReq != OSPC_OSNULL)
 
474
    {
 
475
        ospvTNCustId = (ospvAuthReq)->ospmAuthReqTNCustId;
 
476
    }
 
477
    return(ospvTNCustId);
 
478
}
 
479
 
 
480
/* */
 
481
/*-----------------------------------------------------------------------*
 
482
 * OSPPAuthReqHasTNDeviceId() - Does request have a TransNexus Device Id?
 
483
 *-----------------------------------------------------------------------*/
 
484
unsigned                                   /* returns non-zero if time */
 
485
OSPPAuthReqHasTNDeviceId(
 
486
    OSPTAUTHREQ *ospvAuthReq               /* authorisation request in question */
 
487
)
 
488
{
 
489
    unsigned ospvHasTNDeviceId = OSPC_FALSE;
 
490
 
 
491
    if (ospvAuthReq != OSPC_OSNULL)
 
492
    {
 
493
        ospvHasTNDeviceId = ((ospvAuthReq)->ospmAuthReqTNDeviceId != 0L);
 
494
    }
 
495
    return(ospvHasTNDeviceId);
 
496
}
 
497
 
 
498
/* */
 
499
/*-----------------------------------------------------------------------*
 
500
 * OSPPAuthReqSetTNDeviceId() - Set TransNexus Device Id
 
501
 *-----------------------------------------------------------------------*/
 
502
void                                       /* nothing returned */
 
503
OSPPAuthReqSetTNDeviceId(
 
504
    OSPTAUTHREQ    *ospvAuthReq,
 
505
    unsigned long  ospvTNDeviceId
 
506
)
 
507
{
 
508
    if (ospvAuthReq != OSPC_OSNULL)
 
509
    {
 
510
        (ospvAuthReq)->ospmAuthReqTNDeviceId = (ospvTNDeviceId);
 
511
    }
 
512
}
 
513
 
 
514
/* */
 
515
/*-----------------------------------------------------------------------*
 
516
 * OSPPAuthReqGetTNDeviceId() - returns TN Device Id for an auth request
 
517
 *-----------------------------------------------------------------------*/
 
518
unsigned long                              /* returns the time value */
 
519
    OSPPAuthReqGetTNDeviceId(
 
520
    OSPTAUTHREQ *ospvAuthReq               /* authorisation request */
 
521
    )
 
522
{
 
523
    unsigned long ospvTNDeviceId = 0L;
 
524
 
 
525
    if (ospvAuthReq != OSPC_OSNULL)
 
526
    {
 
527
        ospvTNDeviceId = (ospvAuthReq)->ospmAuthReqTNDeviceId;
 
528
    }
 
529
    return(ospvTNDeviceId);
 
530
}
 
531
 
 
532
/* */
 
533
/*-----------------------------------------------------------------------*
 
534
 * OSPPAuthReqHasComponentId() - is the component id set ?
 
535
 *-----------------------------------------------------------------------*/
 
536
unsigned                    /* returns non-zero if component id is set */
 
537
OSPPAuthReqHasComponentId(
 
538
    OSPTAUTHREQ *ospvAuthReq
 
539
)
 
540
{
 
541
  return (ospvAuthReq->ospmAuthReqComponentId != OSPC_OSNULL);
 
542
}
 
543
 
 
544
 
 
545
/* */
 
546
/*-----------------------------------------------------------------------*
 
547
 * OSPPAuthReqNew() - creates a new (empty) authorisation request
 
548
 *-----------------------------------------------------------------------*/
 
549
 
 
550
OSPTAUTHREQ *                              /* returns pointer or NULL */
 
551
    OSPPAuthReqNew()
 
552
{
 
553
    OSPTAUTHREQ *ospvAuthReq = OSPC_OSNULL;
 
554
 
 
555
    OSPM_MALLOC(ospvAuthReq, OSPTAUTHREQ,sizeof(OSPTAUTHREQ));
 
556
    if (ospvAuthReq != OSPC_OSNULL)
 
557
    {
 
558
        OSPM_MEMSET(ospvAuthReq, 0,sizeof(OSPTAUTHREQ));
 
559
        ospvAuthReq->ospmAuthReqTimestamp = OSPC_TIMEMIN;
 
560
    }
 
561
    return(ospvAuthReq);
 
562
}
 
563
 
 
564
/*-----------------------------------------------------------------------*
 
565
 * OSPPAuthReqDelete() - deletes an authorisation request structure
 
566
 *-----------------------------------------------------------------------*/
 
567
void 
 
568
OSPPAuthReqDelete(OSPTAUTHREQ **ospvAuthReq)
 
569
{
 
570
    OSPTCALLID  *callid     = OSPC_OSNULL;
 
571
    OSPTALTINFO *altinfo    = OSPC_OSNULL;
 
572
 
 
573
    if (*ospvAuthReq)
 
574
    {
 
575
        while(!OSPPListEmpty(&((*ospvAuthReq)->ospmAuthReqCallId)))
 
576
        {
 
577
            callid = (OSPTCALLID *)OSPPListRemove(&((*ospvAuthReq)->ospmAuthReqCallId));
 
578
 
 
579
            if(callid != OSPC_OSNULL)
 
580
            {
 
581
                OSPM_FREE(callid);
 
582
                callid = OSPC_OSNULL;
 
583
            }
 
584
        }  
 
585
 
 
586
        OSPPListDelete(&((*ospvAuthReq)->ospmAuthReqCallId));
 
587
 
 
588
        while(!OSPPListEmpty(&((*ospvAuthReq)->ospmAuthReqDeviceInfo)))
 
589
        {
 
590
            altinfo = (OSPTALTINFO *)OSPPListRemove(&((*ospvAuthReq)->ospmAuthReqDeviceInfo));
 
591
            if(altinfo != OSPC_OSNULL)
 
592
            {
 
593
                OSPM_FREE(altinfo);
 
594
                altinfo = OSPC_OSNULL;
 
595
            }
 
596
        }  
 
597
 
 
598
        OSPPListDelete(&((*ospvAuthReq)->ospmAuthReqDeviceInfo));
 
599
 
 
600
        while(!OSPPListEmpty(&((*ospvAuthReq)->ospmAuthReqSourceAlternate)))
 
601
        {
 
602
            altinfo = (OSPTALTINFO *)OSPPListRemove(&((*ospvAuthReq)->ospmAuthReqSourceAlternate));
 
603
            if(altinfo != OSPC_OSNULL)
 
604
            {
 
605
                OSPM_FREE(altinfo);
 
606
                altinfo = OSPC_OSNULL;
 
607
            }
 
608
        }  
 
609
 
 
610
        OSPPListDelete(&((*ospvAuthReq)->ospmAuthReqSourceAlternate));
 
611
 
 
612
        while(!OSPPListEmpty(&((*ospvAuthReq)->ospmAuthReqDestinationAlternate)))
 
613
        {
 
614
            altinfo = (OSPTALTINFO *)OSPPListRemove(&((*ospvAuthReq)->ospmAuthReqDestinationAlternate));
 
615
            if(altinfo != OSPC_OSNULL)
 
616
            {
 
617
                OSPM_FREE(altinfo);
 
618
                altinfo = OSPC_OSNULL;
 
619
            }
 
620
        }  
 
621
 
 
622
        if(OSPPAuthReqHasComponentId(*ospvAuthReq))
 
623
        {
 
624
            OSPM_FREE((*ospvAuthReq)->ospmAuthReqComponentId);
 
625
        }
 
626
 
 
627
 
 
628
        if(OSPPAuthReqHasMessageId(*ospvAuthReq))
 
629
        {
 
630
            OSPM_FREE((*ospvAuthReq)->ospmAuthReqMessageId);
 
631
        }
 
632
 
 
633
        OSPPListDelete(&((*ospvAuthReq)->ospmAuthReqDestinationAlternate));
 
634
 
 
635
        OSPM_FREE(*ospvAuthReq);
 
636
        *ospvAuthReq = OSPC_OSNULL;
 
637
    }
 
638
 
 
639
    return;
 
640
}
 
641
 
 
642
/*^L*/
 
643
/*-----------------------------------------------------------------------*
 
644
 * OSPPAuthReqAddServiceInfo() - Add service type to usage detail
 
645
 *-----------------------------------------------------------------------*/
 
646
unsigned OSPPAuthReqAddServiceInfo(
 
647
    OSPTXMLELEM **ospvElem,         /* where to put XML element pointer */
 
648
    OSPE_SERVICE_TYPE ServiceType
 
649
)
 
650
{
 
651
    unsigned      ospvErrCode = OSPC_ERR_NO_ERROR;
 
652
    OSPTXMLELEM  *elem = OSPC_OSNULL;
 
653
 
 
654
    if (ospvElem == OSPC_OSNULL)
 
655
    {
 
656
        ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;
 
657
    }
 
658
 
 
659
    if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
660
    {
 
661
        /* create the parent element */
 
662
        *ospvElem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemService), "");
 
663
        if (*ospvElem == OSPC_OSNULL)
 
664
        {
 
665
            ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;
 
666
        }
 
667
    }
 
668
    if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
669
    {
 
670
        if (ServiceType == OSPC_VOICE)
 
671
        {
 
672
            elem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemServiceType), "voice");
 
673
        }
 
674
        else
 
675
        {
 
676
            elem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemServiceType), "data");
 
677
        }
 
678
        if (elem == OSPC_OSNULL)
 
679
        {
 
680
            ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;
 
681
        }
 
682
    }
 
683
    if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
684
    {
 
685
        OSPPXMLElemAddChild(*ospvElem, elem);
 
686
    }
 
687
 
 
688
    /* if for any reason we found an error - destroy any elements created */
 
689
    if ((ospvErrCode != OSPC_ERR_NO_ERROR) && (*ospvElem != OSPC_OSNULL))
 
690
    {
 
691
        OSPPXMLElemDelete(ospvElem);
 
692
    }
 
693
 
 
694
    return(ospvErrCode);
 
695
 
 
696
}
 
697
 
 
698
 
 
699
/* */
 
700
/*-----------------------------------------------------------------------*
 
701
 * OSPPAuthReqAddPricingInfo() - adds pricing info to an xml element
 
702
 *-----------------------------------------------------------------------*/
 
703
unsigned OSPPAuthReqAddPricingInfo(
 
704
    OSPTXMLELEM **ospvElem,         /* where to put XML element pointer */
 
705
    OSPT_PRICING_INFO PricingInfo
 
706
)
 
707
{
 
708
    unsigned      ospvErrCode = OSPC_ERR_NO_ERROR;
 
709
    OSPTXMLELEM  *elem = OSPC_OSNULL;
 
710
 
 
711
    if (ospvElem == OSPC_OSNULL)
 
712
    {
 
713
        ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;
 
714
    }
 
715
 
 
716
    if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
717
    {
 
718
        /* create the parent element */
 
719
        *ospvElem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemPricingInd), "");
 
720
        if (*ospvElem == OSPC_OSNULL)
 
721
        {
 
722
            ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;
 
723
        }
 
724
    }
 
725
 
 
726
    if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
727
    {
 
728
        ospvErrCode = OSPPMsgFloatToElement(PricingInfo.amount,
 
729
                (const unsigned char *)OSPPMsgGetElemName(ospeElemAmount), &elem);
 
730
 
 
731
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
732
        {
 
733
           OSPPXMLElemAddChild(*ospvElem, elem);
 
734
        }
 
735
    }
 
736
 
 
737
    /* now add the increment */
 
738
    if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
739
    {
 
740
        ospvErrCode = OSPPMsgNumToElement(PricingInfo.increment,
 
741
                (const unsigned char *)OSPPMsgGetElemName(ospeElemIncrement), &elem);
 
742
    
 
743
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
744
        {
 
745
           OSPPXMLElemAddChild(*ospvElem, elem);
 
746
        }
 
747
    }
 
748
 
 
749
    /* now we need to add units */
 
750
    if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
751
    {
 
752
        elem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemUnit),(const char *)PricingInfo.unit);
 
753
        if (elem == OSPC_OSNULL)
 
754
        {
 
755
            ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;
 
756
        }
 
757
 
 
758
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
759
        {
 
760
            OSPPXMLElemAddChild(*ospvElem, elem);
 
761
        }
 
762
    }
 
763
 
 
764
    /* add currency */
 
765
    if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
766
    {
 
767
        elem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemCurrency),(const char *)PricingInfo.currency);
 
768
        if (elem == OSPC_OSNULL)
 
769
        {
 
770
            ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;
 
771
        }
 
772
 
 
773
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
774
        {
 
775
            OSPPXMLElemAddChild(*ospvElem, elem);
 
776
        }
 
777
    }
 
778
 
 
779
    /* if for any reason we found an error - destroy any elements created */
 
780
    if ((ospvErrCode != OSPC_ERR_NO_ERROR) && (*ospvElem != OSPC_OSNULL))
 
781
    {
 
782
        OSPPXMLElemDelete(ospvElem);
 
783
    }
 
784
    return(ospvErrCode);
 
785
}
 
786
 
 
787
 
 
788
/* */
 
789
/*-----------------------------------------------------------------------*
 
790
 * OSPPAuthReqToElement() - create an XML element from an authorisation request
 
791
 *-----------------------------------------------------------------------*/
 
792
 
 
793
int                                /* returns error code */
 
794
OSPPAuthReqToElement(
 
795
    OSPTAUTHREQ  *ospvAuthReq,     /* authorisation request value */
 
796
    OSPTXMLELEM **ospvElem,         /* where to put XML element pointer */
 
797
    void   *ospvtrans
 
798
)
 
799
{
 
800
    int      ospvErrCode      = OSPC_ERR_NO_ERROR;
 
801
    OSPTXMLELEM  *elem        = OSPC_OSNULL,
 
802
        *authreqelem = OSPC_OSNULL;
 
803
    OSPTXMLATTR  *attr        = OSPC_OSNULL;
 
804
    OSPTCALLID   *callid      = OSPC_OSNULL;
 
805
    OSPTALTINFO  *altinfo     = OSPC_OSNULL;
 
806
    char         random[OSPC_MAX_RANDOM];
 
807
    OSPTBOOL     isbase64     = OSPC_TRUE;
 
808
    OSPTTRANS   *trans = (OSPTTRANS *)ospvtrans;
 
809
    int i;
 
810
 
 
811
    OSPM_MEMSET(random, 0, OSPC_MAX_RANDOM);
 
812
 
 
813
    if (ospvElem == OSPC_OSNULL)
 
814
    {
 
815
        ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;
 
816
    }
 
817
    if (ospvAuthReq == OSPC_OSNULL)
 
818
    {
 
819
        ospvErrCode = OSPC_ERR_DATA_NO_AUTHREQ;
 
820
    }
 
821
 
 
822
    /* create the "Message" element as the parent */
 
823
    *ospvElem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemMessage), "");
 
824
 
 
825
    if(*ospvElem == OSPC_OSNULL)
 
826
    {
 
827
        ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;
 
828
    }
 
829
    else
 
830
    {
 
831
        attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrMessageId), 
 
832
            (OSPPAuthReqHasMessageId(ospvAuthReq))?(const unsigned char *)(ospvAuthReq->ospmAuthReqMessageId): (const unsigned char *)"NULL");
 
833
 
 
834
        if (attr != OSPC_OSNULL) 
 
835
        {
 
836
            OSPPXMLElemAddAttr(*ospvElem, attr);
 
837
            attr = OSPC_OSNULL;
 
838
        }
 
839
        else
 
840
        {
 
841
            ospvErrCode = OSPC_ERR_XML_NO_ATTR;
 
842
        }
 
843
 
 
844
        /* random */
 
845
        if((OSPPUtilGetRandom(random, 0) > 0) &&
 
846
            (ospvErrCode == OSPC_ERR_NO_ERROR))
 
847
        {
 
848
            attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrRandom),
 
849
                (const unsigned char *)random);
 
850
 
 
851
            if (attr != OSPC_OSNULL) 
 
852
            {
 
853
                OSPPXMLElemAddAttr(*ospvElem, attr);
 
854
                attr = OSPC_OSNULL;
 
855
            }
 
856
            else
 
857
            {
 
858
                ospvErrCode = OSPC_ERR_XML_NO_ATTR;
 
859
            }
 
860
        }
 
861
    }
 
862
 
 
863
    if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
864
    {
 
865
        /* create the authreq element */
 
866
        authreqelem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemAuthReq), "");
 
867
        if (authreqelem == OSPC_OSNULL)
 
868
        {
 
869
            ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;
 
870
        }
 
871
        /* now add the attributes to the parent -- in this case the component id
 
872
         *
 
873
         */
 
874
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
875
        {
 
876
            attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrComponentId), 
 
877
                (OSPPAuthReqHasComponentId(ospvAuthReq))?(const unsigned char *)(ospvAuthReq->ospmAuthReqComponentId): (const unsigned char *)"NULL");
 
878
            if (attr == OSPC_OSNULL)
 
879
            {
 
880
                ospvErrCode = OSPC_ERR_XML_NO_ATTR;
 
881
            }
 
882
        }
 
883
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
884
        {
 
885
            OSPPXMLElemAddAttr(authreqelem, attr);
 
886
            attr = OSPC_OSNULL;
 
887
        }
 
888
 
 
889
        /* now add the children */
 
890
        /* add timestamp  */
 
891
        if ((ospvErrCode == OSPC_ERR_NO_ERROR) && OSPPAuthReqHasTimestamp(ospvAuthReq))
 
892
        {
 
893
            ospvErrCode = OSPPMsgTimeToElement(OSPPAuthReqGetTimestamp(ospvAuthReq),
 
894
                (const unsigned char *)OSPPMsgGetElemName(ospeElemTimestamp), &elem);
 
895
            if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
896
            {
 
897
                OSPPXMLElemAddChild(authreqelem, elem);
 
898
                elem = OSPC_OSNULL;
 
899
            }
 
900
        }
 
901
 
 
902
 
 
903
        /* add the call ID */
 
904
        if ((ospvErrCode == OSPC_ERR_NO_ERROR) && OSPPAuthReqHasCallId(ospvAuthReq))
 
905
        {
 
906
            for (callid = OSPPAuthReqFirstCallId(ospvAuthReq);
 
907
                ((callid != OSPC_OSNULL) && (ospvErrCode == OSPC_ERR_NO_ERROR));
 
908
                callid = OSPPAuthReqNextCallId(ospvAuthReq, callid))
 
909
            {
 
910
                ospvErrCode = OSPPCallIdToElement(callid, &elem, isbase64);
 
911
                if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
912
                {
 
913
                    OSPPXMLElemAddChild(authreqelem, elem);
 
914
                    elem = OSPC_OSNULL;
 
915
                }
 
916
            }
 
917
        }
 
918
 
 
919
        /* add the source number */
 
920
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
921
        {
 
922
            elem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemSrcInfo),
 
923
                (const char *)OSPPAuthReqGetSourceNumber(ospvAuthReq));
 
924
            if (elem == OSPC_OSNULL)
 
925
            {
 
926
                ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;
 
927
            }
 
928
        }
 
929
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
930
        {
 
931
            if (trans->CallingNumberFormat == OSPC_E164)
 
932
            {
 
933
                attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrType),
 
934
                    (const unsigned char *)"e164");
 
935
            }
 
936
            else if (trans->CallingNumberFormat == OSPC_SIP)
 
937
            {
 
938
                attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrType),
 
939
                    (const unsigned char *)"sip");
 
940
            }
 
941
            else if (trans->CallingNumberFormat == OSPC_URL)
 
942
            {
 
943
                attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrType),
 
944
                    (const unsigned char *)"url");
 
945
            }
 
946
 
 
947
            if (attr == OSPC_OSNULL)
 
948
            {
 
949
                ospvErrCode = OSPC_ERR_XML_NO_ATTR;
 
950
            }
 
951
        }
 
952
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
953
        {
 
954
            OSPPXMLElemAddAttr(elem, attr);
 
955
            attr = OSPC_OSNULL;
 
956
        }
 
957
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
958
        {
 
959
            OSPPXMLElemAddChild(authreqelem, elem);
 
960
            elem = OSPC_OSNULL;
 
961
        }
 
962
 
 
963
        if ((ospvErrCode == OSPC_ERR_NO_ERROR) &&
 
964
            (ospvAuthReq->ospmAuthReqDeviceInfo != NULL))
 
965
        {
 
966
            /*
 
967
             *
 
968
             * Create/Add DeviceInfo elements
 
969
             *
 
970
             */
 
971
            for(altinfo = (OSPTALTINFO *)OSPPListFirst( &(ospvAuthReq->ospmAuthReqDeviceInfo));
 
972
            altinfo!= (OSPTALTINFO *)OSPC_OSNULL;
 
973
            altinfo = (OSPTALTINFO *)OSPPListNext( &(ospvAuthReq->ospmAuthReqDeviceInfo), altinfo))
 
974
            {
 
975
                OSPPAltInfoToElement(altinfo, &elem, ospeElemDeviceInfo);
 
976
                OSPPXMLElemAddChild(authreqelem, elem);
 
977
                elem = OSPC_OSNULL;
 
978
            }
 
979
        }
 
980
 
 
981
        /* add the source alternates */
 
982
        if ((ospvErrCode == OSPC_ERR_NO_ERROR) && 
 
983
            OSPPAuthReqHasSourceAlt(ospvAuthReq))
 
984
        {
 
985
            for (altinfo = (OSPTALTINFO *)OSPPAuthReqFirstSourceAlt(ospvAuthReq);
 
986
                ((altinfo != (OSPTALTINFO *)OSPC_OSNULL) && (ospvErrCode == OSPC_ERR_NO_ERROR));
 
987
                altinfo = (OSPTALTINFO *)OSPPAuthReqNextSourceAlt(ospvAuthReq, altinfo))
 
988
            {
 
989
                ospvErrCode = OSPPAltInfoToElement(altinfo, &elem, ospeElemSrcAlt);
 
990
                if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
991
                {
 
992
                    OSPPXMLElemAddChild(authreqelem, elem);
 
993
                    elem = OSPC_OSNULL;
 
994
                }
 
995
            }
 
996
        }
 
997
 
 
998
        /* add the dest number */
 
999
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
1000
        {
 
1001
            elem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemDestInfo),
 
1002
                (const char *)OSPPAuthReqGetDestNumber(ospvAuthReq));
 
1003
            if (elem == OSPC_OSNULL)
 
1004
            {
 
1005
                ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;
 
1006
            }
 
1007
        }
 
1008
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
1009
        {
 
1010
            if (trans->CalledNumberFormat == OSPC_E164)
 
1011
            {
 
1012
                attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrType),
 
1013
                    (const unsigned char *)"e164");
 
1014
            }
 
1015
            else if (trans->CalledNumberFormat == OSPC_SIP)
 
1016
            {
 
1017
                attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrType),
 
1018
                    (const unsigned char *)"sip");
 
1019
            }
 
1020
            else if (trans->CalledNumberFormat == OSPC_URL)
 
1021
            {
 
1022
                attr = OSPPXMLAttrNew((const unsigned char *)OSPPMsgGetAttrName(ospeAttrType),
 
1023
                    (const unsigned char *)"url");
 
1024
            }
 
1025
            if (attr == OSPC_OSNULL)
 
1026
            {
 
1027
                ospvErrCode = OSPC_ERR_XML_NO_ATTR;
 
1028
            }
 
1029
        }
 
1030
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
1031
        {
 
1032
            OSPPXMLElemAddAttr(elem, attr);
 
1033
            attr = OSPC_OSNULL;
 
1034
 
 
1035
            OSPPXMLElemAddChild(authreqelem, elem);
 
1036
            elem = OSPC_OSNULL;
 
1037
        }
 
1038
 
 
1039
        /* add the destination alternates */
 
1040
        if ((ospvErrCode == OSPC_ERR_NO_ERROR) && 
 
1041
            OSPPAuthReqHasDestinationAlt(ospvAuthReq))
 
1042
        {
 
1043
            altinfo = OSPC_OSNULL;
 
1044
            for (altinfo = (OSPTALTINFO *)OSPPAuthReqFirstDestinationAlt(ospvAuthReq);
 
1045
                ((altinfo != (OSPTALTINFO *)OSPC_OSNULL) && (ospvErrCode == OSPC_ERR_NO_ERROR));
 
1046
                altinfo = (OSPTALTINFO *)OSPPAuthReqNextDestinationAlt(ospvAuthReq, altinfo))
 
1047
            {
 
1048
                ospvErrCode = OSPPAltInfoToElement(altinfo, &elem, ospeElemDestAlt);
 
1049
                if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
1050
                {
 
1051
                    OSPPXMLElemAddChild(authreqelem, elem);
 
1052
                    elem = OSPC_OSNULL;
 
1053
                }
 
1054
            }
 
1055
        }
 
1056
 
 
1057
        /*
 
1058
         * Add the pricing information
 
1059
         */
 
1060
        if ((ospvErrCode == OSPC_ERR_NO_ERROR) &&
 
1061
            (trans->IsPricingInfoPresent))
 
1062
        {
 
1063
            for (i=0;i<trans->NumOfPricingInfoElements;i++)
 
1064
            {
 
1065
                ospvErrCode = OSPPAuthReqAddPricingInfo(&elem,trans->PricingInfo[i]);
 
1066
                if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
1067
                {
 
1068
                    OSPPXMLElemAddChild(authreqelem, elem);
 
1069
                    elem = OSPC_OSNULL;
 
1070
                }
 
1071
                else
 
1072
                {
 
1073
                    break;
 
1074
                }
 
1075
            }
 
1076
        }
 
1077
 
 
1078
        /* now add the service */
 
1079
        if ((ospvErrCode == OSPC_ERR_NO_ERROR) && (trans->IsServiceInfoPresent == OSPC_TRUE))
 
1080
        {
 
1081
            ospvErrCode = OSPPAuthReqAddServiceInfo(&elem,trans->ServiceType);
 
1082
            if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
1083
            {
 
1084
                OSPPXMLElemAddChild(authreqelem, elem);
 
1085
                elem = OSPC_OSNULL;
 
1086
            }
 
1087
        }
 
1088
        else
 
1089
        {
 
1090
            if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
1091
            {
 
1092
                elem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemService),"");
 
1093
                if (elem == OSPC_OSNULL)
 
1094
                {
 
1095
                    ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;
 
1096
                }
 
1097
            }
 
1098
            if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
1099
            {
 
1100
                OSPPXMLElemAddChild(authreqelem, elem);
 
1101
                elem = OSPC_OSNULL;
 
1102
            }
 
1103
        }
 
1104
 
 
1105
        /* now add the max destinations */
 
1106
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
1107
        {
 
1108
            ospvErrCode = OSPPMsgNumToElement( 
 
1109
                OSPPAuthReqGetMaxDest(ospvAuthReq),
 
1110
                (const unsigned char *)OSPPMsgGetElemName(ospeElemMaxDest),
 
1111
                &elem);
 
1112
        }
 
1113
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
1114
        {
 
1115
            OSPPXMLElemAddChild(authreqelem, elem);
 
1116
            elem = OSPC_OSNULL;
 
1117
        }
 
1118
 
 
1119
        /* now add the transnexus extentions (if available) */
 
1120
        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
1121
        {
 
1122
            if (OSPPAuthReqHasTNCustId(ospvAuthReq))
 
1123
            {
 
1124
                ospvErrCode = OSPPMsgNumToElement( 
 
1125
                    OSPPAuthReqGetTNCustId(ospvAuthReq),
 
1126
                    (const unsigned char *) OSPPMsgGetElemName(ospeElemTNCustId),
 
1127
                    &elem);
 
1128
 
 
1129
                if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
1130
                {
 
1131
 
 
1132
                   attr = OSPPXMLAttrNew(
 
1133
                        (const unsigned char *)OSPPMsgGetAttrName(ospeAttrCritical),
 
1134
                        (const unsigned char *)"False");
 
1135
 
 
1136
                    if (attr != OSPC_OSNULL)
 
1137
                    {
 
1138
                        OSPPXMLElemAddAttr(elem, attr);
 
1139
                        attr = OSPC_OSNULL;
 
1140
                    }
 
1141
                    else
 
1142
                    {
 
1143
                        ospvErrCode = OSPC_ERR_XML_NO_ATTR;
 
1144
                    }
 
1145
 
 
1146
                    if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
1147
                    {
 
1148
                        OSPPXMLElemAddChild(authreqelem, elem);
 
1149
                        elem = OSPC_OSNULL;
 
1150
                    }
 
1151
 
 
1152
                    if (OSPPAuthReqHasTNDeviceId(ospvAuthReq) && ospvErrCode == OSPC_ERR_NO_ERROR)
 
1153
                    {
 
1154
                        ospvErrCode = OSPPMsgNumToElement( 
 
1155
                            OSPPAuthReqGetTNDeviceId(ospvAuthReq),
 
1156
                            (const unsigned char *) OSPPMsgGetElemName(ospeElemTNDeviceId),
 
1157
                            &elem);
 
1158
 
 
1159
                        if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
1160
                        {
 
1161
                            attr = OSPPXMLAttrNew(
 
1162
                                (const unsigned char *)OSPPMsgGetAttrName(ospeAttrCritical),
 
1163
                                (const unsigned char *)"False");
 
1164
 
 
1165
                            if (attr != OSPC_OSNULL)
 
1166
                            {
 
1167
                                OSPPXMLElemAddAttr(elem, attr);
 
1168
                                attr = OSPC_OSNULL;
 
1169
                            }
 
1170
                            else
 
1171
                            {
 
1172
                                ospvErrCode = OSPC_ERR_XML_NO_ATTR;
 
1173
                            }
 
1174
 
 
1175
                            if (ospvErrCode == OSPC_ERR_NO_ERROR)
 
1176
                            {
 
1177
                                OSPPXMLElemAddChild(authreqelem, elem);
 
1178
                                elem = OSPC_OSNULL;
 
1179
                            }                        
 
1180
                        }
 
1181
                    }
 
1182
                }
 
1183
            }
 
1184
        }
 
1185
 
 
1186
        if(ospvErrCode == OSPC_ERR_NO_ERROR)
 
1187
        {
 
1188
            /* Now add the authreqelem to the main elem */
 
1189
            OSPPXMLElemAddChild(*ospvElem, authreqelem);
 
1190
            authreqelem = OSPC_OSNULL;
 
1191
        }
 
1192
 
 
1193
        /* if for any reason we found an error - destroy any elements created */
 
1194
        if (ospvErrCode != OSPC_ERR_NO_ERROR)
 
1195
        {
 
1196
 
 
1197
            if(elem != OSPC_OSNULL)
 
1198
            {
 
1199
                OSPPXMLElemDelete(&elem);
 
1200
            }
 
1201
 
 
1202
            if(authreqelem != OSPC_OSNULL)
 
1203
            {
 
1204
                OSPPXMLElemDelete(&authreqelem);
 
1205
            }
 
1206
 
 
1207
            if(attr != OSPC_OSNULL)
 
1208
            {
 
1209
                OSPPXMLAttrDelete(&attr);
 
1210
            }
 
1211
 
 
1212
            if(*ospvElem != OSPC_OSNULL)
 
1213
            {
 
1214
                OSPPXMLElemDelete(ospvElem);
 
1215
            }
 
1216
        }
 
1217
    }
 
1218
    return(ospvErrCode);
 
1219
}
 
1220
 
 
1221
/*-----------------------------------------------------------------------*
 
1222
 * OSPPAuthReqHasMessageId() - is the message id set ?
 
1223
 *-----------------------------------------------------------------------*/
 
1224
unsigned                   /* returns non-zero if message id is set */
 
1225
OSPPAuthReqHasMessageId(
 
1226
    OSPTAUTHREQ *ospvAuthReq
 
1227
)
 
1228
{
 
1229
  return (ospvAuthReq->ospmAuthReqMessageId != OSPC_OSNULL);
 
1230
}