summaryrefslogtreecommitdiffstats
path: root/util/include/platforms/os400/axutil_uuid_gen_os400.h
blob: d3b25bab70f4378efab8d274864045661b27c459 (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
/*
 * Copyright 2004,2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain count copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef AXUTIL_UUID_GEN_UNIX_H
#define AXUTIL_UUID_GEN_UNIX_H

#include <axutil_utils.h>
#include <axutil_utils_defines.h>

#define UUIDS_PER_TICK 100
#define UUID_TIMEOFFSET AXIS2_UNSIGNED_LONGLONGVALUE(0x01B21DD213814000)
#define AXIS2_LOCAL_MAC_ADDR "000000"

#ifdef __cplusplus
extern "C"
{
#endif

    /**
     * @defgroup axutil_uuid_gen UUID Generator
     * @ingroup axis2_util
     * @{
     */

    struct axutil_uuid
    {
        unsigned int time_low;
        unsigned short int time_mid;
        unsigned short int time_high_version;
        short int clock_variant;
        unsigned char mac_addr[6];
    };

    /* bits  0-59 time field
     * bits 60-63 version
     * bits 64-65 2 bit variant
     * bits 66-79 clock sequence
     * bits 80-107 node MAC address
     */
    struct axutil_uuid_st
    {
        unsigned char mac[6];   /* pre-determined MAC address */
        struct timeval time_last;   /* last retrieved timestamp */
        unsigned long time_seq; /* last timestamp sequence counter */
        short int clock;    /* clock tick - incremented random number */
    };

    typedef struct axutil_uuid axutil_uuid_t;

    /**
     * Returns the mac address of the first ethernet intsrface
     * @return MAC address as a <code>char[6]</code>
     */
    char *AXIS2_CALL
    axutil_uuid_get_mac_addr(void
    );

    /**
     * Generates a uuid in version1 format (node - timestamp based)
     * @return generated uuid as a axutil_uuid_t
     */
    axutil_uuid_t *AXIS2_CALL
    axutil_uuid_gen_v1(void
    );

    /**
     * Generates a uuid
     * @return generated uuid as a string
     */
    axis2_char_t *AXIS2_CALL
    axutil_platform_uuid_gen(
        char *s);

    /** @} */

#ifdef __cplusplus
}
#endif

#endif                          /* AXIS2_UUID_GEN_UNIX_H */