2 #include <linux/rtnetlink.h>
3 #include <netinet/ip6.h>
12 int plugin_api_version
= PLUGIN_API_VERSION
;
13 static struct pluginfuncs
*f
= 0;
15 char *plugin_control_help
[] = {
16 " drop USER|SID [REASON] Shutdown user session",
17 " kill USER|SID [REASON] Kill user session",
21 int plugin_control(struct param_control
*data
)
31 if (strcmp(data
->argv
[0], "drop") && strcmp(data
->argv
[0], "kill"))
32 return PLUGIN_RET_OK
; // not for us
34 if (!data
->iam_master
)
35 return PLUGIN_RET_NOTMASTER
;
37 if (data
->argc
< 2 || data
->argc
> 3)
39 data
->response
= NSCTL_RES_ERR
;
40 data
->additional
= "requires username or session id and optional reason";
41 return PLUGIN_RET_STOP
;
44 if (!(session
= strtol(data
->argv
[1], &end
, 10)) || *end
)
45 session
= f
->get_session_by_username(data
->argv
[1]);
48 s
= f
->get_session_by_id(session
);
52 data
->response
= NSCTL_RES_ERR
;
53 data
->additional
= "session not found";
54 return PLUGIN_RET_STOP
;
58 reason
= data
->argv
[2];
60 reason
= "Requested by administrator.";
62 if (data
->argv
[0][0] == 'd')
63 f
->sessionshutdown(session
, reason
, CDN_ADMIN_DISC
, TERM_ADMIN_RESET
);
65 f
->sessionkill(session
, reason
);
67 data
->response
= NSCTL_RES_OK
;
70 return PLUGIN_RET_STOP
;
73 int plugin_init(struct pluginfuncs
*funcs
)
75 return ((f
= funcs
)) ? 1 : 0;