1 |
dpavlin |
1 |
/* |
2 |
dpavlin |
7 |
* Cisco router simulation platform. |
3 |
dpavlin |
1 |
* Copyright (c) 2006 Christophe Fillot. All rights reserved. |
4 |
|
|
* |
5 |
|
|
* Cisco EEPROM manipulation functions. |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#ifndef __CISCO_EEPROM_H__ |
9 |
|
|
#define __CISCO_EEPROM_H__ |
10 |
|
|
|
11 |
|
|
#include "utils.h" |
12 |
|
|
|
13 |
dpavlin |
3 |
/* Cisco EEPROM */ |
14 |
|
|
struct cisco_eeprom { |
15 |
|
|
char *name; |
16 |
|
|
m_uint16_t *data; |
17 |
|
|
size_t len; |
18 |
|
|
}; |
19 |
|
|
|
20 |
|
|
/* Find a NM EEPROM */ |
21 |
|
|
const struct cisco_eeprom *cisco_eeprom_find_nm(char *name); |
22 |
|
|
|
23 |
|
|
/* Find a PA EEPROM */ |
24 |
|
|
const struct cisco_eeprom *cisco_eeprom_find_pa(char *name); |
25 |
|
|
|
26 |
|
|
/* Find an EEPROM in the specified EEPROM array */ |
27 |
|
|
const struct cisco_eeprom * |
28 |
|
|
cisco_eeprom_find(const struct cisco_eeprom *eeproms,char *name); |
29 |
|
|
|
30 |
|
|
/* Copy an EEPROM */ |
31 |
|
|
int cisco_eeprom_copy(struct cisco_eeprom *dst,const struct cisco_eeprom *src); |
32 |
|
|
|
33 |
|
|
/* Free resources used by an EEPROM */ |
34 |
|
|
void cisco_eeprom_free(struct cisco_eeprom *eeprom); |
35 |
|
|
|
36 |
|
|
/* Return TRUE if the specified EEPROM contains usable data */ |
37 |
|
|
int cisco_eeprom_valid(struct cisco_eeprom *eeprom); |
38 |
|
|
|
39 |
dpavlin |
1 |
/* Get a byte from an EEPROM */ |
40 |
dpavlin |
3 |
int cisco_eeprom_get_byte(struct cisco_eeprom *eeprom, |
41 |
dpavlin |
1 |
size_t offset,m_uint8_t *val); |
42 |
|
|
|
43 |
|
|
/* Set a byte to an EEPROM */ |
44 |
dpavlin |
3 |
int cisco_eeprom_set_byte(struct cisco_eeprom *eeprom, |
45 |
dpavlin |
1 |
size_t offset,m_uint8_t val); |
46 |
|
|
|
47 |
|
|
/* Get an EEPROM region */ |
48 |
dpavlin |
3 |
int cisco_eeprom_get_region(struct cisco_eeprom *eeprom,size_t offset, |
49 |
|
|
m_uint8_t *data,size_t data_len); |
50 |
dpavlin |
1 |
|
51 |
|
|
/* Set an EEPROM region */ |
52 |
dpavlin |
3 |
int cisco_eeprom_set_region(struct cisco_eeprom *eeprom,size_t offset, |
53 |
|
|
m_uint8_t *data,size_t data_len); |
54 |
dpavlin |
1 |
|
55 |
dpavlin |
3 |
/* Get a field of a Cisco EEPROM v4 */ |
56 |
|
|
int cisco_eeprom_v4_get_field(struct cisco_eeprom *eeprom,m_uint8_t *type, |
57 |
|
|
m_uint8_t *len,size_t *offset); |
58 |
|
|
|
59 |
dpavlin |
1 |
/* Dump a Cisco EEPROM with format version 4 */ |
60 |
dpavlin |
3 |
void cisco_eeprom_v4_dump(struct cisco_eeprom *eeprom); |
61 |
dpavlin |
1 |
|
62 |
|
|
/* Returns the offset of the specified field */ |
63 |
dpavlin |
3 |
int cisco_eeprom_v4_find_field(struct cisco_eeprom *eeprom, |
64 |
|
|
m_uint8_t field_type, |
65 |
|
|
size_t *field_offset); |
66 |
dpavlin |
1 |
|
67 |
|
|
#endif |
68 |
|
|
|