forked from zombieCraig/UDSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.h
114 lines (103 loc) · 3.66 KB
/
module.h
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
#ifndef UDS_MODULE_H
#define UDS_MODULE_H
#include <cstddef>
#include <vector>
#include <stdlib.h>
#include <string.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include "gamedata.h"
#include "canframe.h"
using namespace std;
class GameData;
extern GameData gd;
#define STATE_IDLE 0
#define STATE_ACTIVE 1
#define STATE_MOUSEOVER 2
#define STATE_SELECTED 3
#define MODULE_TYPE_UNKNOWN 0
#define MODULE_TYPE_GM 1
#define MODULE_H 30
#define MODULE_W 35
#define ACTIVE_TICK_DELAY 100
#define DEFAULT_VIN "PWN3D OP3N G4R4G3"
class Module
{
public:
Module(int id);
~Module();
void setArbId(int i) {arbId = i;}
int getArbId() { return arbId; }
void incMatchedISOTP() {matched_isotp++;}
void incMissedISOTP() {missed_isotp++;}
int getMatchedISOTP() { return matched_isotp; }
int getMissedISOTP() { return missed_isotp; }
void setPaddingByte(char b) {padding = true; padding_byte = b; }
float confidence();
void setPositiveResponderID(int i) { positive_responder_id = i; }
int getPositiveResponder() { return positive_responder_id; }
void setNegativeResponderID(int i) { negative_responder_id = i; }
int getNegativeResponder() { return negative_responder_id; }
void setResponder(bool v) { responder = v; }
bool isResponder() { return responder; }
void addPacket(struct canfd_frame *);
void addPacket(string);
vector <CanFrame *>getHistory() { return can_history; }
vector <CanFrame *>getPacketsByBytePos(unsigned int, unsigned char);
bool foundResponse(Module *);
int getState();
void setState(int s);
int getX() { return _x; }
int getY() { return _y; }
void setX(int x) { _x = x; }
void setY(int y) { _y = y; }
SDL_Texture *getIdTexture() { return id_texture; }
void setIdTexture(SDL_Texture *t) { id_texture = t; }
vector <CanFrame *>getResponse(struct canfd_frame *,bool);
void setType(int t) { _type = t; }
int getType() { return _type; }
void toggleFakeResponses() { _fake_responses ? _fake_responses = false : _fake_responses = true; }
void setFakeResponses(bool t) { _fake_responses = t; }
bool getFakeResponses() { return _fake_responses; }
void toggleIgnore() { _ignore ? _ignore = false : _ignore = true; }
void setIgnore(bool t) { _ignore = t; }
bool getIgnore() { return _ignore; }
void toggleFuzzVin() { _fuzz_vin ? _fuzz_vin = false : _fuzz_vin = true; }
void setFuzzVin(bool t) { _fuzz_vin = t; }
bool getFuzzVin() { return _fuzz_vin; }
unsigned int getFuzzLevel() { return _fuzz_level; }
void setFuzzLevel(unsigned int);
unsigned char calc_vin_checksum(char *, int);
vector <CanFrame *>inject_vin_checksum(vector <CanFrame *>);
vector <CanFrame *>fetchHistory(struct canfd_frame *);
vector <CanFrame *>fetchHistorySubfunc(struct canfd_frame *);
vector <CanFrame *>genericHandler(struct canfd_frame *);
vector <CanFrame *>showCurrentData(vector <CanFrame *>, struct canfd_frame *);
vector <CanFrame *>vehicleInfoRequest(vector <CanFrame *>, struct canfd_frame *);
vector <CanFrame *>fuzzResp(vector <CanFrame *>, struct canfd_frame *);
CanFrame *createPacket(int, char *, int);
void setActiveTicks(int i) { _activeTicks = i; }
int getActiveTicks() { return _activeTicks; }
private:
int arbId;
int matched_isotp = 0;
int missed_isotp = 0;
bool padding = false;
char padding_byte;
bool responder = false;
int state = STATE_IDLE;
int _activeTicks = 0;
int _x = 0;
int _y = 0;
int _type = 0;
SDL_Texture *id_texture = NULL;
vector<CanFrame *>can_history;
vector<CanFrame *>_queue;
int positive_responder_id = -1;
int negative_responder_id = -1;
unsigned int _fuzz_level = 0;
bool _fake_responses = false;
bool _fuzz_vin = false;
bool _ignore = false;
};
#endif