-
Notifications
You must be signed in to change notification settings - Fork 2
/
basic_config.c
54 lines (37 loc) · 1.29 KB
/
basic_config.c
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
#include <stdio.h>
#include <stdlib.h>
#include "sysrepo.h"
#define CHECK_RC(RC, LABEL) do {if (SR_ERR_OK != rc) {goto LABEL; } } while(0)
int main(int argc, char **argv) {
int rc = SR_ERR_OK;
sr_conn_ctx_t *conn = NULL;
sr_session_ctx_t *sess = NULL;
sr_val_t val = {0};
sr_log_stderr(SR_LL_DBG);
rc = sr_connect("push kea config", SR_CONN_DEFAULT, &conn);
CHECK_RC(rc, cleanup);
rc = sr_session_start(conn, SR_DS_STARTUP, SR_SESS_DEFAULT, &sess);
CHECK_RC(rc, cleanup);
/* socket type */
val.xpath = "/ietf-kea-dhcpv6:server/serv-attributes/control-socket/socket-type";
val.type = SR_STRING_T;
val.data.string_val = "unix";
rc = sr_set_item(sess, val.xpath, &val, SR_EDIT_DEFAULT);
CHECK_RC(rc, cleanup);
/* socket name */
val.xpath = "/ietf-kea-dhcpv6:server/serv-attributes/control-socket/socket-name";
val.type = SR_STRING_T;
val.data.string_val = "/tmp/kea-dhcp6-ctrl.sock";
rc = sr_set_item(sess, val.xpath, &val, SR_EDIT_DEFAULT);
CHECK_RC(rc, cleanup);
rc = sr_commit(sess);
/* retrieve field */
sr_val_t* val2 = 0;
rc = sr_get_item(sess, val.xpath, &val2);
printf("Retrieved: [%s]\n", val.data.string_val);
sr_free_val(val2);
CHECK_RC(rc, cleanup);
cleanup:
sr_session_stop(sess);
sr_disconnect(conn);
}