sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dfsan_interface.h
Go to the documentation of this file.
1 //===-- dfsan_interface.h -------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file is a part of DataFlowSanitizer.
11 //
12 // Public interface header.
13 //===----------------------------------------------------------------------===//
14 #ifndef DFSAN_INTERFACE_H
15 #define DFSAN_INTERFACE_H
16 
17 #include <stddef.h>
18 #include <stdint.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 typedef uint16_t dfsan_label;
26 
33  // Fields for union labels, set to 0 for base labels.
34  dfsan_label l1;
35  dfsan_label l2;
36 
37  // Fields for base labels.
38  const char *desc;
39  void *userdata;
40 };
41 
43 typedef void (*dfsan_write_callback_t)(int fd, const void *buf, size_t count);
44 
47 dfsan_label dfsan_union(dfsan_label l1, dfsan_label l2);
48 
50 dfsan_label dfsan_create_label(const char *desc, void *userdata);
51 
53 void dfsan_set_label(dfsan_label label, void *addr, size_t size);
54 
57 void dfsan_add_label(dfsan_label label, void *addr, size_t size);
58 
65 dfsan_label dfsan_get_label(long data);
66 
68 dfsan_label dfsan_read_label(const void *addr, size_t size);
69 
71 const struct dfsan_label_info *dfsan_get_label_info(dfsan_label label);
72 
74 int dfsan_has_label(dfsan_label label, dfsan_label elem);
75 
78 dfsan_label dfsan_has_label_with_desc(dfsan_label label, const char *desc);
79 
81 size_t dfsan_get_label_count(void);
82 
86 void dfsan_set_write_callback(dfsan_write_callback_t labeled_write_callback);
87 
92 void dfsan_dump_labels(int fd);
93 
100 void dfsan_weak_hook_memcmp(void *caller_pc, const void *s1, const void *s2,
101  size_t n, dfsan_label s1_label,
102  dfsan_label s2_label, dfsan_label n_label);
103 void dfsan_weak_hook_strncmp(void *caller_pc, const char *s1, const char *s2,
104  size_t n, dfsan_label s1_label,
105  dfsan_label s2_label, dfsan_label n_label);
106 #ifdef __cplusplus
107 } // extern "C"
108 
109 template <typename T>
110 void dfsan_set_label(dfsan_label label, T &data) { // NOLINT
111  dfsan_set_label(label, (void *)&data, sizeof(T));
112 }
113 
114 #endif
115 
116 #endif // DFSAN_INTERFACE_H
dfsan_label l2
Definition: dfsan_interface.h:35
void dfsan_set_label(dfsan_label label, void *addr, size_t size)
Sets the label for each address in [addr,addr+size) to label.
const struct dfsan_label_info * dfsan_get_label_info(dfsan_label label)
Retrieves a pointer to the dfsan_label_info struct for the given label.
void dfsan_weak_hook_strncmp(void *caller_pc, const char *s1, const char *s2, size_t n, dfsan_label s1_label, dfsan_label s2_label, dfsan_label n_label)
dfsan_label l1
Definition: dfsan_interface.h:34
void * userdata
Definition: dfsan_interface.h:39
tuple buf
Definition: DeviceGeneric.py:119
uint16_t dfsan_label
Definition: dfsan_interface.h:25
byte addr[8]
Definition: OWP_DG_1w-adaptor.ino:104
Definition: dfsan_interface.h:32
float T
Definition: Yun_Log_BatteryDisCharging.ino:108
void dfsan_weak_hook_memcmp(void *caller_pc, const void *s1, const void *s2, size_t n, dfsan_label s1_label, dfsan_label s2_label, dfsan_label n_label)
void dfsan_dump_labels(int fd)
tuple size
Definition: unpack-test.py:15
tuple data
Definition: ser-mon-AS7265X.py:40
void dfsan_set_write_callback(dfsan_write_callback_t labeled_write_callback)
size_t dfsan_get_label_count(void)
Returns the number of labels allocated.
void dfsan_add_label(dfsan_label label, void *addr, size_t size)
const char * desc
Definition: dfsan_interface.h:38
unsigned int count
Definition: Uno_Dragino_LoRa_GPS_Shield_TTN.ino:97
int dfsan_has_label(dfsan_label label, dfsan_label elem)
Returns whether the given label label contains the label elem.
dfsan_label dfsan_union(dfsan_label l1, dfsan_label l2)
dfsan_label dfsan_has_label_with_desc(dfsan_label label, const char *desc)
float n
Definition: OWGeneric_SensorStation.ino:147
dfsan_label dfsan_read_label(const void *addr, size_t size)
Retrieves the label associated with the data at the given address.
dfsan_label dfsan_get_label(long data)
void(* dfsan_write_callback_t)(int fd, const void *buf, size_t count)
Signature of the callback argument to dfsan_set_write_callback().
Definition: dfsan_interface.h:43
dfsan_label dfsan_create_label(const char *desc, void *userdata)
Creates and returns a base label with the given description and user data.