diff --git a/src/barebox-state/state.c b/src/barebox-state/state.c index 2c613a9..0036b69 100644 --- a/src/barebox-state/state.c +++ b/src/barebox-state/state.c @@ -692,6 +692,27 @@ return 0; } +int state_read_mac(struct state *state, const char *name, u8 *buf) +{ + struct state_variable *svar; + struct state_mac *mac; + + if (!state || !name || !buf) + return -EINVAL; + + svar = state_find_var(state, name); + if (IS_ERR(svar)) + return PTR_ERR(svar); + + if (svar->type->type != STATE_VARIABLE_TYPE_MAC) + return -EINVAL; + + mac = to_state_mac(svar); + memcpy(buf, mac->value, 6); + + return 0; +} + void state_info(void) { struct state *state; diff --git a/src/state.h b/src/state.h index ce420d1..888b491 100644 --- a/src/state.h +++ b/src/state.h @@ -23,4 +23,6 @@ int state_save(struct state *state); void state_info(void); +int state_read_mac(struct state *state, const char *name, u8 *buf); + #endif /* __STATE_H */