-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy path15_dhcpv6_client.c
More file actions
116 lines (103 loc) · 4.55 KB
/
15_dhcpv6_client.c
File metadata and controls
116 lines (103 loc) · 4.55 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* If not stated otherwise in this file or this component's Licenses.txt file the
* following copyright and licenses apply:
*
* Copyright 2015 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**********************************************************************
Copyright [2014] [Cisco Systems, Inc.]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
**********************************************************************/
#include <stdio.h>
#include "srvmgr.h"
#include "secure_wrapper.h"
#ifdef RDKB_EXTENDER_ENABLED
#include <string.h>
#include <stdlib.h>
#endif
#define SERVICE_NAME "dhcpv6_client"
#define SERVICE_DEFAULT_HANDLER "/etc/utopia/service.d/service_dhcpv6_client.sh"
#if defined(CORE_NET_LIB)
const char* SERVICE_CUSTOM_EVENTS[] = {
"dhcpv6_client-start|/usr/bin/service_dhcpv6_client",
"dhcpv6_client-stop|/usr/bin/service_dhcpv6_client",
"dhcpv6_client-restart|/usr/bin/service_dhcpv6_client",
"erouter_mode-updated|/usr/bin/service_dhcpv6_client",
"phylink_wan_state|/usr/bin/service_dhcpv6_client",
"current_wan_ifname|/usr/bin/service_dhcpv6_client",
"bridge_mode|/usr/bin/service_dhcpv6_client",
"current_ipv4_link_state|/usr/bin/service_dhcpv6_client",
"lan-status|/usr/bin/service_dhcpv6_client",
NULL
};
#elif defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_)
const char* SERVICE_CUSTOM_EVENTS[] = {
"erouter_mode-updated|/etc/utopia/service.d/service_dhcpv6_client.sh",
"phylink_wan_state|/etc/utopia/service.d/service_dhcpv6_client.sh",
"current_wan_ifname|/etc/utopia/service.d/service_dhcpv6_client.sh",
"bridge_mode|/etc/utopia/service.d/service_dhcpv6_client.sh",
NULL
};
#else
const char* SERVICE_CUSTOM_EVENTS[] = {
"current_ipv4_link_state|/etc/utopia/service.d/service_dhcpv6_client.sh",
"current_wan_ifname|/etc/utopia/service.d/service_dhcpv6_client.sh",
"lan-status|/etc/utopia/service.d/service_dhcpv6_client.sh",
NULL
};
#endif
void srv_register(void) {
sm_register(SERVICE_NAME, SERVICE_DEFAULT_HANDLER, SERVICE_CUSTOM_EVENTS);
}
#ifdef RDKB_EXTENDER_ENABLED
void stop_service()
{
v_secure_system(SERVICE_DEFAULT_HANDLER " " SERVICE_NAME "-stop");
}
#endif
void srv_unregister(void) {
#ifdef RDKB_EXTENDER_ENABLED
stop_service();
#endif
sm_unregister(SERVICE_NAME);
}
int main(int argc, char **argv)
{
cmd_type_t choice = parse_cmd_line(argc, argv);
switch(choice) {
case(nochoice):
case(start):
srv_register();
break;
case(stop):
srv_unregister();
break;
case(restart):
srv_unregister();
srv_register();
break;
default:
printf("%s called with invalid parameter (%s)\n", argv[0], 1==argc ? "" : argv[1]);
}
return(0);
}