struct lldpd_config config = {};
char *iface_pattern = NULL, *mgmt_pattern = NULL;
char *description = NULL;
+ char *canary = NULL;
int rc, len;
len = strlen(value) + 1;
return NULL;
}
+ if (asprintf(&canary, "%d%s", key, value) == -1) {
+ SET_ERROR(atom->conn, LLDPCTL_ERR_NOMEM);
+ return NULL;
+ }
rc = _lldpctl_do_something(atom->conn,
CONN_STATE_SET_CONFIG_SEND, CONN_STATE_SET_CONFIG_RECV,
- NULL,
+ canary,
SET_CONFIG, &config, &MARSHAL_INFO(lldpd_config),
NULL, NULL);
+ free(canary);
if (rc == 0) return atom;
return NULL;
long int value)
{
int rc;
+ char *canary = NULL;
struct _lldpctl_atom_config_t *c =
(struct _lldpctl_atom_config_t *)atom;
struct lldpd_config config = {};
return NULL;
}
+ if (asprintf(&canary, "%d%ld", key, value) == -1) {
+ SET_ERROR(atom->conn, LLDPCTL_ERR_NOMEM);
+ return NULL;
+ }
rc = _lldpctl_do_something(atom->conn,
CONN_STATE_SET_CONFIG_SEND, CONN_STATE_SET_CONFIG_RECV,
- NULL,
+ canary,
SET_CONFIG, &config, &MARSHAL_INFO(lldpd_config),
NULL, NULL);
+ free(canary);
if (rc == 0) return atom;
return NULL;
}
struct lldpd_hardware *hardware = p->hardware;
struct lldpd_port_set set = {};
int rc;
+ char *canary;
#ifdef ENABLE_DOT3
struct _lldpctl_atom_dot3_power_t *dpow;
}
set.ifname = hardware->h_ifname;
+
+ if (asprintf(&canary, "%d%p%s", key, value, set.ifname) == -1) {
+ SET_ERROR(atom->conn, LLDPCTL_ERR_NOMEM);
+ return NULL;
+ }
rc = _lldpctl_do_something(atom->conn,
CONN_STATE_SET_PORT_SEND, CONN_STATE_SET_PORT_RECV,
- value,
+ canary,
SET_PORT, &set, &MARSHAL_INFO(lldpd_port_set),
NULL, NULL);
+ free(canary);
if (rc == 0) return atom;
return NULL;
}
*/
int
_lldpctl_do_something(lldpctl_conn_t *conn,
- int state_send, int state_recv, void *state_data,
+ int state_send, int state_recv, const char *state_data,
enum hmsg_type type,
void *to_send, struct marshal_info *mi_send,
void **to_recv, struct marshal_info *mi_recv)
conn->state = state_send;
conn->state_data = state_data;
}
- if (conn->state == state_send && conn->state_data == state_data) {
+ if (conn->state == state_send &&
+ (state_data == NULL || !strcmp(conn->state_data, state_data))) {
/* We need to send the currently built message */
rc = lldpctl_send(conn);
if (rc < 0)
return SET_ERROR(conn, rc);
conn->state = state_recv;
}
- if (conn->state == state_recv && conn->state_data == state_data) {
+ if (conn->state == state_recv &&
+ (state_data == NULL || !strcmp(conn->state_data, state_data))) {
/* We need to receive the answer */
while ((rc = ctl_msg_recv_unserialized(&conn->input_buffer,
&conn->input_buffer_len,
#define CONN_STATE_SET_CONFIG_SEND 10
#define CONN_STATE_SET_CONFIG_RECV 11
int state; /* Current state */
- void *state_data; /* Data attached to the state. It is used to
+ const char *state_data; /* Data attached to the state. It is used to
* check that we are using the same data as a
* previous call until the state machine goes to
* CONN_STATE_IDLE. */
ssize_t _lldpctl_needs(lldpctl_conn_t *lldpctl, size_t length);
int _lldpctl_do_something(lldpctl_conn_t *conn,
- int state_send, int state_recv, void *state_data,
+ int state_send, int state_recv, const char *state_data,
enum hmsg_type type,
void *to_send, struct marshal_info *mi_send,
void **to_recv, struct marshal_info *mi_recv);