File: utils.h

package info (click to toggle)
ion 3.2.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 23,700 kB
  • ctags: 10,983
  • sloc: ansic: 141,798; sh: 22,848; makefile: 7,818; python: 1,638; sql: 311; perl: 197; awk: 178; xml: 50; java: 19
file content (104 lines) | stat: -rw-r--r-- 3,662 bytes parent folder | download | duplicates (2)
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
/******************************************************************************
 **                           COPYRIGHT NOTICE
 **      (c) 2012 The Johns Hopkins University Applied Physics Laboratory
 **                         All rights reserved.
 **
 **     This material may only be used, modified, or reproduced by or for the
 **       U.S. Government pursuant to the license rights granted under
 **          FAR clause 52.227-14 or DFARS clauses 252.227-7013/7014
 **
 **     For any other permissions, please contact the Legal Office at JHU/APL.
 ******************************************************************************/

/*****************************************************************************
 **
 ** File Name: utils.h
 **
 ** Subsystem:
 **          Network Management Utilities
 **
 ** Description: This file contains the definitions, prototypes, constants, and
 **              other information necessary for the identification and
 **              processing of DTNMP Managed Identifiers (MIDs).
 **
 ** Notes:
 **
 ** Assumptions:
 **
 **
 ** Modification History:
 **  MM/DD/YY  AUTHOR         DESCRIPTION
 **  --------  ------------   ---------------------------------------------
 **  10/29/12  E. Birrane     Initial Implementation
 *****************************************************************************/

#ifndef UTILS_H_
#define UTILS_H_

#include "stdint.h"

#include "bp.h"
#include "lyst.h"


/*
 * +--------------------------------------------------------------------------+
 * |							  CONSTANTS  								  +
 * +--------------------------------------------------------------------------+
 */

#ifndef MIN
#define MIN(x,y) (x < y ? x : y)
#endif



/*
 * +--------------------------------------------------------------------------+
 * |							  DATA TYPES  								  +
 * +--------------------------------------------------------------------------+
 */


/**
 * The Data Collection is similar to a MID collection: an SDNV count followed
 * by one or more of a homogeneous structure.  In the case of a Data Collection,
 * the structure is given by the datacol_entry_t.  This is simply a buffer with
 * associated byte length.
 */
typedef struct {
	uint8_t *value;   /**> The data associated with the entry. */
	uint32_t length;  /**> The length of the data in bytes. */
} datacol_entry_t;


/*
 * +--------------------------------------------------------------------------+
 * |						  DATA DEFINITIONS  							  +
 * +--------------------------------------------------------------------------+
 */


/*
 * +--------------------------------------------------------------------------+
 * |						  FUNCTION PROTOTYPES  							  +
 * +--------------------------------------------------------------------------+
 */

//unsigned long utils_atox(char *s);
unsigned long utils_atox(char *s, int *success);

int      utils_datacol_compare(Lyst col1, Lyst col2);
Lyst     utils_datacol_copy(Lyst col);
Lyst     utils_datacol_deserialize(uint8_t* buffer, uint32_t buffer_size, uint32_t *bytes_used);
void     utils_datacol_destroy(Lyst *datacol);
uint8_t* utils_datacol_serialize(Lyst datacol, uint32_t *size);
int8_t   utils_grab_byte(unsigned char *cursor, uint32_t size, uint8_t *result);
uint32_t utils_grab_sdnv(unsigned char *cursor, uint32_t size, uvast *result);
char*    utils_hex_to_string(uint8_t *buffer, uint32_t size);
void     utils_print_hex(unsigned char *s, uint32_t len);
uint8_t* utils_string_to_hex(unsigned char *value, uint32_t *size);
int      utils_time_delta(struct timeval *result, struct timeval *t1, struct timeval *t2);
vast     utils_time_cur_delta(struct timeval *t1);

#endif /* UTILS_H_ */