mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-22 01:53:43 +08:00
Compare commits
845 Commits
json-edito
...
ap_autocon
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bb3ead2e6 | ||
|
|
86044f0d80 | ||
|
|
b1e1e5891e | ||
|
|
f8e2f37600 | ||
|
|
1d3e91ab3d | ||
|
|
05dd9b93e3 | ||
|
|
4eb4dce310 | ||
|
|
c36e90e571 | ||
|
|
84a4143077 | ||
|
|
3b377968a1 | ||
|
|
e3270bd71a | ||
|
|
8e7a3139ea | ||
|
|
a68237119c | ||
|
|
50c52afe3c | ||
|
|
c377c19bed | ||
|
|
45643376ed | ||
|
|
df58fd64d4 | ||
|
|
a5e43567b3 | ||
|
|
e03568f9b1 | ||
|
|
ea23e1489c | ||
|
|
32db63deb0 | ||
|
|
5211a49f67 | ||
|
|
907f2fc59b | ||
|
|
cf8571b217 | ||
|
|
86bab4da22 | ||
|
|
3bdf2ba11b | ||
|
|
4ee3a92064 | ||
|
|
f1b4cbc520 | ||
|
|
dff5045437 | ||
|
|
80a057b727 | ||
|
|
84a8afe5da | ||
|
|
609035d250 | ||
|
|
bb0299fe26 | ||
|
|
57f6e54646 | ||
|
|
859a2af38e | ||
|
|
477284e1a6 | ||
|
|
a9d10a8642 | ||
|
|
01cf113338 | ||
|
|
7da94735b5 | ||
|
|
baccd9ad56 | ||
|
|
1642841acd | ||
|
|
c3157ef44e | ||
|
|
127f732831 | ||
|
|
be91f797dc | ||
|
|
ae7a3e329f | ||
|
|
ef37f8d9c1 | ||
|
|
07ca78f548 | ||
|
|
10a11f0cb8 | ||
|
|
4c11cdac89 | ||
|
|
8b51e8c03b | ||
|
|
2d9f03d6ab | ||
|
|
e19674ea70 | ||
|
|
0af09b123c | ||
|
|
6e6f7289ad | ||
|
|
25f6109691 | ||
|
|
7e0fe946cd | ||
|
|
c831c34a94 | ||
|
|
a9180d3a2b | ||
|
|
3ad8ef4b40 | ||
|
|
17fd0ab28a | ||
|
|
8ae15aa39b | ||
|
|
1ed5f0c0f6 | ||
|
|
939ff109c2 | ||
|
|
5c9469589c | ||
|
|
d6dae7cd0b | ||
|
|
0872d45d63 | ||
|
|
14e54fbf04 | ||
|
|
105edbfada | ||
|
|
a77deb3f36 | ||
|
|
38f737fa20 | ||
|
|
600209795d | ||
|
|
6819ccef9c | ||
|
|
8d257729ef | ||
|
|
78c84db435 | ||
|
|
1b1e071b1b | ||
|
|
38bf0e3c89 | ||
|
|
2506c9874a | ||
|
|
ee486af38b | ||
|
|
bf871111a5 | ||
|
|
1388b566bc | ||
|
|
a63295be52 | ||
|
|
450b9eaee9 | ||
|
|
e22a60c637 | ||
|
|
32817656e1 | ||
|
|
da017f98e2 | ||
|
|
1e3c338abb | ||
|
|
034f69408a | ||
|
|
d86e277461 | ||
|
|
2f333148b2 | ||
|
|
8a275944e3 | ||
|
|
76d40e2e1e | ||
|
|
e00394f158 | ||
|
|
64944425f5 | ||
|
|
9d996bdf9e | ||
|
|
5c8e7cb740 | ||
|
|
201fb45c6c | ||
|
|
7e2cdb88fb | ||
|
|
f750ab67d7 | ||
|
|
1ba812351d | ||
|
|
efc11f8c6d | ||
|
|
69cf19cc8e | ||
|
|
085ec84436 | ||
|
|
faec0f002a | ||
|
|
436a57f8d6 | ||
|
|
e3d0362d1f | ||
|
|
3135ad4865 | ||
|
|
12f4a5380b | ||
|
|
3887bab7f7 | ||
|
|
a6a54316e8 | ||
|
|
0273969b9c | ||
|
|
0781d5620d | ||
|
|
d8d42400b1 | ||
|
|
c3ee0a2d8a | ||
|
|
d66c3c0bbf | ||
|
|
a57d03d7e9 | ||
|
|
ec35396ffc | ||
|
|
7e9a109466 | ||
|
|
21c9d13b7a | ||
|
|
f467f2a90f | ||
|
|
8ffe458009 | ||
|
|
a9122f9909 | ||
|
|
cea453c91c | ||
|
|
4b707a26f4 | ||
|
|
81a39308cc | ||
|
|
73d7e51afa | ||
|
|
557f2693d3 | ||
|
|
c9b2973ac8 | ||
|
|
6f15e7ff27 | ||
|
|
f431a3ddf5 | ||
|
|
4ce6578aa7 | ||
|
|
39ab8e9282 | ||
|
|
e5694c1429 | ||
|
|
0c998dbb66 | ||
|
|
d8b5f3e1f0 | ||
|
|
0b39626067 | ||
|
|
5665076321 | ||
|
|
db5c1613f5 | ||
|
|
c82cf9ebb0 | ||
|
|
1f7565536d | ||
|
|
1922fa2560 | ||
|
|
fe86ade858 | ||
|
|
f49c4f4a64 | ||
|
|
ac7491c010 | ||
|
|
63db10eb1f | ||
|
|
651ad4ce22 | ||
|
|
51a3b0ad35 | ||
|
|
0c8b1ea046 | ||
|
|
104805a36e | ||
|
|
a1bfb1b568 | ||
|
|
5c744f71e3 | ||
|
|
20ca483d80 | ||
|
|
7a466c989c | ||
|
|
ff63939e84 | ||
|
|
3b283b8f3a | ||
|
|
d93d72587e | ||
|
|
b098ef3dc2 | ||
|
|
8c69fc062a | ||
|
|
8ad4f32786 | ||
|
|
71b66376f0 | ||
|
|
48525b051a | ||
|
|
753e894b69 | ||
|
|
ce701702c5 | ||
|
|
11550d140a | ||
|
|
f622a96054 | ||
|
|
3f19a43df2 | ||
|
|
d2fedc407a | ||
|
|
783fd44680 | ||
|
|
614774cb8b | ||
|
|
84521942ca | ||
|
|
bbbbdf9650 | ||
|
|
98071d157d | ||
|
|
d829f00e07 | ||
|
|
640535a2ef | ||
|
|
7837417219 | ||
|
|
269cbe364e | ||
|
|
54cc458a2d | ||
|
|
fdc882b6e0 | ||
|
|
346eaf0414 | ||
|
|
d946f11c32 | ||
|
|
c0957a425a | ||
|
|
8015a503ac | ||
|
|
a7d09f5ede | ||
|
|
8a5b49d585 | ||
|
|
ac69ea616e | ||
|
|
f358d6338d | ||
|
|
c514903145 | ||
|
|
dd69c371ae | ||
|
|
4a1ab17bd4 | ||
|
|
208b2cc8e5 | ||
|
|
2e934a7169 | ||
|
|
b06980688a | ||
|
|
29b9605e02 | ||
|
|
0afa721bca | ||
|
|
3c0de388d1 | ||
|
|
aa1741e87a | ||
|
|
3040359e85 | ||
|
|
237286f42d | ||
|
|
7758b30397 | ||
|
|
7b0dce915c | ||
|
|
b6fdd0115a | ||
|
|
392e08e2fc | ||
|
|
2ae2110799 | ||
|
|
773e7af7f6 | ||
|
|
75e9a5360f | ||
|
|
db5e42434e | ||
|
|
00fd7efa3b | ||
|
|
34f495f0a5 | ||
|
|
e3b7c9c238 | ||
|
|
e3f2e715c1 | ||
|
|
4c149ff680 | ||
|
|
959b0546bc | ||
|
|
e39430ceaf | ||
|
|
6ea9942320 | ||
|
|
a5e812f785 | ||
|
|
a604987a3e | ||
|
|
7b2d8edacf | ||
|
|
47b2b4fc51 | ||
|
|
6b3e6bcd11 | ||
|
|
52726289cc | ||
|
|
6c2aac5db5 | ||
|
|
bfc2b17a72 | ||
|
|
e98422f81e | ||
|
|
841a76a7e6 | ||
|
|
1760ea526c | ||
|
|
b5a493e540 | ||
|
|
7f00d0419f | ||
|
|
64da6686af | ||
|
|
8cc1877efd | ||
|
|
6673a85a21 | ||
|
|
3e07ea7f8d | ||
|
|
8b4ef46681 | ||
|
|
f35e41cc0c | ||
|
|
0aff258e29 | ||
|
|
d919f4440e | ||
|
|
9d20839041 | ||
|
|
36ec134e33 | ||
|
|
ea57418313 | ||
|
|
c61aa804ce | ||
|
|
19bbb87682 | ||
|
|
3ee01927b1 | ||
|
|
d9f6b37bd7 | ||
|
|
c3dd0a996b | ||
|
|
90c5c5c52c | ||
|
|
f7cb4c8aac | ||
|
|
07cbf0938e | ||
|
|
a31bb99c30 | ||
|
|
80e3d89d9a | ||
|
|
d26eaf0ef0 | ||
|
|
e437fc821e | ||
|
|
c86d16daf9 | ||
|
|
a91b41d70a | ||
|
|
847b27c879 | ||
|
|
89fe5115f0 | ||
|
|
aba88e359d | ||
|
|
84b594e9bf | ||
|
|
e3dd402d4e | ||
|
|
a06ffa00ce | ||
|
|
c3c5d4ff8b | ||
|
|
bb996c64df | ||
|
|
adbb8b70c1 | ||
|
|
34b3478d77 | ||
|
|
181dd5039e | ||
|
|
10e83915c7 | ||
|
|
59e0b78e84 | ||
|
|
c1e7c8f103 | ||
|
|
de9a7c447d | ||
|
|
8cbcc039d7 | ||
|
|
044dd31be4 | ||
|
|
48b286031a | ||
|
|
ee3dceb433 | ||
|
|
aa1353f08e | ||
|
|
682497f68c | ||
|
|
bfb98073c1 | ||
|
|
a8960be7b5 | ||
|
|
6255b9b2df | ||
|
|
4e11dda2c0 | ||
|
|
c898217717 | ||
|
|
4d2358aa2a | ||
|
|
d3fb4ec562 | ||
|
|
b06ca2b5e5 | ||
|
|
30928e5eb9 | ||
|
|
c75d639a69 | ||
|
|
0bb19c25f7 | ||
|
|
64a826896d | ||
|
|
eee9c7a70c | ||
|
|
0c0e9f15f2 | ||
|
|
48ab39fa31 | ||
|
|
6914c0548f | ||
|
|
ffe74261d9 | ||
|
|
1b5630c67e | ||
|
|
2bf5014aeb | ||
|
|
279a583d23 | ||
|
|
0a0cad9715 | ||
|
|
74618b9377 | ||
|
|
5ff2854490 | ||
|
|
7ae3a29d08 | ||
|
|
68e4189d05 | ||
|
|
c0f7c0ecf1 | ||
|
|
825f1ff76d | ||
|
|
7fa1bf30c1 | ||
|
|
ee3e6d5975 | ||
|
|
96d0a3fba8 | ||
|
|
7b158a918a | ||
|
|
6bad87c47f | ||
|
|
c73ae26618 | ||
|
|
d73a60a4f3 | ||
|
|
0c52946965 | ||
|
|
e89485f19c | ||
|
|
bfb73ba4b5 | ||
|
|
b3e19722b7 | ||
|
|
908ef455c2 | ||
|
|
950687c88b | ||
|
|
5675ff87de | ||
|
|
ae0213ce8c | ||
|
|
a45957e872 | ||
|
|
2c67b66e15 | ||
|
|
bf5b932a93 | ||
|
|
3f6c55a86d | ||
|
|
133c45e91d | ||
|
|
fce1fa2eae | ||
|
|
986fc5ea78 | ||
|
|
95e887087f | ||
|
|
0082d26141 | ||
|
|
2306b1e76f | ||
|
|
7b432d88f8 | ||
|
|
c56aed73d4 | ||
|
|
af719df40c | ||
|
|
2d25beb3ab | ||
|
|
ba561afb24 | ||
|
|
4f8906c1f7 | ||
|
|
42c7aafb93 | ||
|
|
6c1b78b69d | ||
|
|
1eade44fe6 | ||
|
|
834522d107 | ||
|
|
cc65e6ce52 | ||
|
|
b2061f27e0 | ||
|
|
cc26f7bbe9 | ||
|
|
6841172f75 | ||
|
|
8fd7232ea2 | ||
|
|
4d7ac5941e | ||
|
|
2bd9e1ac13 | ||
|
|
766379c8e4 | ||
|
|
dd8edbec71 | ||
|
|
a0bfac1658 | ||
|
|
ec68c58bb7 | ||
|
|
701a77b6b3 | ||
|
|
18e94a6b47 | ||
|
|
514a85703c | ||
|
|
e72ef7290b | ||
|
|
428a1791ed | ||
|
|
43bd7d872f | ||
|
|
1fd62bbfa2 | ||
|
|
08c542cf6f | ||
|
|
098f3340b1 | ||
|
|
d43113a471 | ||
|
|
597fadf578 | ||
|
|
d45959b3da | ||
|
|
8952a6eca8 | ||
|
|
c5df7e08a1 | ||
|
|
a2c6430caa | ||
|
|
e364957074 | ||
|
|
a14e72e26f | ||
|
|
fc38f16aa5 | ||
|
|
ebf1f8fd39 | ||
|
|
005d53ff14 | ||
|
|
a585061b6c | ||
|
|
c945f19c3c | ||
|
|
9566dbfb8e | ||
|
|
120785335c | ||
|
|
f87a160b98 | ||
|
|
bf6342472a | ||
|
|
36e9c3a3d7 | ||
|
|
3c79856802 | ||
|
|
e29ab21280 | ||
|
|
c2b993b494 | ||
|
|
fbc5226978 | ||
|
|
3d5a5d4697 | ||
|
|
0be99d1bc0 | ||
|
|
053bfa1442 | ||
|
|
0346ce9285 | ||
|
|
ae3b959cbf | ||
|
|
2e10c5845e | ||
|
|
83bb965d81 | ||
|
|
a80cff151d | ||
|
|
76a5df9115 | ||
|
|
e63d9f0445 | ||
|
|
0432b27f39 | ||
|
|
dcae4a36ea | ||
|
|
3dc00d7c04 | ||
|
|
12a7fb224d | ||
|
|
dfd2d75021 | ||
|
|
0bc504232a | ||
|
|
6d5bb86e58 | ||
|
|
ff47df64b8 | ||
|
|
b1f86fdc3b | ||
|
|
a0a457cd35 | ||
|
|
0c5f03d50c | ||
|
|
4c124ccd4e | ||
|
|
321eb8c8e4 | ||
|
|
776dc46d49 | ||
|
|
dcfbd0349a | ||
|
|
ed5d4e572d | ||
|
|
22429269e2 | ||
|
|
eee0fcf3db | ||
|
|
9f6f39a094 | ||
|
|
0e0bbb2339 | ||
|
|
36ded309bc | ||
|
|
182b08fcbf | ||
|
|
17fef094df | ||
|
|
bcdbb5dae8 | ||
|
|
f1be5f4ee4 | ||
|
|
33eeedcdd7 | ||
|
|
5e41b8c3bc | ||
|
|
4652ec7399 | ||
|
|
7cccc5d048 | ||
|
|
4843a8e9ff | ||
|
|
a67aedda72 | ||
|
|
d5a7db3a91 | ||
|
|
45190fb2fd | ||
|
|
c8a8cda534 | ||
|
|
64e0a86b77 | ||
|
|
123e2df9fa | ||
|
|
61d9885cd5 | ||
|
|
733cb365ee | ||
|
|
aeba764008 | ||
|
|
d0350ee279 | ||
|
|
00b6800c2f | ||
|
|
ea0079eec8 | ||
|
|
b72d3a45b3 | ||
|
|
d71c6382d5 | ||
|
|
ef4570dd83 | ||
|
|
56273668d6 | ||
|
|
413c86b854 | ||
|
|
53d9ff537d | ||
|
|
024d1bf061 | ||
|
|
cb5d38eb86 | ||
|
|
9108848387 | ||
|
|
81fb5ff455 | ||
|
|
5d16d75162 | ||
|
|
da5b719e6d | ||
|
|
3baa8f3157 | ||
|
|
27610a0305 | ||
|
|
3ef6f4b04c | ||
|
|
0bea0f9635 | ||
|
|
8ee10eb149 | ||
|
|
1a36a1d22a | ||
|
|
4b11d665ff | ||
|
|
ab710068a6 | ||
|
|
9ceec5cc0b | ||
|
|
9161d99082 | ||
|
|
fa76f6f32c | ||
|
|
c37934cb69 | ||
|
|
53a52bc455 | ||
|
|
7f58e5409d | ||
|
|
ccad65dd89 | ||
|
|
e5b8c6f46b | ||
|
|
7ec727e994 | ||
|
|
52313cdaa8 | ||
|
|
da18a10782 | ||
|
|
0ae10079fb | ||
|
|
0e22b3d267 | ||
|
|
895cfbc4f0 | ||
|
|
85cf73c66b | ||
|
|
e8ddd67747 | ||
|
|
60396bad6d | ||
|
|
568098ee0b | ||
|
|
868fece089 | ||
|
|
e0cb0e7a07 | ||
|
|
49f9faa58c | ||
|
|
30245d6dec | ||
|
|
8df424c249 | ||
|
|
e732109ef2 | ||
|
|
0e64d6f262 | ||
|
|
57816f3353 | ||
|
|
0cb4e026c7 | ||
|
|
25a6e81181 | ||
|
|
352e54af58 | ||
|
|
f5b4e71927 | ||
|
|
37dae0ee6f | ||
|
|
045dd954fa | ||
|
|
ecde3a89eb | ||
|
|
7e5b693624 | ||
|
|
7bbbfb150c | ||
|
|
317f4118e1 | ||
|
|
a819c14f7d | ||
|
|
f4b98bd8e9 | ||
|
|
1eeb09bfa2 | ||
|
|
3e67053e9d | ||
|
|
3630dd5fc1 | ||
|
|
29d72d64d6 | ||
|
|
19e3f822e7 | ||
|
|
87969bddae | ||
|
|
1f6dc0d9fb | ||
|
|
c92d47953e | ||
|
|
e4221b84f0 | ||
|
|
593da2e6f8 | ||
|
|
d882e35820 | ||
|
|
89e0a6ba35 | ||
|
|
0c69245845 | ||
|
|
a3265ea7f7 | ||
|
|
155df35229 | ||
|
|
b477f767f3 | ||
|
|
883023b588 | ||
|
|
96322d2a2c | ||
|
|
ff72d4e88b | ||
|
|
4f5a1ad365 | ||
|
|
56f93e1eab | ||
|
|
57e2a69575 | ||
|
|
c7f037fdd7 | ||
|
|
ea87bfe337 | ||
|
|
df93ed2d3c | ||
|
|
de03c6149c | ||
|
|
92480328ac | ||
|
|
02404d5f22 | ||
|
|
bd65c9a666 | ||
|
|
ec443bbb91 | ||
|
|
0292918ef4 | ||
|
|
947d72ae96 | ||
|
|
fb195d9456 | ||
|
|
aa6ff005ea | ||
|
|
a404289e69 | ||
|
|
ccb5d3108a | ||
|
|
ed23fc33b4 | ||
|
|
c1dbba3545 | ||
|
|
ab7cf3e44a | ||
|
|
2afe82e86b | ||
|
|
cd4733efa9 | ||
|
|
123dcd9d87 | ||
|
|
fa2f34ef58 | ||
|
|
f099a39137 | ||
|
|
011e469c8a | ||
|
|
f085b5552f | ||
|
|
434f0f79a5 | ||
|
|
59206bb37f | ||
|
|
b7d7b2a382 | ||
|
|
d7564ddf36 | ||
|
|
e2f238a155 | ||
|
|
0fe4491394 | ||
|
|
c471e4b465 | ||
|
|
8436c5e39a | ||
|
|
d4d7cb9ed0 | ||
|
|
a72d39cac8 | ||
|
|
ccf5343e62 | ||
|
|
28a125cc5b | ||
|
|
abc791f516 | ||
|
|
e599097a22 | ||
|
|
71ee9e3311 | ||
|
|
d7936fd7d1 | ||
|
|
70fb4a6442 | ||
|
|
0e21fc2475 | ||
|
|
4d5f387738 | ||
|
|
78bab83bed | ||
|
|
9745a16694 | ||
|
|
158f1d94a6 | ||
|
|
bdb29afd54 | ||
|
|
57d179ed01 | ||
|
|
2c18313c13 | ||
|
|
61d80f6cc5 | ||
|
|
5ddc513d5d | ||
|
|
5e4549e413 | ||
|
|
dc36c83866 | ||
|
|
5eeef917e6 | ||
|
|
ea5535f374 | ||
|
|
696b4b063a | ||
|
|
8660069566 | ||
|
|
44943fdea7 | ||
|
|
70cacfbe71 | ||
|
|
6aa2fe7749 | ||
|
|
a01a3be0d1 | ||
|
|
f52528f806 | ||
|
|
bcce414686 | ||
|
|
579757f4d9 | ||
|
|
81841777b9 | ||
|
|
392e014872 | ||
|
|
5557c69ec4 | ||
|
|
614a8556d9 | ||
|
|
db110b74e7 | ||
|
|
533a7d68eb | ||
|
|
79f7343cb4 | ||
|
|
61c11e2520 | ||
|
|
b91bf2fa67 | ||
|
|
720e45c20e | ||
|
|
08230823d5 | ||
|
|
52614cee38 | ||
|
|
e648f237eb | ||
|
|
3cc9a2d72e | ||
|
|
332b6ce7b6 | ||
|
|
6aa3467f29 | ||
|
|
644f9b68eb | ||
|
|
5b6e76e51c | ||
|
|
4ffaeace88 | ||
|
|
8814788e9f | ||
|
|
c8355daac5 | ||
|
|
fec9e5486c | ||
|
|
e860576802 | ||
|
|
d20f43a756 | ||
|
|
de730bc4f0 | ||
|
|
ce6946ca9b | ||
|
|
e73efef313 | ||
|
|
0bdd4644e5 | ||
|
|
a2932315c3 | ||
|
|
af7a636751 | ||
|
|
a7c83c46cf | ||
|
|
64cb92e9e9 | ||
|
|
2972baa68b | ||
|
|
3a1b07e868 | ||
|
|
f34d0abc6b | ||
|
|
6ad4df7ea0 | ||
|
|
d44433ed59 | ||
|
|
e4a4b44719 | ||
|
|
a5c2af7a95 | ||
|
|
0543036ebd | ||
|
|
b2b6c19e74 | ||
|
|
c3ecfabfc6 | ||
|
|
a2c3063520 | ||
|
|
c2c28d0cea | ||
|
|
0940898f7b | ||
|
|
ea29e6bce0 | ||
|
|
bd54ff5c52 | ||
|
|
11330760dd | ||
|
|
7e82a361b5 | ||
|
|
8c55345f85 | ||
|
|
c29a46aeee | ||
|
|
946b5b3932 | ||
|
|
c80f64db82 | ||
|
|
b4d2e92cb6 | ||
|
|
2f91b5e726 | ||
|
|
aa0fc5a7ed | ||
|
|
b4e1f18cc5 | ||
|
|
8d43795c34 | ||
|
|
8e957a6c69 | ||
|
|
db1db9da8d | ||
|
|
301d3a0cd6 | ||
|
|
39093e4b1a | ||
|
|
a58467cad0 | ||
|
|
0a3dc9f316 | ||
|
|
47a15eb231 | ||
|
|
a6b66929e4 | ||
|
|
9b1a3ebc71 | ||
|
|
87ec25c82c | ||
|
|
8153cf8d74 | ||
|
|
766096cba4 | ||
|
|
dd00b7eb2e | ||
|
|
a60fa6797a | ||
|
|
0f31287335 | ||
|
|
5dcde335dd | ||
|
|
29f49ff674 | ||
|
|
9ddbbdfe17 | ||
|
|
b23f81f3ba | ||
|
|
5b5addb7fc | ||
|
|
1e9e7be709 | ||
|
|
bce138d52e | ||
|
|
7de0b7e20d | ||
|
|
376ddd4a12 | ||
|
|
b6399da95b | ||
|
|
295ee80a1a | ||
|
|
ac71c9e85f | ||
|
|
d0fc0ffc43 | ||
|
|
cee4575f63 | ||
|
|
4f1ad101bc | ||
|
|
9386ec4bc2 | ||
|
|
84af00e784 | ||
|
|
cc2d40a912 | ||
|
|
21b4c960a3 | ||
|
|
89df7ce409 | ||
|
|
97fd03d966 | ||
|
|
bdfb498fb6 | ||
|
|
b61bc3cd02 | ||
|
|
6223a63efe | ||
|
|
74df3bbd25 | ||
|
|
4afaeddbda | ||
|
|
c552774826 | ||
|
|
1335405ccc | ||
|
|
871a3c3907 | ||
|
|
8815e230ed | ||
|
|
0bf21c30c6 | ||
|
|
e6edca3137 | ||
|
|
7247a2d0d4 | ||
|
|
0f62b3f2be | ||
|
|
6f2a9d0fd4 | ||
|
|
2910b13325 | ||
|
|
4d89930dae | ||
|
|
c5568cc3a8 | ||
|
|
d145893c54 | ||
|
|
7efa7dc06b | ||
|
|
dcc3b5090f | ||
|
|
2771475f57 | ||
|
|
7993de3335 | ||
|
|
387b9fcfef | ||
|
|
456bca5cbb | ||
|
|
10337ed433 | ||
|
|
cab7f065f3 | ||
|
|
e877a0c949 | ||
|
|
20ce9c5f65 | ||
|
|
fc01428650 | ||
|
|
18008a9ec9 | ||
|
|
51180ef90d | ||
|
|
3df32e7860 | ||
|
|
bb51885313 | ||
|
|
89b623b415 | ||
|
|
061d5c0eef | ||
|
|
75869b899c | ||
|
|
ea19916cc4 | ||
|
|
d416df6f86 | ||
|
|
72c59bc2ad | ||
|
|
5f2b3a3f9b | ||
|
|
cb504ababe | ||
|
|
ab44d2383e | ||
|
|
30d72f1683 | ||
|
|
45b8a62027 | ||
|
|
c476a8ec75 | ||
|
|
4a3d6e0331 | ||
|
|
a947dae5f3 | ||
|
|
b219be48eb | ||
|
|
87fc510726 | ||
|
|
4929ebc503 | ||
|
|
88af9763a0 | ||
|
|
34343d4824 | ||
|
|
708a417086 | ||
|
|
e8ba4a8a14 | ||
|
|
b2523c14b6 | ||
|
|
2677dd57de | ||
|
|
df919ded0c | ||
|
|
343ed3993b | ||
|
|
41b934575e | ||
|
|
579fd3bf07 | ||
|
|
ee30bacc15 | ||
|
|
06bad4b9c4 | ||
|
|
04a08815e7 | ||
|
|
8397922ecd | ||
|
|
4de8c13136 | ||
|
|
b9b81709af | ||
|
|
b4c7eb1a3e | ||
|
|
6706e94bc2 | ||
|
|
44c870e1bb | ||
|
|
4f5c7623d2 | ||
|
|
5ca4ee678b | ||
|
|
ebb112f264 | ||
|
|
b30aca1b27 | ||
|
|
5d7af4f3c3 | ||
|
|
e5204b2fdc | ||
|
|
ed855b6921 | ||
|
|
052823c0fd | ||
|
|
e5f389aab6 | ||
|
|
6bf2135bbc | ||
|
|
dcc58ea25a | ||
|
|
8644eb21ab | ||
|
|
170a1f6ad8 | ||
|
|
362b54c642 | ||
|
|
d9e28aa3ca | ||
|
|
a942e21040 | ||
|
|
49dd5d8e31 | ||
|
|
86757e41a3 | ||
|
|
3f86658c46 | ||
|
|
7fa87aca9d | ||
|
|
5259cc9edb | ||
|
|
b39000ea58 | ||
|
|
001d494afd | ||
|
|
3befafcbc1 | ||
|
|
597d866204 | ||
|
|
568b6785d3 | ||
|
|
3a7975bd9b | ||
|
|
e54251dc24 | ||
|
|
ec2b9e76c4 | ||
|
|
d8b65da11f | ||
|
|
3f124c31f0 | ||
|
|
b376a0b16a | ||
|
|
42c0e1ecc8 | ||
|
|
cdce816fd2 | ||
|
|
a49951ad7e | ||
|
|
887cef9b37 | ||
|
|
3ccdcb4140 | ||
|
|
0a80afc550 | ||
|
|
c5c4a6dcbe | ||
|
|
6f5e41bb76 | ||
|
|
20937718f1 | ||
|
|
f7b13cf973 | ||
|
|
946b7a453c | ||
|
|
fcf102b9d2 | ||
|
|
6355eb4b9e | ||
|
|
315d7b44f9 | ||
|
|
6c342e930d | ||
|
|
624e67df4b | ||
|
|
8f2694b035 | ||
|
|
776baa7c95 | ||
|
|
baff3cf6c7 | ||
|
|
a5e007a3b6 | ||
|
|
23b88839a0 | ||
|
|
ddc1933862 | ||
|
|
50e836e3e7 | ||
|
|
e3f7ad9156 | ||
|
|
73d9e5a6f1 | ||
|
|
73124c3d37 | ||
|
|
be2a34fcb4 | ||
|
|
a3f8d33711 | ||
|
|
a500724e17 | ||
|
|
ab4b8f3373 | ||
|
|
bc0452e56d | ||
|
|
da92efc708 | ||
|
|
ba98d3e7aa | ||
|
|
019a02fa7f | ||
|
|
42d496107e | ||
|
|
549378ecbd | ||
|
|
c0bef6ce70 | ||
|
|
97853638bf | ||
|
|
a968641bd1 | ||
|
|
e7c8c56819 | ||
|
|
f4b1bf345c | ||
|
|
6d212ecea3 | ||
|
|
444a5a0c82 | ||
|
|
b2fce09a7f | ||
|
|
6fe9ad271e | ||
|
|
7677e51aeb | ||
|
|
9724913f14 | ||
|
|
99925c9360 | ||
|
|
621ca1c23a | ||
|
|
316e7d1d47 | ||
|
|
8ebe2c7f5a | ||
|
|
0b4be48bf3 | ||
|
|
f680ff2229 | ||
|
|
60034eab91 | ||
|
|
6d539c17a7 | ||
|
|
2c06bbeaf0 | ||
|
|
d36147601b | ||
|
|
cb3c2d4b0e | ||
|
|
e11950b9a1 | ||
|
|
901c2df5cf | ||
|
|
504621b64b | ||
|
|
916ac0eea7 | ||
|
|
d7859ebe06 | ||
|
|
c96e9c170a | ||
|
|
9cb726d649 | ||
|
|
c3bb2895dc | ||
|
|
f9f19d1e0c | ||
|
|
df03c86b1d | ||
|
|
72aba70aaf | ||
|
|
09e20e451a | ||
|
|
743a9fb0ac | ||
|
|
605d816076 | ||
|
|
7319e7d6aa | ||
|
|
e89954c0c0 | ||
|
|
dcc6644b6e | ||
|
|
26a5a54673 | ||
|
|
a5d00e28d6 | ||
|
|
d5ab22bcbf |
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2019 iopsys Software Solutions AB. All rights reserved.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*/
|
||||
#
|
||||
# Copyright (C) 2019 iopsys Software Solutions AB. All rights reserved.
|
||||
#
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# version 2 as published by the Free Software Foundation.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
@@ -19,9 +19,5 @@ config BBF_TR143
|
||||
config BBF_TR157
|
||||
bool "Compile with tr157 bulkdata collector features"
|
||||
default y
|
||||
|
||||
config BBF_TR064
|
||||
bool "Compile with tr064 features"
|
||||
default n
|
||||
|
||||
endif
|
||||
|
||||
63
bbf/Makefile
63
bbf/Makefile
@@ -1,41 +1,59 @@
|
||||
#
|
||||
# Copyright (C) 2019 Iopsys
|
||||
# Copyright (C) 2019 IOPSYS
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=libbbfdm
|
||||
PKG_VERSION:=1.0-2019-10-01
|
||||
PKG_VERSION:=3.2.5
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/bbf.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=b3bae9df19df35075ac52f53758288d8e0573790
|
||||
PKG_SOURCE_VERSION:=301cbd0bed43ed9274bad3e8bcddcfd807755412
|
||||
PKG_RELEASE=$(PKG_SOURCE_VERSION)
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_LICENSE:=GPLv2
|
||||
PKG_LICENSE:=LGPL-2.1
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/libbbf_api
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=Library for libbbfdm API
|
||||
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c
|
||||
endef
|
||||
|
||||
define Package/libbbfdm
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=Library for broadband-forum data model
|
||||
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libtrace
|
||||
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libtrace +libbbf_api +libopenssl +libmbedtls
|
||||
endef
|
||||
|
||||
define Package/libbbfdm/config
|
||||
source "$(SOURCE)/Config_bbfdm.in"
|
||||
endef
|
||||
|
||||
define Package/libbbfdm/description
|
||||
Test description will update later.
|
||||
define Package/libbbf_api/description
|
||||
Library contains the API(UCI, UBUS, JSON, CLI and Browse) of libbbfdm
|
||||
endef
|
||||
|
||||
define Package/libbbfdm/description
|
||||
Library contains the data model tree. It includes TR181, TR104, TR143 and TR157 data models
|
||||
endef
|
||||
|
||||
USE_LOCAL=$(shell ls ./src/ 2>/dev/null >/dev/null && echo 1)
|
||||
ifneq ($(USE_LOCAL),)
|
||||
define Build/Prepare
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
TARGET_CFLAGS += -DCUSTOM_PREFIX=\\\"$(CONFIG_LIBBBFDM_VENDOR_PREFIX)\\\"
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
@@ -61,27 +79,46 @@ CONFIGURE_ARGS += \
|
||||
--enable-tr157
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BBF_TR064),y)
|
||||
ifeq ($(CONFIG_PACKAGE_libopenssl),y)
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-tr064
|
||||
--enable-libopenssl
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_PACKAGE_libmbedtls),y)
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-libmbedtls
|
||||
endif
|
||||
|
||||
define Package/libbbf_api/install
|
||||
$(INSTALL_DIR) $(1)/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/bin/.libs/libbbf_api.so* $(1)/lib/
|
||||
endef
|
||||
|
||||
define Package/libbbfdm/install
|
||||
$(INSTALL_DIR) $(1)/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/bin/.libs/libbbfdm.so* $(1)/lib/
|
||||
$(INSTALL_DIR) $(1)/etc/bbfdm
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/config/dmmap $(1)/etc/bbfdm
|
||||
$(INSTALL_DIR) $(1)/usr/share/bbfdm
|
||||
$(CP) $(PKG_BUILD_DIR)/scripts/functions $(1)/usr/share/bbfdm
|
||||
$(INSTALL_DIR) $(1)/etc/bbfdm
|
||||
$(INSTALL_DIR) $(1)/etc/bbfdm/json
|
||||
$(INSTALL_DIR) $(1)/usr/lib/bbfdm
|
||||
endef
|
||||
|
||||
define Package/libbbfdm/prerm
|
||||
#!/bin/sh
|
||||
rm -rf /etc/bbfdm/*
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/include/libbbfdm
|
||||
$(INSTALL_DIR) $(1)/usr/include/libbbf_api
|
||||
$(CP) $(PKG_BUILD_DIR)/*.h $(1)/usr/include/libbbfdm/
|
||||
$(CP) $(PKG_BUILD_DIR)/dmtree/tr181/*.h $(1)/usr/include/libbbfdm/
|
||||
$(CP) $(PKG_BUILD_DIR)/libbbf_api/*.h $(1)/usr/include/libbbf_api/
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/bin/.libs/libbbfdm.{a,so*} $(1)/usr/lib/
|
||||
$(CP) $(PKG_BUILD_DIR)/bin/.libs/libbbf_api.{a,so*} $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libbbf_api))
|
||||
$(eval $(call BuildPackage,libbbfdm))
|
||||
|
||||
44
bulkdata/Makefile
Executable file
44
bulkdata/Makefile
Executable file
@@ -0,0 +1,44 @@
|
||||
#
|
||||
# Copyright (C) 2020 iopsys Software Solutions AB
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=bulkdata
|
||||
PKG_VERSION:=1.0.0
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=TRx69
|
||||
TITLE:=BBF BulkData Collection
|
||||
DEPENDS:=+libubus +libuci +libubox +libjson-c +libcurl +curl +libblobmsg-json +libbbfdm +libbbf_api
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
BBF BulkData Collection
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-D_GNU_SOURCE
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bulkdatad $(1)/usr/sbin/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/bbfdm
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/*.so $(1)/usr/lib/bbfdm
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
43
bulkdata/files/etc/config/bulkdata
Normal file
43
bulkdata/files/etc/config/bulkdata
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
config bulkdata 'bulkdata'
|
||||
option enable '0'
|
||||
#Log levels: Critical=0, Warning=1, Notice=2, Info=3, Debug=4
|
||||
option log_level '3'
|
||||
|
||||
config profile
|
||||
option profile_id '1'
|
||||
option enable '0'
|
||||
option name ''
|
||||
option nbre_of_retained_failed_reports '0'
|
||||
option protocol 'http'
|
||||
option encoding_type ''
|
||||
option reporting_interval '86400'
|
||||
option time_reference '0'
|
||||
option csv_encoding_field_separator ','
|
||||
option csv_encoding_row_separator ' '
|
||||
option csv_encoding_escape_character '"'
|
||||
option csv_encoding_report_format 'column'
|
||||
option csv_encoding_row_time_stamp 'unix'
|
||||
option json_encoding_report_format 'objecthierarchy'
|
||||
option json_encoding_report_time_stamp 'unix'
|
||||
option http_url ''
|
||||
option http_username ''
|
||||
option http_password ''
|
||||
option http_compression 'none'
|
||||
option http_method 'post'
|
||||
option http_use_date_header '1'
|
||||
option http_retry_enable '0'
|
||||
option http_retry_minimum_wait_interval '5'
|
||||
option http_retry_interval_multiplier '2000'
|
||||
option http_persist_across_reboot '0'
|
||||
|
||||
config profile_parameter
|
||||
option profile_id '1'
|
||||
option name ''
|
||||
option reference ''
|
||||
|
||||
config profile_http_request_uri_parameter
|
||||
option profile_id '1'
|
||||
option name ''
|
||||
option reference ''
|
||||
|
||||
34
bulkdata/files/etc/init.d/bulkdatad
Executable file
34
bulkdata/files/etc/init.d/bulkdatad
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Bulkdata Software
|
||||
# Copyright (C) 2020 iopsys Software Solutions AB
|
||||
# Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
START=99
|
||||
STOP=10
|
||||
|
||||
USE_PROCD=1
|
||||
PROG="/usr/sbin/bulkdatad"
|
||||
|
||||
start_service() {
|
||||
local bulkdata_enable=`uci -q get bulkdata.bulkdata.enable`
|
||||
if [ "$bulkdata_enable" = "1" ]; then
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG"
|
||||
procd_set_param respawn "3" "7" "0"
|
||||
procd_close_instance
|
||||
fi
|
||||
}
|
||||
|
||||
boot() {
|
||||
start
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers()
|
||||
{
|
||||
procd_add_reload_trigger bulkdata
|
||||
}
|
||||
23
bulkdata/src/Makefile
Normal file
23
bulkdata/src/Makefile
Normal file
@@ -0,0 +1,23 @@
|
||||
PROG = bulkdatad
|
||||
LIB = libbulkdata.so
|
||||
|
||||
PROG_OBJS = bulkdata.o common.o config.o http.o log.o report.o times.o buci.o
|
||||
LIB_OBJS = datamodel.o
|
||||
|
||||
PROG_CFLAGS = $(CFLAGS) -Wall -Werror -fPIC
|
||||
PROG_LDFLAGS = $(LDFLAGS) -lubus -luci -lubox -ljson-c -lcurl -lblobmsg_json -lbbfdm
|
||||
LIB_LDFLAGS = $(LDFLAGS) -lbbf_api
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(PROG_CFLAGS) $(FPIC) -c -o $@ $<
|
||||
|
||||
all: $(PROG) $(LIB)
|
||||
|
||||
$(PROG): $(PROG_OBJS)
|
||||
$(CC) $(PROG_CFLAGS) -o $@ $^ $(PROG_LDFLAGS)
|
||||
|
||||
$(LIB): $(LIB_OBJS)
|
||||
$(CC) $(PROG_CFLAGS) $(LIB_LDFLAGS) -shared -o $@ $^
|
||||
|
||||
clean:
|
||||
rm -f *.o $(PROG) $(LIB)
|
||||
265
bulkdata/src/buci.c
Normal file
265
bulkdata/src/buci.c
Normal file
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <strings.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "buci.h"
|
||||
|
||||
struct uci_context *uci_ctx = NULL;
|
||||
|
||||
int buci_init(void)
|
||||
{
|
||||
uci_ctx = uci_alloc_context();
|
||||
if (!uci_ctx) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int buci_fini(void)
|
||||
{
|
||||
if (uci_ctx) {
|
||||
uci_free_context(uci_ctx);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool buci_validate_section(const char *str)
|
||||
{
|
||||
if (!*str)
|
||||
return false;
|
||||
|
||||
for (; *str; str++) {
|
||||
unsigned char c = *str;
|
||||
|
||||
if (isalnum(c) || c == '_')
|
||||
continue;
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static int buci_init_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *package, char *section, char *option, char *value)
|
||||
{
|
||||
memset(ptr, 0, sizeof(struct uci_ptr));
|
||||
|
||||
/* value */
|
||||
if (value) {
|
||||
ptr->value = value;
|
||||
}
|
||||
ptr->package = package;
|
||||
if (!ptr->package)
|
||||
goto error;
|
||||
|
||||
ptr->section = section;
|
||||
if (!ptr->section) {
|
||||
ptr->target = UCI_TYPE_PACKAGE;
|
||||
goto lastval;
|
||||
}
|
||||
|
||||
ptr->option = option;
|
||||
if (!ptr->option) {
|
||||
ptr->target = UCI_TYPE_SECTION;
|
||||
goto lastval;
|
||||
} else {
|
||||
ptr->target = UCI_TYPE_OPTION;
|
||||
}
|
||||
|
||||
lastval:
|
||||
if (ptr->section && !buci_validate_section(ptr->section))
|
||||
ptr->flags |= UCI_LOOKUP_EXTENDED;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct uci_section *buci_walk_section(char *package, char *section_type, struct uci_section *prev_section)
|
||||
{
|
||||
struct uci_ptr ptr;
|
||||
struct uci_element *e;
|
||||
struct uci_section *next_section;
|
||||
|
||||
if (section_type == NULL) {
|
||||
if (prev_section) {
|
||||
e = &prev_section->e;
|
||||
if (e->list.next == &prev_section->package->sections)
|
||||
return NULL;
|
||||
e = container_of(e->list.next, struct uci_element, list);
|
||||
next_section = uci_to_section(e);
|
||||
return next_section;
|
||||
}
|
||||
else {
|
||||
if (buci_init_ptr(uci_ctx, &ptr, package, NULL, NULL, NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
if (uci_lookup_ptr(uci_ctx, &ptr, NULL, true) != UCI_OK) {
|
||||
return NULL;
|
||||
}
|
||||
if (ptr.p->sections.next == &ptr.p->sections)
|
||||
return NULL;
|
||||
e = container_of(ptr.p->sections.next, struct uci_element, list);
|
||||
next_section = uci_to_section(e);
|
||||
|
||||
return next_section;
|
||||
}
|
||||
}
|
||||
else {
|
||||
struct uci_list *ul, *shead = NULL;
|
||||
|
||||
if (prev_section) {
|
||||
ul = &prev_section->e.list;
|
||||
shead = &prev_section->package->sections;
|
||||
}
|
||||
else {
|
||||
if (buci_init_ptr(uci_ctx, &ptr, package, NULL, NULL, NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
if (uci_lookup_ptr(uci_ctx, &ptr, NULL, true) != UCI_OK) {
|
||||
return NULL;
|
||||
}
|
||||
ul = &ptr.p->sections;
|
||||
shead = &ptr.p->sections;
|
||||
}
|
||||
while (ul->next != shead) {
|
||||
e = container_of(ul->next, struct uci_element, list);
|
||||
next_section = uci_to_section(e);
|
||||
if (strcmp(next_section->type, section_type) == 0)
|
||||
return next_section;
|
||||
ul = ul->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void buci_print_list(struct uci_list *uh, char **val, char *delimiter)
|
||||
{
|
||||
struct uci_element *e;
|
||||
static char buffer[512];
|
||||
char *buf = buffer;
|
||||
*buf = '\0';
|
||||
|
||||
uci_foreach_element(uh, e) {
|
||||
if (*buf) {
|
||||
strcat(buf, delimiter);
|
||||
strcat(buf, e->name);
|
||||
}
|
||||
else {
|
||||
strcpy(buf, e->name);
|
||||
}
|
||||
}
|
||||
*val = buf;
|
||||
}
|
||||
|
||||
struct uci_element *buci_lookup_list(struct uci_list *list, const char *name)
|
||||
{
|
||||
struct uci_element *e;
|
||||
|
||||
uci_foreach_element(list, e) {
|
||||
if (!strcmp(e->name, name))
|
||||
return e;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int uci_lookup_ptr_bysection(struct uci_context *ctx, struct uci_ptr *ptr, struct uci_section *section, char *option, char *value)
|
||||
{
|
||||
struct uci_element *e;
|
||||
memset(ptr, 0, sizeof(struct uci_ptr));
|
||||
|
||||
ptr->package = section->package->e.name;
|
||||
ptr->section = section->e.name;
|
||||
ptr->option = option;
|
||||
ptr->value = value;
|
||||
ptr->flags |= UCI_LOOKUP_DONE;
|
||||
|
||||
ptr->p = section->package;
|
||||
ptr->s = section;
|
||||
|
||||
if (ptr->option) {
|
||||
e = buci_lookup_list(&ptr->s->options, ptr->option);
|
||||
if (!e)
|
||||
return UCI_OK;
|
||||
ptr->o = uci_to_option(e);
|
||||
ptr->last = e;
|
||||
ptr->target = UCI_TYPE_OPTION;
|
||||
}
|
||||
else {
|
||||
ptr->last = &ptr->s->e;
|
||||
ptr->target = UCI_TYPE_SECTION;
|
||||
}
|
||||
|
||||
ptr->flags |= UCI_LOOKUP_COMPLETE;
|
||||
|
||||
return UCI_OK;
|
||||
}
|
||||
|
||||
char *buci_get_value_bysection(struct uci_section *section, char *option)
|
||||
{
|
||||
struct uci_ptr ptr;
|
||||
char *val = "";
|
||||
|
||||
if (uci_lookup_ptr_bysection(uci_ctx, &ptr, section, option, NULL) != UCI_OK) {
|
||||
return val;
|
||||
}
|
||||
|
||||
if (!ptr.o)
|
||||
return val;
|
||||
|
||||
if(ptr.o->type == UCI_TYPE_LIST) {
|
||||
buci_print_list(&ptr.o->v.list, &val, " ");
|
||||
return val;
|
||||
}
|
||||
|
||||
if (ptr.o->v.string)
|
||||
return ptr.o->v.string;
|
||||
else
|
||||
return val;
|
||||
}
|
||||
|
||||
char *buci_get_value(char *package, char *section, char *option)
|
||||
{
|
||||
struct uci_ptr ptr;
|
||||
char *val = "";
|
||||
|
||||
if (!section || !option)
|
||||
return val;
|
||||
|
||||
if (buci_init_ptr(uci_ctx, &ptr, package, section, option, NULL)) {
|
||||
return val;
|
||||
}
|
||||
if (uci_lookup_ptr(uci_ctx, &ptr, NULL, true) != UCI_OK) {
|
||||
return val;
|
||||
}
|
||||
|
||||
if (!ptr.o)
|
||||
return val;
|
||||
|
||||
if(ptr.o->type == UCI_TYPE_LIST) {
|
||||
buci_print_list(&ptr.o->v.list, &val, " ");
|
||||
return val;
|
||||
}
|
||||
|
||||
if (ptr.o->v.string)
|
||||
return ptr.o->v.string;
|
||||
else
|
||||
return val;
|
||||
}
|
||||
31
bulkdata/src/buci.h
Normal file
31
bulkdata/src/buci.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __BUCI_H
|
||||
#define __BUCI_H
|
||||
|
||||
#include <uci.h>
|
||||
|
||||
int buci_init(void);
|
||||
int buci_fini(void);
|
||||
struct uci_section *buci_walk_section(char *package, char *section_type, struct uci_section *prev_section);
|
||||
void buci_print_list(struct uci_list *uh, char **val, char *delimiter);
|
||||
struct uci_element *buci_lookup_list(struct uci_list *list, const char *name);
|
||||
int uci_lookup_ptr_bysection(struct uci_context *ctx, struct uci_ptr *ptr, struct uci_section *section, char *option, char *value);
|
||||
char *buci_get_value_bysection(struct uci_section *section, char *option);
|
||||
char *buci_get_value(char *package, char *section, char *option);
|
||||
|
||||
#define buci_foreach_section(package, section_type, section) \
|
||||
for (section = buci_walk_section(package, section_type, NULL); \
|
||||
section != NULL; \
|
||||
section = buci_walk_section(package, section_type, section))
|
||||
|
||||
#endif //__BUCI_H
|
||||
144
bulkdata/src/bulkdata.c
Normal file
144
bulkdata/src/bulkdata.c
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
* Omar Kallel <omar.kallel@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libubox/uloop.h>
|
||||
|
||||
#include "http.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "common.h"
|
||||
#include "report.h"
|
||||
#include "times.h"
|
||||
#include "bulkdata.h"
|
||||
|
||||
struct bulkdata bulkdata_main = {0};
|
||||
int profiles_number = 0;
|
||||
|
||||
void bulkdata_profile_cb(struct uloop_timeout *timeout);
|
||||
|
||||
int get_retry_period(int min)
|
||||
{
|
||||
srand(time(NULL));
|
||||
return rand()%min + min;
|
||||
}
|
||||
|
||||
static void bulkdata_run_profiles(struct bulkdata *bulkdata)
|
||||
{
|
||||
unsigned int next_period;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < profiles_number; i++) {
|
||||
bulkdata->profile[i].utimer.cb = bulkdata_profile_cb;
|
||||
LIST_HEAD(failedreports);
|
||||
bulkdata->profile[i].failed_reports = &failedreports;
|
||||
next_period = get_next_period(bulkdata->profile[i].time_reference, bulkdata->profile[i].reporting_interval);
|
||||
bulkdata_log(SINFO, "The session of profile_id %d will be start in %d sec", bulkdata->profile[i].profile_id, next_period);
|
||||
uloop_timeout_set(&bulkdata->profile[i].utimer, next_period * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
int http_send_report(struct profile *profile, char *report)
|
||||
{
|
||||
char *msg_in = NULL;
|
||||
int http_code;
|
||||
|
||||
http_client_init(profile);
|
||||
bulkdata_log(SINFO, "Send the report of profile_id %d to Bulkdata Collector", profile->profile_id);
|
||||
http_code = http_send_message(profile, report, strlen(report), &msg_in);
|
||||
http_client_exit();
|
||||
return http_code;
|
||||
}
|
||||
|
||||
void bulkdata_profile_cb(struct uloop_timeout *timeout)
|
||||
{
|
||||
struct profile *profile;
|
||||
unsigned int http_code, retry_period;
|
||||
char *report = NULL;
|
||||
|
||||
profile = container_of(timeout, struct profile, utimer);
|
||||
time_t now = time(NULL);
|
||||
|
||||
bulkdata_log(SINFO, "New session of profile_id %d started", profile->profile_id);
|
||||
if(profile->retry_count == 0 || profile->next_retry > now || !profile->http_retry_enable) //Perdiodic execution
|
||||
create_encoding_bulkdata_report(profile, &report);
|
||||
else
|
||||
create_failed_report(profile, &report);
|
||||
|
||||
bulkdata_log(SDEBUG, "The content of the profile_id report %d is :\n==========\n%s\n==========\n", profile->profile_id, report);
|
||||
http_code= http_send_report(profile, report);
|
||||
if(http_code != 200){
|
||||
if(profile->retry_count == 0 || profile->next_retry > now || !profile->http_retry_enable) { //Perdiodic execution
|
||||
retry_period = get_retry_period(profile->http_retry_minimum_wait_interval);
|
||||
profile->next_period = now + profile->reporting_interval;
|
||||
profile->next_retry = now + retry_period;
|
||||
profile->retry_count = 1;
|
||||
profile->min_retry = profile->http_retry_minimum_wait_interval * 2;
|
||||
if((profile->next_retry < profile->next_period) && profile->http_retry_enable) {
|
||||
bulkdata_log(SINFO, "Retry session of profile_id %d in %d sec", profile->profile_id, retry_period);
|
||||
uloop_timeout_set(timeout, 1000 * retry_period);
|
||||
}
|
||||
else {
|
||||
bulkdata_log(SINFO, "Start New session of profile_id %d in %d sec", profile->profile_id, profile->reporting_interval);
|
||||
uloop_timeout_set(timeout, 1000 * profile->reporting_interval);
|
||||
}
|
||||
} else { //Retry execution
|
||||
retry_period= get_retry_period(profile->min_retry);
|
||||
profile->min_retry*=2;
|
||||
profile->next_retry+=retry_period;
|
||||
profile->retry_count++;
|
||||
if(profile->next_retry < profile->next_period) {
|
||||
bulkdata_log(SINFO, "Retry session of profile_id %d in %d sec", profile->profile_id, retry_period);
|
||||
uloop_timeout_set(timeout, 1000 * retry_period);
|
||||
}
|
||||
else {
|
||||
bulkdata_log(SINFO, "Retry session of profile_id %d in %d sec", profile->profile_id, (profile->next_period-profile->next_retry+retry_period));
|
||||
uloop_timeout_set(timeout, 1000 * (profile->next_period-profile->next_retry+retry_period));
|
||||
}
|
||||
}
|
||||
if(profile->new_report){
|
||||
bulkdata_add_failed_report(profile, profile->new_report);
|
||||
FREE(profile->new_report);
|
||||
}
|
||||
FREE(report);
|
||||
} else {
|
||||
if(profile->retry_count == 0 || profile->next_retry > now || !profile->http_retry_enable) {
|
||||
bulkdata_log(SINFO, "Start New session of profile_id %d in %d sec", profile->profile_id, profile->reporting_interval);
|
||||
uloop_timeout_set(timeout, 1000 * profile->reporting_interval);
|
||||
}
|
||||
else {
|
||||
bulkdata_log(SINFO, "Retry session of profile_id %d in %d sec", profile->profile_id, (profile->next_period-profile->next_retry));
|
||||
uloop_timeout_set(timeout, 1000 * (profile->next_period-profile->next_retry));
|
||||
}
|
||||
FREE(profile->new_report);
|
||||
FREE(report);
|
||||
empty_failed_reports_list(profile);
|
||||
profile->retry_count= 0;
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct bulkdata *bulkdata = &bulkdata_main;
|
||||
if (bulkdata_config_init(bulkdata) == -1)
|
||||
return -1;
|
||||
bulkdata_log(SINFO, "Start bulkdatad daemon");
|
||||
|
||||
uloop_init();
|
||||
bulkdata_run_profiles(bulkdata);
|
||||
uloop_run();
|
||||
uloop_done();
|
||||
|
||||
bulkdata_config_fini(bulkdata);
|
||||
bulkdata_log(SINFO, "Stop bulkdatad daemon");
|
||||
return 0;
|
||||
}
|
||||
18
bulkdata/src/bulkdata.h
Normal file
18
bulkdata/src/bulkdata.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __BULKDATA_H
|
||||
#define __BULKDATA_H
|
||||
|
||||
extern struct bulkdata bulkdata_main;
|
||||
extern int profiles_number;
|
||||
|
||||
#endif /* __BULKDATA_H */
|
||||
105
bulkdata/src/bulkdata.md
Normal file
105
bulkdata/src/bulkdata.md
Normal file
@@ -0,0 +1,105 @@
|
||||
# README #
|
||||
|
||||
bulkdatad is an implementation of The HTTP bulk data collection mechanism which is an extended feature of CPE and other agents implementing TR-069(CWMP) or TR-369(USP), defined by the Broadband Forum. It provides a means by which an Auto-Configuration Server (ACS), or USP Controller, can configure an agent to periodically send a JSON or CSV formatted set of Device information to an HTTP server running a data collection application.
|
||||
|
||||
## Configuration File ##
|
||||
|
||||
The bulkdatad UCI configuration is located in **'/etc/config/bulkdata'**, and contains 4 sections: **bulkdata**, **profile**, **profile\_parameter** and **profile\_http\_request\_uri\_parameter**.
|
||||
|
||||
```
|
||||
config bulkdata 'bulkdata'
|
||||
option enable '0'
|
||||
option log_level '3'
|
||||
|
||||
config profile
|
||||
option profile_id '1'
|
||||
option enable '0'
|
||||
option csv_encoding_row_time_stamp 'unix'
|
||||
option json_encoding_report_time_stamp 'unix'
|
||||
option http_retry_minimum_wait_interval '5'
|
||||
option http_retry_interval_multiplier '2000'
|
||||
|
||||
config profile_parameter
|
||||
option profile_id '1'
|
||||
option name ''
|
||||
option reference ''
|
||||
|
||||
config profile_http_request_uri_parameter
|
||||
option profile_id '1'
|
||||
option name ''
|
||||
option reference ''
|
||||
```
|
||||
|
||||
### bulkdata section ###
|
||||
|
||||
It defines **bulkdata configuration**: enable and log\_level.
|
||||
|
||||
| Name | Type | Description |
|
||||
| ----------- | ------- | ----------------------------------------------------------------------------------------------- |
|
||||
| `enable` | boolean | Enables the BulkData feature if set to **1**. |
|
||||
| `log_level` | integer | Specifies the log type to use, by default **'INFO'**. The possible types are **'EMERG', 'ALERT', 'CRITIC' ,'ERROR', 'WARNING', 'NOTICE', 'INFO' and 'DEBUG'**. |
|
||||
|
||||
### profile section ###
|
||||
|
||||
It defines **the profile section configuration**: enable, name,... The possible options for **profile** section are listed below:
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---------------------------------- | ------- | ---------------------------------------------- |
|
||||
| `profile_id` | integer | The profile id to use. |
|
||||
| `enable` | boolean | If set to **1**, enables the bulkdata profile. |
|
||||
| `name` | string | The name of the profile. |
|
||||
| `nbre_of_retained_failed_reports` | integer | The number of failed reports to be retained and transmitted at the end of the current reporting interval. |
|
||||
| `protocol` | string | The protocol used for the collection profile. |
|
||||
| `encoding_type` | string | The encoding type used for the collection profile. |
|
||||
| `reporting_interval` | integer | The reporting interval in seconds. |
|
||||
| `time_reference` | integer | The time reference to determine when the profile will be transmitted to the ACS collector. |
|
||||
| `csv_encoding_field_separator` | string | The field separator to use when encoding CSV data. |
|
||||
| `csv_encoding_row_separator` | string | The row separator to use when encoding CSV data. |
|
||||
| `csv_encoding_escape_character` | string | The escape character to use when encoding CSV data. |
|
||||
| `csv_encoding_report_format` | string | Describes how reports will be formatted. Two possible formats are supported: **'ParameterPerRow' and 'ParameterPerColumn'**. |
|
||||
| `csv_encoding_row_time_stamp` | string | The format of the timestamp to use for data inserted into the row. The row time stamp supported are **'Unix-Epoch', 'ISO-8601' and 'None'**. |
|
||||
| `json_encoding_report_format` | string | Describes the report format. The supported report formats are **'ObjectHierarchy' and 'NameValuePair'**. |
|
||||
| `json_encoding_report_time_stamp` | string | The format of the timestamp to use for the JSON Object named "CollectionTime". The supported timestamp are **'Unix-Epoch', 'ISO-8601' and 'None'**. |
|
||||
| `http_url` | string | The URL of the collection server. |
|
||||
| `http_username` | string | The username of the collection server. |
|
||||
| `http_password` | string | The password of the collection server. |
|
||||
| `http_compression` | string | The HTTP Compression mechanism used by the collection server. The supported compression mechanism are **'GZIP', 'Compress' and 'Deflate'**. |
|
||||
| `http_method` | string | The HTTP method used by the collection server. Two methods are supported: **'POST' and 'PUT'**. |
|
||||
| `http_use_date_header` | boolean | If set to **1**, the CPE encodes the HTTP Date Header. |
|
||||
| `http_retry_enable` | boolean | If set to **1**, the CPE retries unsuccessful attempts to transfer data. |
|
||||
| `http_retry_minimum_wait_interval` | integer | The data transfer retry wait interval. |
|
||||
| `http_retry_interval_multiplier` | integer | The retry interval multiplier. |
|
||||
| `http_persist_across_reboot` | boolean | If set to **1**, failed data transfers must be persisted across reboots. |
|
||||
|
||||
### profile_parameter section ###
|
||||
|
||||
It defines **the profile\_parameter section configuration**: profile\_id, name, reference.
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------ | ------- | --------------------------------------- |
|
||||
| `profile_id` | integer | The id of the used profile. |
|
||||
| `name` | string | The name of the profile parameter. |
|
||||
| `reference` | string | The reference of the profile parameter. |
|
||||
|
||||
### profile_http_request_uri_parameter section ###
|
||||
|
||||
It defines **the profile\_http\_request\_uri\_parameter section configuration**: profile\_id, name, reference.
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------ | ------- | --------------------------------------- |
|
||||
| `profile_id` | integer | The id of the used profile. |
|
||||
| `name` | string | The name of the Request-URI parameter. |
|
||||
| `reference` | string | The reference of the profile parameter. |
|
||||
|
||||
## Dependencies ##
|
||||
|
||||
To successfully build bulkdatad, the following libraries are needed:
|
||||
|
||||
| Dependency | Link | License |
|
||||
| ----------- | ------------------------------------------- | -------------- |
|
||||
| libuci | https://git.openwrt.org/project/uci.git | LGPL 2.1 |
|
||||
| libubox | https://git.openwrt.org/project/libubox.git | BSD |
|
||||
| libjson-c | https://s3.amazonaws.com/json-c_releases | MIT |
|
||||
| libcurl | https://dl.uxnr.de/mirror/curl | MIT |
|
||||
| libbbfdm | https://dev.iopsys.eu/iopsys/bbf.git | LGPL 2.1 |
|
||||
|
||||
450
bulkdata/src/common.c
Normal file
450
bulkdata/src/common.c
Normal file
@@ -0,0 +1,450 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
* Omar Kallel <omar.kallel@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
|
||||
static pathnode *head = NULL;
|
||||
static pathnode *temphead = NULL;
|
||||
|
||||
int bulkdata_dm_ctx_init(struct dmctx *ctx)
|
||||
{
|
||||
struct bulkdata *bulkdata = &bulkdata_main;
|
||||
dm_ctx_init(ctx, bulkdata->instance_mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bulkdata_dm_ctx_clean(struct dmctx *ctx)
|
||||
{
|
||||
dm_ctx_clean(ctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char **str_split(const char* str, const char* delim, size_t* numtokens)
|
||||
{
|
||||
char *s = strdup(str);
|
||||
size_t tokens_alloc = 1;
|
||||
size_t tokens_used = 0;
|
||||
char **tokens = calloc(tokens_alloc, sizeof(char*));
|
||||
char *token, *strtok_ctx;
|
||||
for (token = strtok_r(s, delim, &strtok_ctx); token != NULL; token = strtok_r(NULL, delim, &strtok_ctx)) {
|
||||
if (tokens_used == tokens_alloc) {
|
||||
tokens_alloc *= 2;
|
||||
tokens = realloc(tokens, tokens_alloc * sizeof(char*));
|
||||
}
|
||||
tokens[tokens_used++] = strdup(token);
|
||||
}
|
||||
// cleanup
|
||||
if (tokens_used == 0) {
|
||||
FREE(tokens);
|
||||
} else {
|
||||
tokens = realloc(tokens, tokens_used * sizeof(char*));
|
||||
}
|
||||
*numtokens = tokens_used;
|
||||
FREE(s);
|
||||
return tokens;
|
||||
}
|
||||
|
||||
static bool bulkdata_match(const char *string, const char *pattern)
|
||||
{
|
||||
regex_t re;
|
||||
if (regcomp(&re, pattern, REG_EXTENDED) != 0) return 0;
|
||||
int status = regexec(&re, string, 0, NULL, 0);
|
||||
regfree(&re);
|
||||
if (status != 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool is_res_required(char *str, int *start, int *len)
|
||||
{
|
||||
char temp_char[NAME_MAX] = {'\0'};
|
||||
|
||||
if (bulkdata_match(str, GLOB_CHAR)) {
|
||||
int s_len = strlen(str);
|
||||
int b_len = s_len, p_len = s_len;
|
||||
|
||||
char *star = strchr(str, '*');
|
||||
if(star)
|
||||
s_len = star - str;
|
||||
*start = MIN(MIN(s_len, p_len), b_len);
|
||||
if (*start == s_len)
|
||||
*len = 1;
|
||||
|
||||
strncpy(temp_char, str+*start, *len);
|
||||
|
||||
if (bulkdata_match(temp_char, "[*+]+"))
|
||||
return true;
|
||||
}
|
||||
*start = strlen(str);
|
||||
return false;
|
||||
}
|
||||
|
||||
static void insert(char *data, bool active)
|
||||
{
|
||||
pathnode *link = (pathnode*) calloc(1, sizeof(pathnode));
|
||||
if(!link) {
|
||||
return;
|
||||
}
|
||||
|
||||
link->ref_path = data;
|
||||
|
||||
if(active) {
|
||||
link->next = head;
|
||||
head = link;
|
||||
} else {
|
||||
link->next = temphead;
|
||||
temphead = link;
|
||||
}
|
||||
}
|
||||
|
||||
static void swap_heads(void)
|
||||
{
|
||||
pathnode *temp = head;
|
||||
head = temphead;
|
||||
temphead = temp;
|
||||
}
|
||||
|
||||
static void deleteList(void)
|
||||
{
|
||||
pathnode *ptr = head, *temp;
|
||||
while(ptr != NULL) {
|
||||
temp = ptr;
|
||||
free(ptr->ref_path);
|
||||
if(ptr->next != NULL) {
|
||||
ptr = ptr->next;
|
||||
} else {
|
||||
ptr = NULL;
|
||||
}
|
||||
free(temp);
|
||||
}
|
||||
head = NULL;
|
||||
swap_heads();
|
||||
}
|
||||
|
||||
void bulkdata_add_data_to_list(struct list_head *dup_list, char *name, char *value, char *type)
|
||||
{
|
||||
struct resultsnode *link;
|
||||
link = calloc(1, sizeof(struct resultsnode));
|
||||
list_add_tail(&link->list, dup_list);
|
||||
link->name = strdup(name);
|
||||
link->data = strdup(value);
|
||||
link->type = strdup(type);
|
||||
}
|
||||
|
||||
void bulkdata_delete_data_from_list(struct resultsnode *link)
|
||||
{
|
||||
list_del(&link->list);
|
||||
FREE(link->name);
|
||||
FREE(link->data);
|
||||
FREE(link->type);
|
||||
FREE(link);
|
||||
}
|
||||
|
||||
void bulkdata_free_data_from_list(struct list_head *dup_list)
|
||||
{
|
||||
struct resultsnode *link;
|
||||
while (dup_list->next != dup_list) {
|
||||
link = list_entry(dup_list->next, struct resultsnode, list);
|
||||
bulkdata_delete_data_from_list(link);
|
||||
}
|
||||
}
|
||||
|
||||
static bool bulkdata_get(int operation, char *path, struct dmctx *dm_ctx)
|
||||
{
|
||||
int fault = 0;
|
||||
|
||||
switch(operation) {
|
||||
case CMD_GET_NAME:
|
||||
fault = dm_entry_param_method(dm_ctx, CMD_GET_NAME, path, "true", NULL);
|
||||
break;
|
||||
case CMD_GET_VALUE:
|
||||
fault = dm_entry_param_method(dm_ctx, CMD_GET_VALUE, path, NULL, NULL);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dm_ctx->list_fault_param.next != &dm_ctx->list_fault_param) {
|
||||
return false;
|
||||
}
|
||||
if (fault) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
char *bulkdata_get_value_param(char *path)
|
||||
{
|
||||
struct dmctx ctx = {0};
|
||||
struct dm_parameter *n;
|
||||
char *value = NULL;
|
||||
|
||||
bulkdata_dm_ctx_init(&ctx);
|
||||
if(bulkdata_get(CMD_GET_VALUE, path, &ctx)) {
|
||||
list_for_each_entry(n, &ctx.list_parameter, list) {
|
||||
value = strdup(n->data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
bulkdata_dm_ctx_clean(&ctx);
|
||||
return value;
|
||||
}
|
||||
|
||||
void bulkdata_get_value(char *path, struct list_head *list)
|
||||
{
|
||||
struct dmctx ctx = {0};
|
||||
struct dm_parameter *n;
|
||||
|
||||
bulkdata_dm_ctx_init(&ctx);
|
||||
if(bulkdata_get(CMD_GET_VALUE, path, &ctx)) {
|
||||
list_for_each_entry(n, &ctx.list_parameter, list) {
|
||||
bulkdata_add_data_to_list(list, n->name, n->data, n->type);
|
||||
}
|
||||
}
|
||||
bulkdata_dm_ctx_clean(&ctx);
|
||||
}
|
||||
|
||||
bool bulkdata_get_name(char *path)
|
||||
{
|
||||
struct dmctx ctx = {0};
|
||||
struct dm_parameter *n;
|
||||
bool ret = false;
|
||||
|
||||
bulkdata_dm_ctx_init(&ctx);
|
||||
if(bulkdata_get(CMD_GET_NAME, path, &ctx)) {
|
||||
list_for_each_entry(n, &ctx.list_parameter, list) {
|
||||
insert(strdup(n->name), false);
|
||||
}
|
||||
ret = true;
|
||||
}
|
||||
bulkdata_dm_ctx_clean(&ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void fill_node_path(void)
|
||||
{
|
||||
pathnode *p=head;
|
||||
while(p!=NULL) {
|
||||
bulkdata_get_name(p->ref_path);
|
||||
p=p->next;
|
||||
}
|
||||
deleteList();
|
||||
}
|
||||
|
||||
static void bulkdata_filter_results(char *path, int start, int end)
|
||||
{
|
||||
int startpos = start, m_index = 0, m_len = 0;
|
||||
char *pp = path + startpos;
|
||||
char exp[NAME_MAX] = {'\0'};
|
||||
|
||||
if(start >= end) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!is_res_required(pp, &m_index, &m_len)) {
|
||||
//append rest of the path to the final list
|
||||
if(pp == path ) {
|
||||
insert(strdup(pp), true);
|
||||
return;
|
||||
}
|
||||
|
||||
pathnode *p = head;
|
||||
while(p != NULL) {
|
||||
char name[NAME_MAX] = {'\0'};
|
||||
strcpy(name, p->ref_path);
|
||||
strcat(name, pp);
|
||||
insert(strdup(name), false);
|
||||
p = p->next;
|
||||
}
|
||||
deleteList();
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the string before the match
|
||||
char name[NAME_MAX]={'\0'};
|
||||
strncpy(name, pp, m_index);
|
||||
|
||||
pathnode *p = head;
|
||||
if(p == NULL) {
|
||||
insert(strdup(name), false);
|
||||
}
|
||||
|
||||
while(p != NULL) {
|
||||
char ref_name[NAME_MAX] = {'\0'};
|
||||
sprintf(ref_name, "%s%s", p->ref_path, name);
|
||||
insert(strdup(ref_name), false);
|
||||
p = p->next;
|
||||
}
|
||||
deleteList();
|
||||
|
||||
startpos += m_index;
|
||||
strncpy(exp, pp+m_index, m_len);
|
||||
pp = path + startpos;
|
||||
fill_node_path();
|
||||
startpos += 2;
|
||||
bulkdata_filter_results(path, startpos, end);
|
||||
}
|
||||
|
||||
static void bulkdata_parse_results(struct list_head *list)
|
||||
{
|
||||
pathnode *p = head;
|
||||
while(p != NULL) {
|
||||
bulkdata_get_value(p->ref_path, list);
|
||||
p = p->next;
|
||||
}
|
||||
deleteList();
|
||||
}
|
||||
|
||||
void bulkdata_get_value_results(char *path, struct list_head *list)
|
||||
{
|
||||
bulkdata_filter_results(path, 0, strlen(path));
|
||||
bulkdata_parse_results(list);
|
||||
}
|
||||
|
||||
char *create_request_url(struct profile *profile)
|
||||
{
|
||||
int i = 0, http_uri_number = profile->profile_http_request_uri_parameter_number;
|
||||
char *value, *uri_param = NULL, *uri_tmp = NULL, *http_url = NULL;
|
||||
|
||||
for (i = 0; i < http_uri_number; i++)
|
||||
{
|
||||
if((profile->profile_http_uri_parameter[i].reference == NULL) || (profile->profile_http_uri_parameter[i].name == NULL))
|
||||
continue;
|
||||
value = bulkdata_get_value_param(profile->profile_http_uri_parameter[i].reference);
|
||||
if(!uri_param) {
|
||||
asprintf(&uri_param, "&%s=%s", profile->profile_http_uri_parameter[i].name, value);
|
||||
free(value);
|
||||
}
|
||||
else {
|
||||
uri_tmp = strdup(uri_param);
|
||||
free(uri_param);
|
||||
asprintf(&uri_param, "%s&%s=%s", uri_tmp, profile->profile_http_uri_parameter[i].name, value);
|
||||
free(value);
|
||||
free(uri_tmp);
|
||||
}
|
||||
}
|
||||
if(uri_param) {
|
||||
asprintf(&http_url, "%s%s", profile->http_url, uri_param);
|
||||
free(uri_param);
|
||||
} else {
|
||||
asprintf(&http_url, "%s", profile->http_url);
|
||||
}
|
||||
return http_url;
|
||||
}
|
||||
|
||||
char *get_bulkdata_profile_parameter_name(char *paramref, char *paramname, char *param)
|
||||
{
|
||||
char **paramarr, *idx1 = NULL, *idx2 = NULL, *res = NULL, *instance = NULL, *tmp = NULL, *retparam = NULL, *s = NULL;
|
||||
int i, j = 0;
|
||||
size_t length;
|
||||
|
||||
if(paramname == NULL || strlen(paramname) <= 0)
|
||||
return strdup(param);
|
||||
paramarr = str_split(paramref, "*", &length);
|
||||
res = strdup(paramname);
|
||||
for(i = 0; i < length; i++) {
|
||||
if(i == length - 1)
|
||||
break;
|
||||
j++;
|
||||
idx1 = strstr(param, paramarr[i]);
|
||||
idx2 = strstr(param, paramarr[i+1]);
|
||||
instance = (char*)calloc(idx2 - idx1 - strlen(paramarr[i]) + 1, sizeof(char));
|
||||
memcpy(instance, idx1 + strlen(paramarr[i]), idx2 - idx1 - strlen(paramarr[i]));
|
||||
tmp = strdup(res);
|
||||
FREE(res);
|
||||
asprintf(&res, "%s.%s", tmp, instance);
|
||||
FREE(tmp);
|
||||
FREE(instance);
|
||||
}
|
||||
if ((s = strstr(param,paramarr[j]) ) != NULL && strlen(s) == strlen(paramarr[j]))
|
||||
asprintf(&retparam, "%s", res);
|
||||
else
|
||||
asprintf(&retparam, "%s.%s", res, strstr(param, paramarr[j]) + strlen(paramarr[j]));
|
||||
|
||||
FREE(res);
|
||||
for(int k = 0; k < length; k++)
|
||||
FREE(paramarr[k]);
|
||||
FREE(paramarr);
|
||||
|
||||
return retparam;
|
||||
}
|
||||
|
||||
void append_string_to_string(char *strappend, char **target)
|
||||
{
|
||||
char *tmp = NULL;
|
||||
|
||||
if(strappend == NULL || strlen(strappend) <= 0)
|
||||
return;
|
||||
if(*target == NULL || strlen(*target) <= 0) {
|
||||
*target = strdup(strappend);
|
||||
return;
|
||||
} else {
|
||||
tmp = strdup(*target);
|
||||
FREE(*target);
|
||||
}
|
||||
asprintf(target, "%s%s", tmp, strappend);
|
||||
FREE(tmp);
|
||||
}
|
||||
|
||||
void bulkdata_add_failed_report(struct profile *profile, char *freport)
|
||||
{
|
||||
struct failed_reports *report, *retreport, *rtmp;
|
||||
|
||||
if(profile->nbre_failed_reports < profile->nbre_of_retained_failed_reports || profile->nbre_of_retained_failed_reports < 0) {
|
||||
profile->nbre_failed_reports++;
|
||||
} else {
|
||||
list_for_each_entry_safe(retreport, rtmp, profile->failed_reports, list) {
|
||||
bulkdata_delete_failed_report(retreport);
|
||||
break;
|
||||
}
|
||||
}
|
||||
report = calloc(1, sizeof(struct failed_reports));
|
||||
list_add_tail(&report->list, profile->failed_reports);
|
||||
report->freport= strdup(freport);
|
||||
}
|
||||
|
||||
void bulkdata_delete_failed_report(struct failed_reports *report)
|
||||
{
|
||||
if(report != NULL) {
|
||||
list_del(&report->list);
|
||||
FREE(report->freport);
|
||||
FREE(report);
|
||||
}
|
||||
}
|
||||
|
||||
struct failed_reports* empty_failed_reports_list(struct profile *profile)
|
||||
{
|
||||
struct failed_reports *report, *rtmp;
|
||||
|
||||
if(list_empty(profile->failed_reports))
|
||||
return NULL;
|
||||
list_for_each_entry_safe(report, rtmp, profile->failed_reports, list) {
|
||||
list_del(&report->list);
|
||||
FREE(report->freport);
|
||||
FREE(report);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void add_failed_reports_to_report_csv(struct profile *profile, char **report, int isnext)
|
||||
{
|
||||
struct failed_reports *retreport = NULL;
|
||||
int j = 0;
|
||||
|
||||
if(list_empty(profile->failed_reports))
|
||||
return;
|
||||
list_for_each_entry(retreport, profile->failed_reports, list) {
|
||||
if(!j && isnext) {
|
||||
j = 1;
|
||||
continue;
|
||||
}
|
||||
append_string_to_string(retreport->freport, report);
|
||||
}
|
||||
}
|
||||
69
bulkdata/src/common.h
Normal file
69
bulkdata/src/common.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __COMMON_H
|
||||
#define __COMMON_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <regex.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <libubox/blobmsg.h>
|
||||
#include <libubox/blobmsg_json.h>
|
||||
#include <libubox/utils.h>
|
||||
#include <libubus.h>
|
||||
|
||||
#include <libbbfdm/dmentry.h>
|
||||
#include <libbbfdm/dmbbfcommon.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "bulkdata.h"
|
||||
|
||||
typedef struct pathnode {
|
||||
char *ref_path;
|
||||
struct pathnode *next;
|
||||
} pathnode;
|
||||
|
||||
typedef struct resultsnode {
|
||||
struct list_head list;
|
||||
char *name;
|
||||
char *data;
|
||||
char *type;
|
||||
} resultsnode;
|
||||
|
||||
struct failed_reports {
|
||||
struct list_head list;
|
||||
char *freport;
|
||||
};
|
||||
|
||||
#define GLOB_CHAR "[[+*]+"
|
||||
|
||||
int bulkdata_dm_ctx_init(struct dmctx *ctx);
|
||||
int bulkdata_dm_ctx_clean(struct dmctx *ctx);
|
||||
|
||||
char *bulkdata_get_value_param(char *path);
|
||||
void bulkdata_get_value(char *path, struct list_head *list);
|
||||
|
||||
void bulkdata_free_data_from_list(struct list_head *dup_list);
|
||||
void bulkdata_get_value_results(char *path, struct list_head *list);
|
||||
char *create_request_url(struct profile *profile);
|
||||
char *get_bulkdata_profile_parameter_name(char *paramref, char *paramname, char *param);
|
||||
void append_string_to_string(char *strappend, char **target);
|
||||
void bulkdata_add_failed_report(struct profile *profile, char *freport);
|
||||
void bulkdata_delete_failed_report(struct failed_reports *report);
|
||||
|
||||
struct failed_reports *empty_failed_reports_list(struct profile *profile);
|
||||
void add_failed_reports_to_report_csv(struct profile *profile, char **report, int isnext);
|
||||
|
||||
#endif //__COMMON_H
|
||||
523
bulkdata/src/config.c
Normal file
523
bulkdata/src/config.c
Normal file
@@ -0,0 +1,523 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
* Omar Kallel <omar.kallel@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <strings.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "config.h"
|
||||
#include "buci.h"
|
||||
#include "common.h"
|
||||
#include "bulkdata.h"
|
||||
|
||||
int get_log_level_config(struct bulkdata *bulkdata)
|
||||
{
|
||||
char *value = NULL;
|
||||
|
||||
buci_init();
|
||||
value = buci_get_value("bulkdata", "bulkdata", "log_level");
|
||||
if(value != NULL && *value != '\0')
|
||||
bulkdata->log_level = atoi(value);
|
||||
else
|
||||
bulkdata->log_level = DEFAULT_LOGLEVEL;
|
||||
bulkdata_log(SDEBUG,"Log Level of Bulkdata is : %d", bulkdata->log_level);
|
||||
buci_fini();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_amd_version_config(struct bulkdata *bulkdata)
|
||||
{
|
||||
char *value = NULL;
|
||||
|
||||
buci_init();
|
||||
value = buci_get_value("cwmp", "cpe", "amd_version");
|
||||
if(value != NULL && *value != '\0')
|
||||
bulkdata->amd_version = atoi(value);
|
||||
else
|
||||
bulkdata->amd_version = DEFAULT_AMD_VERSION;
|
||||
bulkdata_log(SDEBUG,"CWMP Amendment Version is : %d", bulkdata->amd_version);
|
||||
buci_fini();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_instance_mode_config(struct bulkdata *bulkdata)
|
||||
{
|
||||
char *value = NULL;
|
||||
|
||||
buci_init();
|
||||
value = buci_get_value("cwmp", "cpe", "instance_mode");
|
||||
if(value != NULL && *value != '\0') {
|
||||
if(!strcmp(value, "InstanceNumber"))
|
||||
bulkdata->instance_mode = INSTANCE_MODE_NUMBER;
|
||||
else
|
||||
bulkdata->instance_mode = INSTANCE_MODE_ALIAS;
|
||||
}
|
||||
else
|
||||
bulkdata->instance_mode = DEFAULT_INSTANCE_MODE;
|
||||
bulkdata_log(SDEBUG,"CWMP Instance Mode is : %d", bulkdata->instance_mode);
|
||||
buci_fini();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_device_id_config(struct bulkdata *bulkdata)
|
||||
{
|
||||
struct dmctx dmctx = {0};
|
||||
|
||||
bulkdata_dm_ctx_init(&dmctx);
|
||||
bulkdata->device_id.manufacturer_oui = bulkdata_get_value_param("Device.DeviceInfo.ManufacturerOUI");
|
||||
bulkdata->device_id.product_class = bulkdata_get_value_param("Device.DeviceInfo.ProductClass");
|
||||
bulkdata->device_id.serial_number = bulkdata_get_value_param("Device.DeviceInfo.SerialNumber");
|
||||
bulkdata_dm_ctx_clean(&dmctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int load_profile_config(struct bulkdata *bulkdata, struct uci_section *s, int i)
|
||||
{
|
||||
char *value = NULL;
|
||||
|
||||
value = buci_get_value_bysection(s, "profile_id");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].profile_id = atoi(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The profile_id of profile_id %d is : %d", i, bulkdata->profile[i].profile_id);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "nbre_of_retained_failed_reports");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].nbre_of_retained_failed_reports = atoi(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The nombre of retained failed reports of profile_id %d is : %d", bulkdata->profile[i].profile_id, bulkdata->profile[i].nbre_of_retained_failed_reports);
|
||||
}
|
||||
|
||||
value = buci_get_value_bysection(s, "protocol");
|
||||
if(value != NULL && *value != '\0' && strcasecmp(value, "http")==0) {
|
||||
bulkdata->profile[i].protocol = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The protocol of profile_id %d is : %s", bulkdata->profile[i].profile_id, bulkdata->profile[i].protocol);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "encoding_type");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].encoding_type = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The encoding type of profile_id %d is : %s", bulkdata->profile[i].profile_id, bulkdata->profile[i].encoding_type);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "reporting_interval");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].reporting_interval = atoi(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The reporting interval of profile_id %d is : %d", bulkdata->profile[i].profile_id, bulkdata->profile[i].reporting_interval);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "time_reference");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].time_reference = atoi(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The time reference of profile_id %d is : %ld", bulkdata->profile[i].profile_id, bulkdata->profile[i].time_reference);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "csv_encoding_field_separator");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].csv_encoding_field_separator = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The csv encoding field separator of profile_id %d is : %s", bulkdata->profile[i].profile_id, bulkdata->profile[i].csv_encoding_field_separator);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "csv_encoding_row_separator");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].csv_encoding_row_separator = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The csv encoding row separator of profile_id %d is : %s", bulkdata->profile[i].profile_id, bulkdata->profile[i].csv_encoding_row_separator);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "csv_encoding_escape_character");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].csv_encoding_escape_character = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The csv encoding escape character of profile_id %d is : %s", bulkdata->profile[i].profile_id, bulkdata->profile[i].csv_encoding_escape_character);
|
||||
}
|
||||
|
||||
value = buci_get_value_bysection(s, "csv_encoding_report_format");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].csv_encoding_report_format = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The csv encoding report format of profile_id %d is : %s", bulkdata->profile[i].profile_id, bulkdata->profile[i].csv_encoding_report_format);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "csv_encoding_row_time_stamp");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].csv_encoding_row_time_stamp = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The csv encoding row time stamp of profile_id %d is : %s", bulkdata->profile[i].profile_id, bulkdata->profile[i].csv_encoding_row_time_stamp);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "json_encoding_report_format");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].json_encoding_report_format = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The json encoding report format of profile_id %d is : %s", bulkdata->profile[i].profile_id, bulkdata->profile[i].json_encoding_report_format);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "json_encoding_report_time_stamp");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].json_encoding_report_time_stamp = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The json encoding report time stamp of profile_id %d is : %s", bulkdata->profile[i].profile_id, bulkdata->profile[i].json_encoding_report_time_stamp);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "http_url");
|
||||
if(value != NULL && *value != '\0') {
|
||||
char *url = NULL;
|
||||
asprintf(&url, "%s?oui=%s&pc=%s&sn=%s", value, bulkdata->device_id.manufacturer_oui, bulkdata->device_id.serial_number, bulkdata->device_id.serial_number);
|
||||
bulkdata->profile[i].http_url = strdup(url);
|
||||
free(url);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The HTTP url of profile_id %d is : %s", bulkdata->profile[i].profile_id, bulkdata->profile[i].http_url);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "http_username");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].http_username = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The HTTP username of profile_id %d is : %s", bulkdata->profile[i].profile_id, bulkdata->profile[i].http_username);
|
||||
} else {
|
||||
bulkdata->profile[i].http_username = NULL;
|
||||
}
|
||||
|
||||
value = buci_get_value_bysection(s, "http_password");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].http_password = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The HTTP password of profile_id %d is : %s", bulkdata->profile[i].profile_id, bulkdata->profile[i].http_password);
|
||||
} else {
|
||||
bulkdata->profile[i].http_password = NULL;
|
||||
}
|
||||
|
||||
value = buci_get_value_bysection(s, "http_compression");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].http_compression = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The HTTP compression of profile_id %d is : %s", bulkdata->profile[i].profile_id, bulkdata->profile[i].http_compression);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "http_method");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].http_method = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The HTTP method of profile_id %d is : %s", bulkdata->profile[i].profile_id, bulkdata->profile[i].http_method);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "http_use_date_header");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].http_use_date_header = atoi(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The HTTP use date header of profile_id %d is : %d", bulkdata->profile[i].profile_id, bulkdata->profile[i].http_use_date_header);
|
||||
}
|
||||
|
||||
value = buci_get_value_bysection(s, "http_retry_enable");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].http_retry_enable = atoi(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The HTTP retry enable of profile_id %d is : %d", bulkdata->profile[i].profile_id, bulkdata->profile[i].http_retry_enable);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "http_retry_minimum_wait_interval");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].http_retry_minimum_wait_interval = atoi(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The HTTP retry minimum wait interval of profile_id %d is : %d", bulkdata->profile[i].profile_id, bulkdata->profile[i].http_retry_minimum_wait_interval);
|
||||
}
|
||||
|
||||
value = buci_get_value_bysection(s, "http_retry_interval_multiplier");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].http_retry_interval_multiplier = atoi(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The HTTP retry interval multiplier of profile_id %d is : %d", bulkdata->profile[i].profile_id, bulkdata->profile[i].http_retry_interval_multiplier);
|
||||
}
|
||||
|
||||
value = buci_get_value_bysection(s, "http_persist_across_reboot");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].http_persist_across_reboot = atoi(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The HTTP persist across reboot of profile_id %d is : %d", bulkdata->profile[i].profile_id, bulkdata->profile[i].http_persist_across_reboot);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "http_ssl_capath");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].http_ssl_capath = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The HTTP ssl capath of profile_id %d is : %s", bulkdata->profile[i].profile_id, bulkdata->profile[i].http_ssl_capath);
|
||||
} else {
|
||||
bulkdata->profile[i].http_ssl_capath = NULL;
|
||||
}
|
||||
|
||||
value = buci_get_value_bysection(s, "http_insecure_enable");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].http_insecure_enable = atoi(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The HTTP insecure enable of profile_id %d is : %d", bulkdata->profile[i].profile_id, bulkdata->profile[i].http_insecure_enable);
|
||||
}
|
||||
|
||||
bulkdata->profile[i].retry_count = 0;
|
||||
bulkdata->profile[i].nbre_failed_reports = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_profiles_enable(struct bulkdata *bulkdata)
|
||||
{
|
||||
struct uci_section *s;
|
||||
char *enable;
|
||||
int i = 0, nbr_profiles = 0;
|
||||
|
||||
buci_init();
|
||||
|
||||
buci_foreach_section("bulkdata", "profile", s) {
|
||||
enable = buci_get_value_bysection(s, "enable");
|
||||
if(strcmp(enable, "1") == 0) {
|
||||
nbr_profiles++;
|
||||
}
|
||||
}
|
||||
|
||||
if(nbr_profiles != 0)
|
||||
bulkdata->profile = calloc(2, sizeof(struct profile));
|
||||
|
||||
buci_foreach_section("bulkdata", "profile", s) {
|
||||
enable = buci_get_value_bysection(s, "enable");
|
||||
if(strcmp(enable, "1") == 0) {
|
||||
if(load_profile_config(bulkdata, s, i) == -1) {
|
||||
bulkdata_log(SCRIT,"Not able to start bulkdata: some required bulkdata configurations in profile must be set");
|
||||
return -1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
profiles_number = nbr_profiles;
|
||||
|
||||
buci_fini();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int load_profile_parameter_config(struct bulkdata *bulkdata, struct uci_section *s, int i, int j)
|
||||
{
|
||||
char *value = NULL;
|
||||
|
||||
value = buci_get_value_bysection(s, "name");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].profile_parameter[j].name = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The parameter name %d of profile_id %d is : %s", j+1, bulkdata->profile[i].profile_id, bulkdata->profile[i].profile_parameter[j].name);
|
||||
} else {
|
||||
bulkdata->profile[i].profile_parameter[j].name = NULL;
|
||||
}
|
||||
|
||||
value = buci_get_value_bysection(s, "reference");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].profile_parameter[j].reference = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The parameter reference %d of profile_id %d is : %s", j+1, bulkdata->profile[i].profile_id, bulkdata->profile[i].profile_parameter[j].reference);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_profiles_parameters(struct bulkdata *bulkdata)
|
||||
{
|
||||
struct uci_section *s;
|
||||
char *profile_id;
|
||||
int i, j, nbr_profile_parameters;
|
||||
|
||||
buci_init();
|
||||
|
||||
for (i = 0; i < profiles_number; i++) {
|
||||
j = 0;
|
||||
nbr_profile_parameters = 0;
|
||||
buci_foreach_section("bulkdata", "profile_parameter", s) {
|
||||
profile_id = buci_get_value_bysection(s, "profile_id");
|
||||
if(bulkdata->profile[i].profile_id != atoi(profile_id))
|
||||
continue;
|
||||
nbr_profile_parameters++;
|
||||
if(nbr_profile_parameters == 1) {
|
||||
bulkdata->profile[i].profile_parameter = calloc(1, sizeof(struct profile_parameter));
|
||||
} else {
|
||||
bulkdata->profile[i].profile_parameter = realloc(bulkdata->profile[i].profile_parameter, nbr_profile_parameters * sizeof(struct profile_parameter));
|
||||
}
|
||||
if(load_profile_parameter_config(bulkdata, s, i, j) == -1) {
|
||||
bulkdata_log(SCRIT,"Not able to start bulkdata: some required bulkdata configurations in profile_parameter must be set");
|
||||
return -1;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
bulkdata->profile[i].profile_parameter_number = nbr_profile_parameters;
|
||||
}
|
||||
|
||||
buci_fini();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int load_profile_http_request_uri_parameter_config(struct bulkdata *bulkdata, struct uci_section *s, int i, int j)
|
||||
{
|
||||
char *value = NULL;
|
||||
|
||||
value = buci_get_value_bysection(s, "name");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].profile_http_uri_parameter[j].name = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The HTTP resuest URI parameter name %d of profile_id %d is : %s", j+1, bulkdata->profile[i].profile_id, bulkdata->profile[i].profile_http_uri_parameter[j].name);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
value = buci_get_value_bysection(s, "reference");
|
||||
if(value != NULL && *value != '\0') {
|
||||
bulkdata->profile[i].profile_http_uri_parameter[j].reference = strdup(value);
|
||||
value = NULL;
|
||||
bulkdata_log(SDEBUG,"The HTTP resuest URI parameter reference %d of profile_id %d is : %s", j+1, bulkdata->profile[i].profile_id, bulkdata->profile[i].profile_http_uri_parameter[j].reference);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_profile_http_request_uri_parameter(struct bulkdata *bulkdata)
|
||||
{
|
||||
struct uci_section *s;
|
||||
char *profile_id;
|
||||
int i, j, nbr_profile_http_request_uri_parameter;
|
||||
|
||||
buci_init();
|
||||
|
||||
for (i = 0; i < profiles_number; i++) {
|
||||
j = 0;
|
||||
nbr_profile_http_request_uri_parameter = 0;
|
||||
buci_foreach_section("bulkdata", "profile_http_request_uri_parameter", s) {
|
||||
profile_id = buci_get_value_bysection(s, "profile_id");
|
||||
if(bulkdata->profile[i].profile_id != atoi(profile_id))
|
||||
continue;
|
||||
nbr_profile_http_request_uri_parameter++;
|
||||
if(nbr_profile_http_request_uri_parameter == 1) {
|
||||
bulkdata->profile[i].profile_http_uri_parameter = calloc(1, sizeof(struct profile_http_request_uri_parameter));
|
||||
} else {
|
||||
bulkdata->profile[i].profile_http_uri_parameter = realloc(bulkdata->profile[i].profile_http_uri_parameter, nbr_profile_http_request_uri_parameter * sizeof(struct profile_http_request_uri_parameter));
|
||||
}
|
||||
if(load_profile_http_request_uri_parameter_config(bulkdata, s, i, j)== -1) {
|
||||
bulkdata_log(SCRIT,"Not able to start bulkdata: some required bulkdata configurations in profile_http_request_uri_parameter must be set");
|
||||
return -1;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
bulkdata->profile[i].profile_http_request_uri_parameter_number = nbr_profile_http_request_uri_parameter;
|
||||
}
|
||||
|
||||
buci_fini();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bulkdata_config_init(struct bulkdata *bulkdata)
|
||||
{
|
||||
get_log_level_config(bulkdata);
|
||||
get_amd_version_config(bulkdata);
|
||||
get_instance_mode_config(bulkdata);
|
||||
get_device_id_config(bulkdata);
|
||||
if (get_profiles_enable(bulkdata) == -1)
|
||||
return -1;
|
||||
if (get_profiles_parameters(bulkdata) == -1)
|
||||
return -1;
|
||||
if (get_profile_http_request_uri_parameter(bulkdata) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int free_device_id_config(struct bulkdata *bulkdata)
|
||||
{
|
||||
FREE(bulkdata->device_id.manufacturer_oui);
|
||||
FREE(bulkdata->device_id.product_class);
|
||||
FREE(bulkdata->device_id.serial_number);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int free_profiles_enable(struct bulkdata *bulkdata)
|
||||
{
|
||||
for(int i = 0; i < profiles_number; i++) {
|
||||
FREE(bulkdata->profile[i].protocol);
|
||||
FREE(bulkdata->profile[i].encoding_type);
|
||||
FREE(bulkdata->profile[i].csv_encoding_field_separator);
|
||||
FREE(bulkdata->profile[i].csv_encoding_row_separator);
|
||||
FREE(bulkdata->profile[i].csv_encoding_escape_character);
|
||||
FREE(bulkdata->profile[i].csv_encoding_report_format);
|
||||
FREE(bulkdata->profile[i].csv_encoding_row_time_stamp);
|
||||
FREE(bulkdata->profile[i].json_encoding_report_format);
|
||||
FREE(bulkdata->profile[i].json_encoding_report_time_stamp);
|
||||
FREE(bulkdata->profile[i].http_url);
|
||||
FREE(bulkdata->profile[i].http_username);
|
||||
FREE(bulkdata->profile[i].http_password);
|
||||
FREE(bulkdata->profile[i].http_compression);
|
||||
FREE(bulkdata->profile[i].http_method);
|
||||
FREE(bulkdata->profile[i].http_ssl_capath);
|
||||
}
|
||||
FREE(bulkdata->profile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int free_profiles_parameters(struct bulkdata *bulkdata)
|
||||
{
|
||||
for(int i = 0; i < profiles_number; i++) {
|
||||
for(int j = 0; j < bulkdata->profile[i].profile_parameter_number; j++) {
|
||||
FREE(bulkdata->profile[i].profile_parameter[j].name);
|
||||
FREE(bulkdata->profile[i].profile_parameter[j].reference);
|
||||
}
|
||||
FREE(bulkdata->profile[i].profile_parameter);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int free_profile_http_request_uri_parameter(struct bulkdata *bulkdata)
|
||||
{
|
||||
for(int i = 0; i < profiles_number; i++) {
|
||||
for(int j = 0; j < bulkdata->profile[i].profile_http_request_uri_parameter_number; j++) {
|
||||
FREE(bulkdata->profile[i].profile_http_uri_parameter[j].name);
|
||||
FREE(bulkdata->profile[i].profile_http_uri_parameter[j].reference);
|
||||
}
|
||||
FREE(bulkdata->profile[i].profile_http_uri_parameter);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bulkdata_config_fini(struct bulkdata *bulkdata)
|
||||
{
|
||||
free_device_id_config(bulkdata);
|
||||
free_profiles_parameters(bulkdata);
|
||||
free_profile_http_request_uri_parameter(bulkdata);
|
||||
free_profiles_enable(bulkdata);
|
||||
return 0;
|
||||
}
|
||||
103
bulkdata/src/config.h
Normal file
103
bulkdata/src/config.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __CONFIG_H
|
||||
#define __CONFIG_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <time.h>
|
||||
#include <libubox/uloop.h>
|
||||
|
||||
#define DEFAULT_AMD_VERSION 2
|
||||
#define DEFAULT_INSTANCE_MODE 0
|
||||
|
||||
typedef struct device_id {
|
||||
char *manufacturer_oui;
|
||||
char *product_class;
|
||||
char *serial_number;
|
||||
} device_id;
|
||||
|
||||
typedef struct profile_parameter {
|
||||
int profile_id;
|
||||
char *name;
|
||||
char *reference;
|
||||
} profile_parameter;
|
||||
|
||||
typedef struct profile_http_request_uri_parameter {
|
||||
int profile_id;
|
||||
char *name;
|
||||
char *reference;
|
||||
} profile_http_request_uri_parameter;
|
||||
|
||||
typedef struct profile {
|
||||
struct uloop_timeout utimer;
|
||||
int profile_id;
|
||||
int nbre_of_retained_failed_reports;
|
||||
int nbre_failed_reports;
|
||||
int reporting_interval;
|
||||
int profile_parameter_number;
|
||||
int profile_http_request_uri_parameter_number;
|
||||
int http_retry_minimum_wait_interval;
|
||||
int http_retry_interval_multiplier;
|
||||
int min_retry;
|
||||
int retry_count;
|
||||
char *protocol;
|
||||
char *encoding_type;
|
||||
char *csv_encoding_field_separator;
|
||||
char *csv_encoding_row_separator;
|
||||
char *csv_encoding_escape_character;
|
||||
char *csv_encoding_report_format;
|
||||
char *csv_encoding_row_time_stamp;
|
||||
char *json_encoding_report_format;
|
||||
char *json_encoding_report_time_stamp;
|
||||
char *http_url;
|
||||
char *http_username;
|
||||
char *http_password;
|
||||
char *http_compression;
|
||||
char *http_method;
|
||||
char *http_ssl_capath;
|
||||
char *new_report;
|
||||
time_t time_reference;
|
||||
time_t next_retry;
|
||||
time_t next_period;
|
||||
bool http_persist_across_reboot;
|
||||
bool http_insecure_enable;
|
||||
bool enable;
|
||||
bool http_use_date_header;
|
||||
bool http_retry_enable;
|
||||
struct profile_parameter *profile_parameter;
|
||||
struct profile_http_request_uri_parameter *profile_http_uri_parameter;
|
||||
struct list_head *failed_reports;
|
||||
} profile;
|
||||
|
||||
typedef struct bulkdata {
|
||||
struct device_id device_id;
|
||||
struct profile *profile;
|
||||
int log_level;
|
||||
int amd_version;
|
||||
unsigned int instance_mode;
|
||||
} bulkdata;
|
||||
|
||||
int bulkdata_config_init(struct bulkdata *bulkdata);
|
||||
int bulkdata_config_fini(struct bulkdata *bulkdata);
|
||||
|
||||
#ifndef FREE
|
||||
#define FREE(x) do { if(x) {free(x); x = NULL;} } while (0)
|
||||
#endif
|
||||
|
||||
#endif //__CONFIG_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1293
bulkdata/src/datamodel.c
Normal file
1293
bulkdata/src/datamodel.c
Normal file
File diff suppressed because it is too large
Load Diff
29
bulkdata/src/datamodel.h
Normal file
29
bulkdata/src/datamodel.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
||||
* as published by the Free Software Foundation
|
||||
*
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#ifndef _BULKDATA_H_
|
||||
#define _BULKDATA_H_
|
||||
|
||||
#include <libbbf_api/dmcommon.h>
|
||||
|
||||
extern DMOBJ tDeviceBulkDataObj[];
|
||||
extern DMOBJ tBulkDataObj[];
|
||||
extern DMLEAF tBulkDataParams[];
|
||||
extern DMOBJ tBulkDataProfileObj[];
|
||||
extern DMLEAF tBulkDataProfileParams[];
|
||||
extern DMLEAF tBulkDataProfileParameterParams[];
|
||||
extern DMLEAF tBulkDataProfileCSVEncodingParams[];
|
||||
extern DMLEAF tBulkDataProfileJSONEncodingParams[];
|
||||
extern DMOBJ tBulkDataProfileHTTPObj[];
|
||||
extern DMLEAF tBulkDataProfileHTTPParams[];
|
||||
extern DMLEAF tBulkDataProfileHTTPRequestURIParameterParams[];
|
||||
|
||||
#endif //__BULKDATA_H_
|
||||
|
||||
196
bulkdata/src/http.c
Normal file
196
bulkdata/src/http.c
Normal file
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
* Omar Kallel <omar.kallel@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#include "http.h"
|
||||
|
||||
static struct http_client http_c;
|
||||
static CURL *curl;
|
||||
|
||||
int http_client_init(struct profile *profile)
|
||||
{
|
||||
char *url = create_request_url(profile);
|
||||
if(url) {
|
||||
asprintf(&http_c.url, "%s", url);
|
||||
free(url);
|
||||
}
|
||||
bulkdata_log(SINFO, "ACS url: %s", http_c.url);
|
||||
|
||||
curl_global_init(CURL_GLOBAL_SSL);
|
||||
curl = curl_easy_init();
|
||||
if (!curl) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void http_client_exit(void)
|
||||
{
|
||||
FREE(http_c.url);
|
||||
|
||||
if (http_c.header_list) {
|
||||
curl_slist_free_all(http_c.header_list);
|
||||
http_c.header_list = NULL;
|
||||
}
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
}
|
||||
|
||||
static size_t http_get_response(void *buffer, size_t size, size_t rxed, char **msg_in)
|
||||
{
|
||||
char *c;
|
||||
|
||||
if (asprintf(&c, "%s%.*s", *msg_in, (int) (size * rxed), (char *)buffer) == -1) {
|
||||
FREE(*msg_in);
|
||||
return -1;
|
||||
}
|
||||
|
||||
free(*msg_in);
|
||||
*msg_in = c;
|
||||
|
||||
return size * rxed;
|
||||
}
|
||||
|
||||
int http_send_message(struct profile *profile, char *msg_out, int msg_out_len, char **msg_in)
|
||||
{
|
||||
CURLcode res;
|
||||
long http_code = 0;
|
||||
char errbuf[CURL_ERROR_SIZE];
|
||||
|
||||
http_c.header_list = NULL;
|
||||
http_c.header_list = curl_slist_append(http_c.header_list, "User-Agent: iopsys-bulkdata");
|
||||
if (!http_c.header_list) return -1;
|
||||
|
||||
if (profile->http_use_date_header) {
|
||||
if (bulkdata_get_time() != NULL) {
|
||||
http_c.header_list = curl_slist_append(http_c.header_list, bulkdata_get_time());
|
||||
if (!http_c.header_list) return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(profile->encoding_type, "json") == 0) {
|
||||
http_c.header_list = curl_slist_append(http_c.header_list, "Content-Type: application/json; charset=\"utf-8\"");
|
||||
if (!http_c.header_list) return -1;
|
||||
|
||||
if(strcmp (profile->json_encoding_report_format, "objecthierarchy") == 0) {
|
||||
http_c.header_list = curl_slist_append(http_c.header_list, "BBF-Report-Format: \"ObjectHierarchy\"");
|
||||
if (!http_c.header_list) return -1;
|
||||
} else if(strcmp(profile->json_encoding_report_format, "namevaluepair") == 0) {
|
||||
http_c.header_list = curl_slist_append(http_c.header_list, "BBF-Report-Format: \"NameValuePair\"");
|
||||
if (!http_c.header_list) return -1;
|
||||
}
|
||||
} else if(strcmp(profile->encoding_type, "csv") == 0) {
|
||||
http_c.header_list = curl_slist_append(http_c.header_list, "Content-Type: text/csv; charset=\"utf-8\"");
|
||||
if (!http_c.header_list) return -1;
|
||||
|
||||
if(strcmp (profile->csv_encoding_report_format, "row") == 0) {
|
||||
http_c.header_list = curl_slist_append(http_c.header_list, "BBF-Report-Format: \"ParameterPerRow\"");
|
||||
if (!http_c.header_list) return -1;
|
||||
} else if(strcmp (profile->csv_encoding_report_format, "column") == 0) {
|
||||
http_c.header_list = curl_slist_append(http_c.header_list, "BBF-Report-Format: \"ParameterPerColumn\"");
|
||||
if (!http_c.header_list) return -1;
|
||||
}
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, http_c.url);
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, profile->http_username);
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, profile->http_password);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC|CURLAUTH_DIGEST);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, HTTP_TIMEOUT);
|
||||
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, HTTP_TIMEOUT);
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
|
||||
curl_easy_setopt(curl, CURLOPT_NOBODY, 0);
|
||||
|
||||
if(strcasecmp(profile->http_compression, "gzip") == 0) {
|
||||
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "gzip");
|
||||
http_c.header_list = curl_slist_append(http_c.header_list, "Content-Encoding: gzip");
|
||||
} else if(strcasecmp(profile->http_compression, "compress") == 0) {
|
||||
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "compress");
|
||||
http_c.header_list = curl_slist_append(http_c.header_list, "Content-Encoding: compress");
|
||||
} else if(strcasecmp(profile->http_compression, "deflate") == 0) {
|
||||
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "deflate");
|
||||
http_c.header_list = curl_slist_append(http_c.header_list, "Content-Encoding: deflate");
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, http_c.header_list);
|
||||
if(strcasecmp(profile->http_method, "put") == 0)
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, msg_out);
|
||||
if (msg_out)
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) msg_out_len);
|
||||
else
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, http_get_response);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, msg_in);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
|
||||
|
||||
if (profile->http_ssl_capath)
|
||||
curl_easy_setopt(curl, CURLOPT_CAPATH, profile->http_ssl_capath);
|
||||
if (profile->http_insecure_enable) {
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
}
|
||||
*msg_in = (char *) calloc (1, sizeof(char));
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
if(res != CURLE_OK) {
|
||||
size_t len = strlen(errbuf);
|
||||
if(len) {
|
||||
if (errbuf[len - 1] == '\n') errbuf[len - 1] = '\0';
|
||||
bulkdata_log(SCRIT, "libcurl: (%d) %s", res, errbuf);
|
||||
} else {
|
||||
bulkdata_log(SCRIT, "libcurl: (%d) %s", res, curl_easy_strerror(res));
|
||||
}
|
||||
}
|
||||
|
||||
if (!strlen(*msg_in))
|
||||
FREE(*msg_in);
|
||||
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
|
||||
if(http_code == 200)
|
||||
bulkdata_log(SINFO, "Receive HTTP 200 OK from Bulkdata Collector");
|
||||
else if(http_code == 401)
|
||||
bulkdata_log(SINFO, "Receive HTTP 401 Unauthorized from Bulkdata Collector");
|
||||
else if(http_code == 204)
|
||||
bulkdata_log(SINFO, "Receive HTTP 204 No Content from Bulkdata Collector");
|
||||
else
|
||||
bulkdata_log(SINFO, "Receive HTTP %d from Bulkdata Collector", http_code);
|
||||
|
||||
if(http_code == 415)
|
||||
{
|
||||
strcpy(profile->http_compression, "None");
|
||||
goto error;
|
||||
}
|
||||
if (http_code != 200 && http_code != 204)
|
||||
goto error;
|
||||
|
||||
curl_easy_reset(curl);
|
||||
if (http_c.header_list) {
|
||||
curl_slist_free_all(http_c.header_list);
|
||||
http_c.header_list = NULL;
|
||||
}
|
||||
|
||||
if (res) goto error;
|
||||
|
||||
return http_code;
|
||||
|
||||
error:
|
||||
FREE(*msg_in);
|
||||
if (http_c.header_list) {
|
||||
curl_slist_free_all(http_c.header_list);
|
||||
http_c.header_list = NULL;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
37
bulkdata/src/http.h
Normal file
37
bulkdata/src/http.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __HTTP_H
|
||||
#define __HTTP_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <curl/curl.h>
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "times.h"
|
||||
#include "common.h"
|
||||
|
||||
#define HTTP_TIMEOUT 30
|
||||
|
||||
struct http_client
|
||||
{
|
||||
struct curl_slist *header_list;
|
||||
char *url;
|
||||
};
|
||||
|
||||
int http_client_init(struct profile *profile);
|
||||
void http_client_exit(void);
|
||||
int http_send_message(struct profile *profile, char *msg_out, int msg_out_len, char **msg_in);
|
||||
|
||||
#endif //__HTTP_H
|
||||
57
bulkdata/src/log.c
Normal file
57
bulkdata/src/log.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "bulkdata.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
|
||||
static const int log_syslogmap[] = {
|
||||
[SCRIT] = LOG_CRIT,
|
||||
[SWARNING] = LOG_WARNING,
|
||||
[SNOTICE] = LOG_NOTICE,
|
||||
[SINFO] = LOG_INFO,
|
||||
[SDEBUG] = LOG_DEBUG
|
||||
};
|
||||
|
||||
static const char* log_str[] = {
|
||||
[SCRIT] = "CRITICAL",
|
||||
[SWARNING] = "WARNING",
|
||||
[SNOTICE] = "NOTICE",
|
||||
[SINFO] = "INFO",
|
||||
[SDEBUG] = "DEBUG"
|
||||
};
|
||||
|
||||
void bulkdata_log(int priority, const char *format, ...)
|
||||
{
|
||||
va_list vl;
|
||||
|
||||
if (priority <= bulkdata_main.log_level) {
|
||||
time_t t = time(NULL);
|
||||
struct tm tm = *localtime(&t);
|
||||
va_start(vl, format);
|
||||
printf("%d-%02d-%02d %02d:%02d:%02d [bulkdata] %s - ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, log_str[priority]);
|
||||
vprintf(format, vl);
|
||||
va_end(vl);
|
||||
printf("\n");
|
||||
|
||||
openlog("bulkdata", 0, LOG_DAEMON);
|
||||
va_start(vl, format);
|
||||
vsyslog(log_syslogmap[priority], format, vl);
|
||||
va_end(vl);
|
||||
closelog();
|
||||
}
|
||||
}
|
||||
28
bulkdata/src/log.h
Normal file
28
bulkdata/src/log.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LOG_H
|
||||
#define __LOG_H
|
||||
|
||||
#define DEFAULT_LOGLEVEL SINFO
|
||||
|
||||
enum bulkdata_log_level_enum {
|
||||
SCRIT,
|
||||
SWARNING,
|
||||
SNOTICE,
|
||||
SINFO,
|
||||
SDEBUG,
|
||||
__MAX_SLOG
|
||||
};
|
||||
|
||||
void bulkdata_log(int priority, const char *format, ...);
|
||||
|
||||
#endif //__LOG_H
|
||||
336
bulkdata/src/report.c
Normal file
336
bulkdata/src/report.c
Normal file
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "report.h"
|
||||
|
||||
static void add_new_json_obj(json_object *json_obj, char *name, char *data, char *type)
|
||||
{
|
||||
json_object *jobj;
|
||||
if(strstr(type, "unsignedInt") || strstr(type, "int") || strstr(type, "long"))
|
||||
jobj = json_object_new_int64(atoi(data));
|
||||
else if(strstr(type, "bool"))
|
||||
jobj = json_object_new_boolean(atoi(data));
|
||||
else
|
||||
jobj = json_object_new_string(data);
|
||||
|
||||
json_object_object_add(json_obj, name, jobj);
|
||||
}
|
||||
|
||||
static void create_json_bulkdata_report_object_hierarchy(struct profile *profile, char **report)
|
||||
{
|
||||
struct json_object *json_obj, *json_obj1, *json_obj2;
|
||||
struct resultsnode *p;
|
||||
int i, j, profile_param_number = profile->profile_parameter_number;
|
||||
char *param_name, *result, *pch, *pchr, *collection_time = NULL;
|
||||
char buf[1024] = {0};
|
||||
|
||||
json_obj = json_object_new_object();
|
||||
get_time_stamp(profile->json_encoding_report_time_stamp, &collection_time);
|
||||
if(collection_time) {
|
||||
if(strcmp(profile->json_encoding_report_time_stamp, "iso8601") == 0)
|
||||
json_object_object_add(json_obj, "CollectionTime", json_object_new_string(collection_time));
|
||||
else
|
||||
json_object_object_add(json_obj, "CollectionTime", json_object_new_int64(atoi(collection_time)));
|
||||
free(collection_time);
|
||||
}
|
||||
json_obj2 = json_obj;
|
||||
for (i = 0; i < profile_param_number; i++) {
|
||||
LIST_HEAD(results_list);
|
||||
bulkdata_get_value_results(profile->profile_parameter[i].reference, &results_list);
|
||||
list_for_each_entry(p, &results_list, list) {
|
||||
char *argv[128] = {0};
|
||||
j = 0;
|
||||
param_name = get_bulkdata_profile_parameter_name(profile->profile_parameter[i].reference, profile->profile_parameter[i].name, p->name);
|
||||
strcpy(buf, param_name);
|
||||
for (pch = strtok_r(buf, ".", &pchr); pch != NULL; pch = strtok_r(NULL, ".", &pchr)) {
|
||||
argv[j] = pch;
|
||||
json_obj1 = (json_object *)dmjson_select_obj(json_obj, argv);
|
||||
if (json_obj1)
|
||||
json_obj2 = json_obj1;
|
||||
else {
|
||||
if (pchr != NULL && *pchr != '\0') {
|
||||
json_object *new_obj = json_object_new_object();
|
||||
json_object_object_add(json_obj2, pch, new_obj);
|
||||
json_obj2 = new_obj;
|
||||
}
|
||||
else
|
||||
add_new_json_obj(json_obj2, pch, p->data, p->type);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
bulkdata_free_data_from_list(&results_list);
|
||||
FREE(param_name);
|
||||
}
|
||||
result = (char *)json_object_to_json_string_ext(json_obj, JSON_C_TO_STRING_PRETTY);
|
||||
*report = strdup(result);
|
||||
json_object_put(json_obj);
|
||||
}
|
||||
|
||||
static void create_json_bulkdata_report_name_value_pair(struct profile *profile, char **report)
|
||||
{
|
||||
struct json_object *json_obj;
|
||||
struct resultsnode *p;
|
||||
char *param_name, *result, *collection_time = NULL;
|
||||
int i = 0, profile_param_number = profile->profile_parameter_number;
|
||||
|
||||
json_obj = json_object_new_object();
|
||||
get_time_stamp(profile->json_encoding_report_time_stamp, &collection_time);
|
||||
if(collection_time) {
|
||||
if(strcmp(profile->json_encoding_report_time_stamp, "iso8601") == 0)
|
||||
json_object_object_add(json_obj, "CollectionTime", json_object_new_string(collection_time));
|
||||
else
|
||||
json_object_object_add(json_obj, "CollectionTime", json_object_new_int64(atoi(collection_time)));
|
||||
free(collection_time);
|
||||
}
|
||||
for (i = 0; i < profile_param_number; i++) {
|
||||
LIST_HEAD(results_list);
|
||||
bulkdata_get_value_results(profile->profile_parameter[i].reference, &results_list);
|
||||
list_for_each_entry(p, &results_list, list) {
|
||||
param_name = get_bulkdata_profile_parameter_name(profile->profile_parameter[i].reference, profile->profile_parameter[i].name, p->name);
|
||||
add_new_json_obj(json_obj, param_name, p->data, p->type);
|
||||
FREE(param_name);
|
||||
}
|
||||
bulkdata_free_data_from_list(&results_list);
|
||||
}
|
||||
result = (char *)json_object_to_json_string_ext(json_obj, JSON_C_TO_STRING_PRETTY);
|
||||
*report = strdup(result);
|
||||
json_object_put(json_obj);
|
||||
}
|
||||
|
||||
static void add_failed_reports_to_report_json(struct profile *profile, char *new_report, char **report, int isnext)
|
||||
{
|
||||
json_object *json_obj, *json_array, *json_string;
|
||||
struct failed_reports *retreport = NULL;
|
||||
char *msgout = NULL;
|
||||
int j = 0;
|
||||
|
||||
json_obj = json_object_new_object();
|
||||
json_array = json_object_new_array();
|
||||
json_object_object_add(json_obj,"Report", json_array);
|
||||
|
||||
if(list_empty(profile->failed_reports))
|
||||
goto new_report;
|
||||
|
||||
list_for_each_entry(retreport, profile->failed_reports, list) {
|
||||
if(!j && isnext) {
|
||||
j = 1;
|
||||
continue;
|
||||
}
|
||||
json_string = json_tokener_parse(retreport->freport);
|
||||
json_object_array_add(json_array, json_string);
|
||||
}
|
||||
|
||||
new_report :
|
||||
if(new_report) {
|
||||
json_string = json_tokener_parse(new_report);
|
||||
json_object_array_add(json_array, json_string);
|
||||
}
|
||||
|
||||
msgout = (char *)json_object_to_json_string_ext(json_obj, JSON_C_TO_STRING_PRETTY);
|
||||
*report = strdup(msgout);
|
||||
json_object_put(json_obj);
|
||||
}
|
||||
|
||||
static void create_report_json(char *new_report, char **report)
|
||||
{
|
||||
json_object *json_obj, *json_array, *json_string;
|
||||
char *msgout = NULL;
|
||||
|
||||
json_obj = json_object_new_object();
|
||||
json_array = json_object_new_array();
|
||||
json_object_object_add(json_obj,"Report", json_array);
|
||||
|
||||
if(new_report) {
|
||||
json_string = json_tokener_parse(new_report);
|
||||
json_object_array_add(json_array, json_string);
|
||||
}
|
||||
|
||||
msgout = (char *)json_object_to_json_string_ext(json_obj, JSON_C_TO_STRING_PRETTY);
|
||||
*report = strdup(msgout);
|
||||
json_object_put(json_obj);
|
||||
}
|
||||
|
||||
int create_json_bulkdata_report(struct profile *profile, char **report)
|
||||
{
|
||||
/*
|
||||
* create json msg of current report
|
||||
* parse failed reports list and add it to the report
|
||||
* then add new report to the report
|
||||
*/
|
||||
char *msgout;
|
||||
|
||||
profile->new_report = NULL;
|
||||
if(strcmp(profile->json_encoding_report_format, "objecthierarchy") == 0) {
|
||||
create_json_bulkdata_report_object_hierarchy(profile, &msgout);
|
||||
} else if(strcmp(profile->json_encoding_report_format, "namevaluepair") == 0) {
|
||||
create_json_bulkdata_report_name_value_pair(profile, &msgout);
|
||||
}
|
||||
|
||||
if(profile->nbre_of_retained_failed_reports != 0) {
|
||||
if(profile->nbre_failed_reports >= profile->nbre_of_retained_failed_reports && profile->nbre_of_retained_failed_reports > 0)
|
||||
add_failed_reports_to_report_json(profile, msgout, report, 1);
|
||||
else
|
||||
add_failed_reports_to_report_json(profile, msgout, report, 0);
|
||||
} else {
|
||||
create_report_json(msgout, report);
|
||||
}
|
||||
|
||||
append_string_to_string(msgout, &profile->new_report);
|
||||
FREE(msgout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int create_csv_bulkdata_report(struct profile *profile, char **report)
|
||||
{
|
||||
/*
|
||||
* create csv msg of current report
|
||||
* parse failed reports list and add it to the report
|
||||
*/
|
||||
int i;
|
||||
struct resultsnode *p;
|
||||
char *str1 = NULL, *str2 = NULL, *str = NULL, *paramprofilename, *timestamp = NULL, *type = NULL, rowseparator = '\0', separator = '\0';
|
||||
|
||||
if(strcmp(profile->csv_encoding_row_separator, " ") == 0)
|
||||
rowseparator = '\n';
|
||||
else if(strcmp(profile->csv_encoding_row_separator, " ") == 0)
|
||||
rowseparator = '\r';
|
||||
|
||||
if(profile->csv_encoding_field_separator)
|
||||
separator = profile->csv_encoding_field_separator[0];
|
||||
|
||||
get_time_stamp(profile->csv_encoding_row_time_stamp, ×tamp);
|
||||
/*
|
||||
* Create header ReportTimestamp,ParameterName,ParameterValue,ParameterType in case of ParameterPerRow
|
||||
*/
|
||||
if(strcmp(profile->csv_encoding_report_format, "row") == 0) {
|
||||
if(timestamp == NULL)
|
||||
asprintf(&str, "ParameterName%cParameterValue%cParameterType%c", separator, separator, rowseparator);
|
||||
else
|
||||
asprintf(&str, "ReportTimestamp%cParameterName%cParameterValue%cParameterType%c", separator, separator, separator, rowseparator);
|
||||
append_string_to_string(str, report);
|
||||
FREE(str);
|
||||
if(profile->nbre_of_retained_failed_reports != 0) {
|
||||
if(profile->nbre_failed_reports >= profile->nbre_of_retained_failed_reports && profile->nbre_of_retained_failed_reports > 0)
|
||||
add_failed_reports_to_report_csv(profile, report, 1);
|
||||
else
|
||||
add_failed_reports_to_report_csv(profile, report, 0);
|
||||
}
|
||||
}
|
||||
if(strcmp(profile->csv_encoding_report_format, "column") == 0 && timestamp != NULL) {
|
||||
if(profile->nbre_of_retained_failed_reports != 0) {
|
||||
if(profile->nbre_failed_reports >= profile->nbre_of_retained_failed_reports && profile->nbre_of_retained_failed_reports > 0)
|
||||
add_failed_reports_to_report_csv(profile, report, 1);
|
||||
else
|
||||
add_failed_reports_to_report_csv(profile, report, 0);
|
||||
}
|
||||
append_string_to_string("ReportTimestamp", &str1);
|
||||
append_string_to_string(timestamp, &str2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add New reports
|
||||
*/
|
||||
profile->new_report = NULL;
|
||||
for(i = 0; i < profile->profile_parameter_number; i++) {
|
||||
LIST_HEAD(results_list);
|
||||
bulkdata_get_value_results(profile->profile_parameter[i].reference, &results_list);
|
||||
list_for_each_entry(p, &results_list, list) {
|
||||
paramprofilename = get_bulkdata_profile_parameter_name(profile->profile_parameter[i].reference, profile->profile_parameter[i].name, p->name);
|
||||
if(strcmp(profile->csv_encoding_report_format, "row") == 0) {
|
||||
type = strstr(p->type, ":");
|
||||
if(timestamp == NULL)
|
||||
asprintf(&str, "%s%c%s%c%s%c", paramprofilename, separator, p->data, separator, type+1, rowseparator);
|
||||
else
|
||||
asprintf(&str, "%s%c%s%c%s%c%s%c", timestamp, separator, paramprofilename, separator, p->data, separator, type+1, rowseparator);
|
||||
append_string_to_string(str, report);
|
||||
append_string_to_string(str, &profile->new_report);
|
||||
FREE(str);
|
||||
} else if(strcmp(profile->csv_encoding_report_format, "column") == 0) {
|
||||
if(str1 == NULL || strlen(str1) <= 0)
|
||||
asprintf(&str, "%s", paramprofilename);
|
||||
else
|
||||
asprintf(&str, "%c%s", separator, paramprofilename);
|
||||
append_string_to_string(str, &str1);
|
||||
FREE(str);
|
||||
if(str2 == NULL || strlen(str2) <= 0)
|
||||
asprintf(&str, "%s", p->data);
|
||||
else
|
||||
asprintf(&str, "%c%s", separator, p->data);
|
||||
append_string_to_string(str, &str2);
|
||||
FREE(str);
|
||||
}
|
||||
FREE(paramprofilename);
|
||||
}
|
||||
bulkdata_free_data_from_list(&results_list);
|
||||
}
|
||||
if(strcmp(profile->csv_encoding_report_format, "column") == 0) {
|
||||
asprintf(&str, "%c", rowseparator);
|
||||
append_string_to_string(str, &str1);
|
||||
append_string_to_string(str, &str2);
|
||||
append_string_to_string(str1, report);
|
||||
append_string_to_string(str2, report);
|
||||
append_string_to_string(str1, &profile->new_report);
|
||||
append_string_to_string(str2, &profile->new_report);
|
||||
}
|
||||
FREE(str);
|
||||
FREE(str1);
|
||||
FREE(str2);
|
||||
FREE(timestamp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void create_json_failed_report(struct profile *profile, char **report)
|
||||
{
|
||||
add_failed_reports_to_report_json(profile, NULL, report, 0);
|
||||
}
|
||||
|
||||
static void create_csv_failed_report(struct profile *profile, char **report)
|
||||
{
|
||||
char rowseparator = '\0', separator = '\0', *timestamp = NULL;
|
||||
|
||||
if(strcmp(profile->csv_encoding_row_separator, " ") == 0) {
|
||||
rowseparator = '\n';
|
||||
} else if(strcmp(profile->csv_encoding_row_separator, " ") == 0) {
|
||||
rowseparator = '\r';
|
||||
}
|
||||
|
||||
if(profile->csv_encoding_field_separator)
|
||||
separator = profile->csv_encoding_field_separator[0];
|
||||
|
||||
get_time_stamp(profile->csv_encoding_row_time_stamp, ×tamp);
|
||||
if(strcmp(profile->csv_encoding_report_format, "row") == 0) {
|
||||
if(timestamp == NULL)
|
||||
asprintf(report, "ParameterName%cParameterValue%cParameterType%c", separator, separator, rowseparator);
|
||||
else
|
||||
asprintf(report, "ReportTimestamp%cParameterName%cParameterValue%cParameterType%c", separator, separator, separator, rowseparator);
|
||||
}
|
||||
add_failed_reports_to_report_csv(profile, report, 0);
|
||||
}
|
||||
|
||||
void create_encoding_bulkdata_report(struct profile *profile, char **report)
|
||||
{
|
||||
if(strcasecmp(profile->encoding_type, "json") == 0) {
|
||||
create_json_bulkdata_report(profile, report);
|
||||
} else if(strcasecmp(profile->encoding_type, "csv") == 0) {
|
||||
create_csv_bulkdata_report(profile, report);
|
||||
}
|
||||
}
|
||||
|
||||
void create_failed_report(struct profile *profile, char **report)
|
||||
{
|
||||
if(strcasecmp(profile->encoding_type, "json") == 0) {
|
||||
create_json_failed_report(profile, report);
|
||||
} else if(strcasecmp(profile->encoding_type, "csv") == 0) {
|
||||
create_csv_failed_report(profile, report);
|
||||
}
|
||||
}
|
||||
24
bulkdata/src/report.h
Normal file
24
bulkdata/src/report.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __REPORT_H_
|
||||
#define __REPORT_H_
|
||||
|
||||
#include <json-c/json.h>
|
||||
#include "common.h"
|
||||
#include "times.h"
|
||||
#include "config.h"
|
||||
|
||||
void create_encoding_bulkdata_report(struct profile *profile, char **report);
|
||||
void create_failed_report(struct profile *profile, char **report);
|
||||
|
||||
#endif /* __REPORT_H_ */
|
||||
62
bulkdata/src/times.c
Normal file
62
bulkdata/src/times.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "times.h"
|
||||
|
||||
const char *bulkdata_get_time(void)
|
||||
{
|
||||
static char local_time[64];
|
||||
|
||||
time_t t_time = time(NULL);
|
||||
struct tm *t_tm = localtime(&t_time);
|
||||
if (t_tm == NULL)
|
||||
return NULL;
|
||||
|
||||
if (strftime(local_time, sizeof(local_time),"Date: %a, %d %b %Y %X%z GMT", t_tm) == 0)
|
||||
return NULL;
|
||||
|
||||
return local_time;
|
||||
}
|
||||
|
||||
void get_time_stamp(const char *format, char **timestamp)
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
|
||||
if (strcmp(format, "unix") == 0) {
|
||||
asprintf(timestamp, "%ld", now);
|
||||
} else if (strcmp(format, "iso8601") == 0) {
|
||||
char buf[32] = {0};
|
||||
struct tm *ts = localtime(&now);
|
||||
strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%Z", ts);
|
||||
asprintf(timestamp, "%s", buf);
|
||||
} else
|
||||
timestamp = NULL;
|
||||
}
|
||||
|
||||
unsigned int get_next_period(time_t time_reference, int reporting_interval)
|
||||
{
|
||||
unsigned int next_period;
|
||||
time_t now = time(NULL);
|
||||
|
||||
if (now > time_reference)
|
||||
next_period = reporting_interval - ((now - time_reference) % reporting_interval);
|
||||
else
|
||||
next_period = (time_reference - now) % reporting_interval;
|
||||
|
||||
if (next_period == 0)
|
||||
next_period = reporting_interval;
|
||||
|
||||
return next_period;
|
||||
}
|
||||
19
bulkdata/src/times.h
Normal file
19
bulkdata/src/times.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __TIMES_H
|
||||
#define __TIMES_H
|
||||
|
||||
const char *bulkdata_get_time(void);
|
||||
void get_time_stamp(const char *format, char **timestamp);
|
||||
unsigned int get_next_period(time_t time_reference, int reporting_interval);
|
||||
|
||||
#endif /* __TIMES_H */
|
||||
@@ -1,7 +1,4 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright (C) 2015 inteno.org
|
||||
#
|
||||
|
||||
START=71
|
||||
USE_PROCD=1
|
||||
|
||||
@@ -4,16 +4,15 @@ START=99
|
||||
|
||||
send_log()
|
||||
{
|
||||
nr=$(db get hw.board.serialNumber)
|
||||
hw=$(db get hw.board.hardware)
|
||||
hwv=$(db get hw.board.hardwareVersion)
|
||||
bid=$(db get hw.board.boardId)
|
||||
nr=$(db get hw.board.serial_number)
|
||||
hw=$(db get hw.board.model_name)
|
||||
fam=$(db get hw.board.iopVerFam)
|
||||
sw=$(db get hw.board.iopVersion)
|
||||
server=$(/sbin/uci get system.crashlog.server)
|
||||
|
||||
while true
|
||||
do
|
||||
scp -S /usr/sbin/logssh /proc/last_kmsg log@${server}:log/${bid}_${hwv}_${hw}_${sw}_${nr}
|
||||
scp -S /usr/sbin/logssh /proc/last_kmsg log@${server}:log/${fam}_${hw}_${sw}_${nr}
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
break;
|
||||
@@ -28,7 +27,7 @@ fill_in_default()
|
||||
/sbin/uci add system log
|
||||
/sbin/uci rename system.@log[-1]=crashlog
|
||||
/sbin/uci set system.crashlog.enable=no
|
||||
/sbin/uci set system.crashlog.server="crash.inteno.se"
|
||||
/sbin/uci set system.crashlog.server="crashlog.iopsys.eu"
|
||||
/sbin/uci commit
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ fill_in_default()
|
||||
/sbin/uci add system log
|
||||
/sbin/uci rename system.@log[-1]=corelog
|
||||
/sbin/uci set system.corelog.enable=no
|
||||
/sbin/uci set system.corelog.server="crash.inteno.se"
|
||||
/sbin/uci set system.corelog.server="corelog.iopsys.eu"
|
||||
/sbin/uci commit
|
||||
}
|
||||
|
||||
@@ -50,12 +50,11 @@ cat >$TMP_CORE
|
||||
# more memory to work with. normally this would do nothing.
|
||||
cat >/dev/null
|
||||
|
||||
nr=$(db get hw.board.serialNumber)
|
||||
hw=$(db get hw.board.hardware)
|
||||
hwv=$(db get hw.board.hardwareVersion)
|
||||
bid=$(db get hw.board.boardId)
|
||||
nr=$(db get hw.board.serial_number)
|
||||
hw=$(db get hw.board.model_name)
|
||||
fam=$(hw.board.iopVerFam)
|
||||
sw=$(db get hw.board.iopVersion)
|
||||
|
||||
scp -S /usr/sbin/logssh $TMP_CORE log@${server}:log/core_${1}_${2}_${bid}_${hwv}_${hw}_${sw}_${nr}
|
||||
scp -S /usr/sbin/logssh $TMP_CORE log@${server}:log/core_${1}_${2}_${fam}_${hw}_${sw}_${nr}
|
||||
rm $TMP_CORE
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ What we need is the public key for the clients.
|
||||
For dropbear "dropbearkey -y -f files/etc/dropbear/logid" will generate the public key.
|
||||
|
||||
----------
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCwn9RaDAzxW1dTmIhXgFBnpi1lhj8xhYpCVQiPxxdk9IEmH8zjo4y9j3sPkqKOlRnkwjpZIpLEKBnpQTwVIMCU/AG7nDJX3OH9RfS9mLJQLfFL8HyGCyqDezFWldbyovhJZvdUeK4tAXJWv2W3OVHiz2L8IlncBgP/E9DJElsyhhQHsM96UE6tBkXsvXkoDbMSYXFcLbgiUwBKfmM2BF/aPDL45iznGur7/2j9v95PwJ0gtMu9jjNRq+pXCXhTh3bsnczm0MpZC1aiRc9nJAeGIMmhrf15E4jBKgTnrstzJxGVAdajKeR954KcNsS33cS2Wmui2YjmPbBXjqf1frzJ log@inteno
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCwn9RaDAzxW1dTmIhXgFBnpi1lhj8xhYpCVQiPxxdk9IEmH8zjo4y9j3sPkqKOlRnkwjpZIpLEKBnpQTwVIMCU/AG7nDJX3OH9RfS9mLJQLfFL8HyGCyqDezFWldbyovhJZvdUeK4tAXJWv2W3OVHiz2L8IlncBgP/E9DJElsyhhQHsM96UE6tBkXsvXkoDbMSYXFcLbgiUwBKfmM2BF/aPDL45iznGur7/2j9v95PwJ0gtMu9jjNRq+pXCXhTh3bsnczm0MpZC1aiRc9nJAeGIMmhrf15E4jBKgTnrstzJxGVAdajKeR954KcNsS33cS2Wmui2YjmPbBXjqf1frzJ log@iopsys
|
||||
----------
|
||||
|
||||
The public key should be just one line. Add that line to the
|
||||
|
||||
@@ -16,7 +16,6 @@ PKG_NAME:=dectmngr2
|
||||
PKG_LICENSE:=GPLv2
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
RSTRIP:=true
|
||||
export BUILD_DIR
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
@@ -30,7 +29,7 @@ define Package/dectmngr2
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Dectmngr2
|
||||
URL:=
|
||||
DEPENDS:= +natalie-dect-h bcmkernel +libubox +ubus +libpicoevent
|
||||
DEPENDS:= +natalie-dect-h bcmkernel +libubox +ubus +libpicoevent endptmngr
|
||||
endef
|
||||
|
||||
define Package/dectmngr2/description
|
||||
|
||||
@@ -12,7 +12,7 @@ if [ -e "/proc/nvram/BoardId" ]; then
|
||||
echo "0xfffffff2" >/proc/nvram/ulBoardStuffOption
|
||||
|
||||
db -q batch <<-EOT
|
||||
set hw.board.hasDect=1
|
||||
set hw.board.has_dect=1
|
||||
commit hw.board
|
||||
EOT
|
||||
fi
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=dslmngr
|
||||
PKG_VERSION:=1.0.0
|
||||
PKG_VERSION:=1.1.0
|
||||
|
||||
LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=7522faab4142fe2c0ac8cbf71bb0cc5bd49f0750
|
||||
PKG_SOURCE_VERSION:=400cc66081f2b10b481d5a745bc505b78af098bd
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/dslmngr.git
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
endif
|
||||
@@ -25,9 +25,7 @@ PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
ifeq ($(CONFIG_TARGET_iopsys_brcm63xx_mips),y)
|
||||
TARGET_PLATFORM=BROADCOM
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_brcm63xx_arm),y)
|
||||
ifeq ($(CONFIG_TARGET_iopsys_brcm63xx_arm),y)
|
||||
TARGET_PLATFORM=BROADCOM
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_ramips),y)
|
||||
TARGET_PLATFORM=MEDIATEK
|
||||
@@ -45,7 +43,7 @@ define Package/dslmngr
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=XDSL status and configration utility
|
||||
DEPENDS:=+libdsl +libuci +libubox +ubus +libpthread +libnl-genl +easy-soc-libs
|
||||
DEPENDS:=+libdsl +libuci +libubox +ubus +libpthread +libnl-genl
|
||||
endef
|
||||
|
||||
define Package/dslmngr/description
|
||||
@@ -56,6 +54,7 @@ endef
|
||||
TARGET_CFLAGS += \
|
||||
-I$(STAGING_DIR)/usr/include \
|
||||
-I$(STAGING_DIR)/usr/include/libnl3 \
|
||||
-I$(STAGING_DIR)/usr/include/xdsl \
|
||||
-D_GNU_SOURCE
|
||||
|
||||
MAKE_FLAGS += \
|
||||
|
||||
@@ -19,7 +19,7 @@ define Package/easy-qos
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Easy QoS
|
||||
DEPENDS:=@(TARGET_intel_mips||TARGET_iopsys_brcm63xx_arm||TARGET_iopsys_brcm63xx_mips)
|
||||
DEPENDS:=@(TARGET_intel_mips||TARGET_iopsys_brcm63xx_arm)
|
||||
endef
|
||||
|
||||
define Package/easy-qos/description
|
||||
|
||||
@@ -4,6 +4,7 @@ START=99
|
||||
USE_PROCD=1
|
||||
|
||||
RULE_LIST="/tmp/easy_qos_rule.list"
|
||||
CLIENT_LIST="/tmp/easy_qos_class_client.list"
|
||||
BRIDGE_INTF=""
|
||||
|
||||
[ -f /etc/profile.d/intel.sh ] && {
|
||||
@@ -16,6 +17,13 @@ log() {
|
||||
}
|
||||
|
||||
exec_log() {
|
||||
${@}
|
||||
if [ "${?}" -ne 0 ]; then
|
||||
log "Failed to create ${@}";
|
||||
fi
|
||||
}
|
||||
|
||||
exec_class_log() {
|
||||
${@} |grep -i successful
|
||||
if [ "${?}" -ne 0 ]; then
|
||||
log "Failed to create ${@}";
|
||||
@@ -46,6 +54,114 @@ get_priority() {
|
||||
esac
|
||||
}
|
||||
|
||||
get_mark() {
|
||||
local prio=$(echo $1|tr [A-Z] [a-z]);
|
||||
case "${prio}" in
|
||||
"lowest")
|
||||
echo "0x41/0x3df";;
|
||||
"low")
|
||||
echo "0x82/0x3df";;
|
||||
"besteffort")
|
||||
echo "0xc3/0x3df";;
|
||||
"normal")
|
||||
echo "0x104/0x3df";;
|
||||
"video")
|
||||
echo "0x145/0x3df";;
|
||||
"medium")
|
||||
echo "0x186/0x3df";;
|
||||
"high")
|
||||
echo "0x1c7/0x3df";;
|
||||
"highest")
|
||||
echo "0x208/0x3df";;
|
||||
esac
|
||||
}
|
||||
|
||||
clean_client_entries() {
|
||||
[ -f ${CLIENT_LIST} ] && rm ${CLIENT_LIST}
|
||||
}
|
||||
|
||||
map_client_entries() {
|
||||
local clients ip mac host
|
||||
|
||||
json_load "$(ubus call router.network 'clients')"
|
||||
json_get_keys keys
|
||||
|
||||
for key in ${keys};
|
||||
do
|
||||
json_select ${key}
|
||||
json_get_vars ipaddr macaddr hostname
|
||||
clients="${macaddr} ${ipaddr} ${hostname};${clients}"
|
||||
json_select ..
|
||||
done
|
||||
|
||||
json_init
|
||||
|
||||
IFS=";"
|
||||
for client in ${clients};
|
||||
do
|
||||
macaddr=$(echo ${client} | cut -d" " -f1)
|
||||
json_add_object "${macaddr//:/_}"
|
||||
json_add_string "ip" "$(echo ${client} | cut -d" " -f2)"
|
||||
json_add_string "macaddr" "$(echo ${client} | cut -d" " -f1)"
|
||||
json_add_string "host" "$(echo ${client} | cut -d" " -f3)"
|
||||
json_close_object
|
||||
done
|
||||
|
||||
IFS=' '
|
||||
echo `json_dump` > ${CLIENT_LIST}
|
||||
json_cleanup
|
||||
}
|
||||
|
||||
# Find the IP of a corresponding mac from arp table
|
||||
get_ipaddress() {
|
||||
local clients ip mac host
|
||||
|
||||
json_load "$(cat ${CLIENT_LIST})"
|
||||
json_get_keys keys
|
||||
|
||||
# jshn seems a bit iffy on having : in key, replace by _
|
||||
json_select "${1//:/_}" 2 > /dev/null
|
||||
json_get_var ip ip
|
||||
|
||||
echo "$ip"
|
||||
}
|
||||
|
||||
check_and_create() {
|
||||
iptables -t mangle -C PREROUTING ${@} 2>/dev/null
|
||||
# Create rule if not exists
|
||||
if [ ${?} -ne 0 ]; then
|
||||
exec_log iptables -t mangle -A PREROUTING ${@}
|
||||
else
|
||||
log "Rule exists for ${@}"
|
||||
fi
|
||||
}
|
||||
|
||||
create_ip_rule() {
|
||||
local proto=$1; shift
|
||||
local src_ip=$1; shift
|
||||
local mark=$1; shift
|
||||
local ports=$1;
|
||||
local cmd="";
|
||||
|
||||
cmd="-j EXTMARK --set-mark ${mark}";
|
||||
if [ "${proto}" != "icmp" ]; then
|
||||
if [ -n "${ports}" ]; then
|
||||
cmd="--match multiport --dports ${ports} ${cmd}";
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${proto}" == "icmp" ]; then
|
||||
cmd="-p icmp -m icmp --icmp-type 8 $cmd"
|
||||
elif [ "${proto}" == "all" ]; then
|
||||
cmd="-p all $cmd"
|
||||
else
|
||||
cmd="-p ${proto} -m ${proto} $cmd"
|
||||
fi
|
||||
cmd="-s ${src_ip} $cmd"
|
||||
|
||||
check_and_create ${cmd}
|
||||
}
|
||||
|
||||
is_lan_bridge() {
|
||||
local _section=$1
|
||||
local _type
|
||||
@@ -67,10 +183,10 @@ get_bridge_interface() {
|
||||
validate_rule_section()
|
||||
{
|
||||
uci_validate_section easy_qos rule "${1}" \
|
||||
'priority:string:none' \
|
||||
'macaddr:string:none' \
|
||||
'priority:string' \
|
||||
'macaddr:string' \
|
||||
'proto:string:none' \
|
||||
'port:list(uinteger):none' \
|
||||
'port:list(uinteger)' \
|
||||
'comment:string:none'
|
||||
}
|
||||
|
||||
@@ -82,8 +198,14 @@ clear_existing_rules() {
|
||||
while read line
|
||||
do
|
||||
log "Deleting old classification rules"
|
||||
exec_log classcfg -D ${line} -i ${BRIDGE_INTF}
|
||||
exec_class_log classcfg -D ${line} -i ${BRIDGE_INTF}
|
||||
done <${RULE_LIST}
|
||||
|
||||
local rule=$(iptables -t mangle -S PREROUTING|grep -m 1 EXTMARK |sed 's/-A/-D/1')
|
||||
while [ -n "${rule}" ]; do
|
||||
exec_log iptables -t mangle ${rule}
|
||||
rule=$(iptables -t mangle -S PREROUTING|grep -m 1 EXTMARK |sed 's/-A/-D/1')
|
||||
done
|
||||
sync
|
||||
|
||||
[ -f ${RULE_LIST} ] && rm ${RULE_LIST}
|
||||
@@ -104,13 +226,16 @@ create_rule() {
|
||||
if [ "${mac_addr}" != "none" ]; then
|
||||
cmd="--smac ${mac_addr} ${cmd}";
|
||||
fi
|
||||
if [ "${ports}" != "none" ]; then
|
||||
IFS=","
|
||||
for port in ${ports};
|
||||
do
|
||||
cmd="--dport ${port}:${port} ${cmd}";
|
||||
done
|
||||
IFS=' '
|
||||
|
||||
if [ "${proto}" != "icmp" ]; then
|
||||
if [ "${ports}" != "none" ]; then
|
||||
IFS=","
|
||||
for port in ${ports};
|
||||
do
|
||||
cmd="--dport ${port}:${port} ${cmd}";
|
||||
done
|
||||
IFS=' '
|
||||
fi
|
||||
fi
|
||||
if [ "${proto}" != "none" ]; then
|
||||
cmd="-p ${proto} $cmd"
|
||||
@@ -119,14 +244,14 @@ create_rule() {
|
||||
cmd="-A ${rule_name} $cmd"
|
||||
|
||||
# Store the rule_names for cleanup on reload
|
||||
exec_log classcfg ${cmd}
|
||||
exec_class_log classcfg ${cmd}
|
||||
[ $? -eq 0 ] && \
|
||||
echo ${rule_name} >> ${RULE_LIST}
|
||||
}
|
||||
|
||||
manage_rule() {
|
||||
local cfg="$1"
|
||||
local priority macaddr proto port comment prio_num port_list
|
||||
local priority macaddr proto port comment prio_num port_list ip ipmark
|
||||
|
||||
validate_rule_section "${1}" || {
|
||||
log "Validation of section failed"
|
||||
@@ -135,22 +260,33 @@ manage_rule() {
|
||||
|
||||
prio_num=$(get_priority ${priority})
|
||||
port_list=$(echo ${port}|sed 's/ /,/g')
|
||||
ipmark=$(get_mark ${priority})
|
||||
ip=$(get_ipaddress ${macaddr})
|
||||
|
||||
if [ -n "${prio_num}" ]; then
|
||||
if [ "${proto}" == "none" -o "${proto}" == "tcpudp" ]; then
|
||||
create_rule tcp ${macaddr} ${prio_num} ${port_list}
|
||||
create_rule udp ${macaddr} ${prio_num} ${port_list}
|
||||
if [ -n "${ip}" ]; then
|
||||
create_ip_rule tcp ${ip} ${ipmark} ${port_list}
|
||||
create_ip_rule udp ${ip} ${ipmark} ${port_list}
|
||||
fi
|
||||
else
|
||||
create_rule ${proto} ${macaddr} ${prio_num} ${port_list}
|
||||
if [ -n "${ip}" ]; then
|
||||
create_ip_rule ${proto} ${ip} ${ipmark} ${port_list}
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
get_bridge_interface
|
||||
map_client_entries
|
||||
clear_existing_rules
|
||||
config_load easy_qos
|
||||
config_foreach manage_rule rule
|
||||
clean_client_entries
|
||||
}
|
||||
|
||||
start_service() {
|
||||
|
||||
@@ -103,18 +103,18 @@ validate_rule_section()
|
||||
|
||||
# Clear existing rules before applying new rules
|
||||
clear_existing_rules() {
|
||||
local rule=$(iptables -t mangle -S OUTPUT|grep -m 1 MARK |sed 's/-A/-D/1')
|
||||
local rule=$(iptables -t mangle -S PREROUTING | grep -m 1 MARK |sed 's/-A/-D/1')
|
||||
while [ -n "${rule}" ]; do
|
||||
exec_log iptables -t mangle ${rule}
|
||||
rule=$(iptables -t mangle -S OUTPUT|grep -m 1 MARK |sed 's/-A/-D/1')
|
||||
rule=$(iptables -t mangle -S PREROUTING | grep -m 1 MARK |sed 's/-A/-D/1')
|
||||
done
|
||||
}
|
||||
|
||||
check_and_create() {
|
||||
iptables -t mangle -C OUTPUT ${@} 2>/dev/null
|
||||
iptables -t mangle -C PREROUTING ${@} 2>/dev/null
|
||||
# Create rule if not exists
|
||||
if [ ${?} -ne 0 ]; then
|
||||
exec_log iptables -t mangle -A OUTPUT ${@}
|
||||
exec_log iptables -t mangle -A PREROUTING ${@}
|
||||
else
|
||||
log "Rule exists for ${@}"
|
||||
fi
|
||||
|
||||
@@ -4,7 +4,5 @@ uci -q batch <<-EOT
|
||||
set firewall.easyqos=include
|
||||
set firewall.easyqos.path=/etc/firewall.easyqos
|
||||
set firewall.easyqos.reload=1
|
||||
uci del_list firewall.easyqos._access_w="root"
|
||||
uci add_list firewall.easyqos._access_w="root"
|
||||
commit firewall
|
||||
EOT
|
||||
|
||||
109
easy-soc-events/Makefile
Executable file
109
easy-soc-events/Makefile
Executable file
@@ -0,0 +1,109 @@
|
||||
# All rights reserved.
|
||||
# See LICENSE for more information.
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=easy-soc-events
|
||||
PKG_VERSION:=1.1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=git@dev.iopsys.eu:iopsys/easy-soc-events.git
|
||||
PKG_SOURCE_VERSION:=5c582b0165b574dc94e4865f82e0bb91fa561754
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/easy-soc-events-$(PKG_VERSION)
|
||||
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
-include $(TOPDIR)/.config
|
||||
|
||||
ifneq ($(CONFIG_TARGET_iopsys_brcm63xx_arm),)
|
||||
LINUX_DIR=$(BUILD_DIR)/bcmkernel/bcm963xx/kernel/linux-4.1
|
||||
LINUX_VERSION := 4.1.52
|
||||
LINUXINCLUDE=-Iarch/$(LINUX_KARCH)/mach-bcm963xx/include
|
||||
BCM_BS_PROFILE := $(patsubst "%",%,$(CONFIG_BCM_KERNEL_PROFILE))
|
||||
FS_DIR := $(BUILD_DIR)/bcmkernel/bcm963xx/targets/$(BCM_BS_PROFILE)/fs
|
||||
MODULES_SUBDIR:=lib/modules/$(LINUX_VERSION)/extra
|
||||
TARGET_MODULES_DIR:=/$(MODULES_SUBDIR)
|
||||
endif
|
||||
|
||||
|
||||
define KernelPackage/easy-soc-events/default
|
||||
SUBMENU:=Other modules
|
||||
endef
|
||||
|
||||
define KernelPackage/easy-soc-events
|
||||
$(KernelPackage/easy-soc-events/default)
|
||||
TITLE:=Helper module for netlink event notification
|
||||
FILES:=$(PKG_BUILD_DIR)/easyevent.ko
|
||||
AUTOLOAD:=$(call AutoLoad,11,easyevent)
|
||||
endef
|
||||
|
||||
define KernelPackage/easy-soc-events-test
|
||||
$(KernelPackage/easy-soc-events/default)
|
||||
TITLE:=Test module for event notification through easyevent
|
||||
DEPENDS+=+kmod-easy-soc-events
|
||||
FILES+=$(PKG_BUILD_DIR)/test/testevent.ko
|
||||
endef
|
||||
|
||||
|
||||
define KernelPackage/easy-soc-events/description
|
||||
This is a helper module to generate and pass netlink events from
|
||||
kernel to user applications.
|
||||
endef
|
||||
|
||||
#NOSTDINC_FLAGS :=
|
||||
|
||||
ifdef CONFIG_PACKAGE_kmod-easy-soc-events
|
||||
PKG_MAKE_FLAGS += CONFIG_EASYEVENT=y
|
||||
endif
|
||||
|
||||
LINUXINCLUDE += \
|
||||
-I$(LINUX_DIR)/include -I$(LINUX_DIR)/include/$(LINUX_UAPI_DIR) \
|
||||
-Iarch/$(LINUX_KARCH)/include \
|
||||
-Iarch/$(LINUX_KARCH)/include/generated \
|
||||
-Iarch/$(LINUX_KARCH)/include/generated/$(LINUX_UAPI_DIR) \
|
||||
-I$(LINUX_DIR)/include/generated/uapi \
|
||||
-Iarch/$(LINUX_KARCH)/include/$(LINUX_UAPI_DIR) \
|
||||
-include ./include/linux/kconfig.h
|
||||
|
||||
|
||||
define Build/Prepare
|
||||
$(call Build/Prepare/Default)
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
|
||||
$(KERNEL_MAKE_FLAGS) V=1 \
|
||||
$(PKG_MAKE_FLAGS) \
|
||||
NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
|
||||
LINUXINCLUDE="$(LINUXINCLUDE)" \
|
||||
SUBDIRS="$(PKG_BUILD_DIR)" \
|
||||
modules
|
||||
endef
|
||||
|
||||
|
||||
ifneq ($(CONFIG_TARGET_iopsys_brcm63xx_arm),)
|
||||
define KernelPackage/easy-soc-events/install-extra
|
||||
cp $(PKG_BUILD_DIR)/easyevent.ko $(FS_DIR)/lib/modules/$(LINUX_VERSION)/extra
|
||||
endef
|
||||
endif
|
||||
|
||||
define KernelPackage/easy-soc-events/install
|
||||
$(call KernelPackage/easy-soc-events/install-extra)
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include
|
||||
#$(INSTALL_DIR) $(STAGING_DIR)/usr/include/linux
|
||||
#$(CP) $(PKG_BUILD_DIR)/easysoc-event.h $(STAGING_DIR)/usr/include/linux/
|
||||
#$(CP) $(PKG_BUILD_DIR)/easysoc-event.h $(LINUX_DIR)/include/linux/
|
||||
$(CP) $(PKG_BUILD_DIR)/easyevent.h $(STAGING_DIR)/usr/include/
|
||||
$(CP) $(PKG_BUILD_DIR)/wifievent.h $(STAGING_DIR)/usr/include/
|
||||
$(CP) $(PKG_BUILD_DIR)/easyevent.h $(LINUX_DIR)/include/generated/uapi
|
||||
$(CP) $(PKG_BUILD_DIR)/wifievent.h $(LINUX_DIR)/include/generated/uapi
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,easy-soc-events-test))
|
||||
$(eval $(call KernelPackage,easy-soc-events))
|
||||
@@ -1,10 +0,0 @@
|
||||
if (PACKAGE_libwifix)
|
||||
menu "configurations"
|
||||
|
||||
config LIBWIFIX_DEBUG
|
||||
depends on PACKAGE_libwifix
|
||||
bool "Enable wifi debugging"
|
||||
default n
|
||||
|
||||
endmenu
|
||||
endif
|
||||
@@ -1,108 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2019 iopsys Software Solutions AB
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=easy-soc-libs.deprecated
|
||||
PKG_VERSION:=1.0.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=b88afddd2f4cb216bfcd190f9096c138299c28e2
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/easy-soc-libs.git
|
||||
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_LICENSE:=GPLv2
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/easy-soc-libs.deprecated
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=IOPSYS easy SoC libraries (deprecated)
|
||||
SUBMENU:=IOPSYS easy SoC libraries (deprecated)
|
||||
DEPENDS:=+libopenssl
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
define Package/libwifix/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
define Package/libwifix
|
||||
$(call Package/easy-soc-libs.deprecated)
|
||||
TITLE:= WiFi library for wifix (deprecated)
|
||||
DEPENDS+=+libnl +libnl-route
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_TARGET_iopsys_brcm63xx_mips),y)
|
||||
TARGET_PLATFORM=BROADCOM
|
||||
TARGET_CFLAGS +=-DIOPSYS_BROADCOM -DCONFIG_BCM963138 \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx
|
||||
KERNEL_DIR:=$(BUILD_DIR)/bcmkernel/bcm963xx
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_brcm63xx_arm),y)
|
||||
TARGET_PLATFORM=BROADCOM
|
||||
TARGET_CFLAGS +=-DIOPSYS_BROADCOM -DCONFIG_BCM963138 \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_ramips),y)
|
||||
TARGET_PLATFORM=MEDIATEK
|
||||
TARGET_CFLAGS +=-DIOPSYS_MEDIATEK
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_linksys),y)
|
||||
TARGET_PLATFORM=MARVELL
|
||||
TARGET_CFLAGS +=-DIOPSYS_MARVELL
|
||||
else ifeq ($(CONFIG_TARGET_intel_mips),y)
|
||||
TARGET_PLATFORM=INTEL
|
||||
TARGET_CFLAGS +=-DIOPSYS_INTEL
|
||||
else
|
||||
$(info Unexpected CONFIG_TARGET)
|
||||
endif
|
||||
|
||||
export TARGET_PLATFORM
|
||||
|
||||
ifdef CONFIG_LIBWIFIX_DEBUG
|
||||
TARGET_CFLAGS += -DIOP_LLA_LIBS_DEBUG
|
||||
endif
|
||||
|
||||
subdirs := \
|
||||
$(if $(CONFIG_PACKAGE_libwifix),libwifix)
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-I$(STAGING_DIR)/usr/include \
|
||||
-I$(STAGING_DIR)/usr/include/openssl \
|
||||
-I$(STAGING_DIR)/usr/include/libnl3
|
||||
|
||||
MAKE_FLAGS += \
|
||||
CFLAGS="$(TARGET_CFLAGS) -Wall -I./" \
|
||||
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||
FPIC="$(FPIC)" \
|
||||
PLATFORM="$(TARGET_PLATFORM)" \
|
||||
subdirs="$(subdirs)"
|
||||
|
||||
define Build/InstallDev/libwifix
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifix/wifi.h $(1)/usr/include/wifix.h
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifix/libwifi*.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(call Build/Compile/Default)
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(foreach dir,$(subdirs),$(call Build/InstallDev/$(dir),$(1),$(2));)
|
||||
endef
|
||||
|
||||
define Package/libwifix/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifix/libwifi*.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libwifix))
|
||||
@@ -1,19 +1,19 @@
|
||||
#
|
||||
# Copyright (C) 2019 iopsys Software Solutions AB
|
||||
# Copyright (C) 2020 iopsys Software Solutions AB
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
#
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=easy-soc-libs
|
||||
PKG_VERSION:=2.4.0
|
||||
PKG_VERSION:=6.0.2
|
||||
PKG_RELEASE:=1
|
||||
|
||||
LOCAL_DEV=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=30f5527ae724d54537c803127e11992d1a5ae154
|
||||
PKG_SOURCE_VERSION:=fee575f414324c68d0916fab06d10eccb78541fd
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/easy-soc-libs.git
|
||||
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
|
||||
@@ -39,26 +39,28 @@ define Package/libwifi/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
define Package/libeasy
|
||||
$(call Package/easy-soc-libs)
|
||||
TITLE:= Common helper functions library (libeasy)
|
||||
DEPENDS+=+libnl +libnl-route
|
||||
endef
|
||||
|
||||
define Package/libwifi
|
||||
$(call Package/easy-soc-libs)
|
||||
TITLE:= WiFi library (libwifi)
|
||||
DEPENDS+=+libnl +libnl-route
|
||||
DEPENDS+=+libnl +libnl-route +libeasy
|
||||
endef
|
||||
|
||||
define Package/libethernet
|
||||
$(call Package/easy-soc-libs)
|
||||
TITLE:= Ethernet library (libethernet)
|
||||
DEPENDS+=+TARGET_iopsys_ramips:swconfig
|
||||
DEPENDS+=+libnl +libnl-route +libeasy +TARGET_iopsys_ramips:swconfig
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_TARGET_iopsys_brcm63xx_mips),y)
|
||||
ifeq ($(CONFIG_TARGET_iopsys_brcm63xx_arm),y)
|
||||
TARGET_PLATFORM=BROADCOM
|
||||
TARGET_CFLAGS +=-DIOPSYS_BROADCOM -DCONFIG_BCM963138 \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx
|
||||
KERNEL_DIR:=$(BUILD_DIR)/bcmkernel/bcm963xx
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_brcm63xx_arm),y)
|
||||
TARGET_PLATFORM=BROADCOM
|
||||
TARGET_CFLAGS +=-DIOPSYS_BROADCOM -DCONFIG_BCM963138 \
|
||||
CHIP_ID=$(patsubst "%",%,$(CONFIG_BCM_CHIP_ID))
|
||||
TARGET_CFLAGS +=-DIOPSYS_BROADCOM -DCHIP_$(CHIP_ID) -DCONFIG_BCM9$(CHIP_ID) \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_ramips),y)
|
||||
TARGET_PLATFORM=MEDIATEK
|
||||
@@ -69,6 +71,12 @@ else ifeq ($(CONFIG_TARGET_iopsys_linksys),y)
|
||||
else ifeq ($(CONFIG_TARGET_intel_mips),y)
|
||||
TARGET_PLATFORM=INTEL
|
||||
TARGET_CFLAGS +=-DIOPSYS_INTEL
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_x86),y)
|
||||
TARGET_PLATFORM=TEST
|
||||
TARGET_CFLAGS +=-DIOPSYS_TEST
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_armvirt),y)
|
||||
TARGET_PLATFORM=TEST
|
||||
TARGET_CFLAGS +=-DIOPSYS_TEST
|
||||
else
|
||||
$(info Unexpected CONFIG_TARGET)
|
||||
endif
|
||||
@@ -86,6 +94,7 @@ define Package/libdsl
|
||||
endef
|
||||
|
||||
subdirs := \
|
||||
$(if $(CONFIG_PACKAGE_libeasy),libeasy) \
|
||||
$(if $(CONFIG_PACKAGE_libwifi),libwifi) \
|
||||
$(if $(CONFIG_PACKAGE_libdsl),libdsl) \
|
||||
$(if $(CONFIG_PACKAGE_libethernet),libethernet)
|
||||
@@ -108,6 +117,16 @@ define Build/Prepare
|
||||
endef
|
||||
endif
|
||||
|
||||
define Build/InstallDev/libeasy
|
||||
$(INSTALL_DIR) $(1)/usr/include/easy
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libeasy/easy.h $(1)/usr/include/easy/
|
||||
$(CP) $(PKG_BUILD_DIR)/libeasy/event.h $(1)/usr/include/easy/
|
||||
$(CP) $(PKG_BUILD_DIR)/libeasy/utils.h $(1)/usr/include/easy/
|
||||
$(CP) $(PKG_BUILD_DIR)/libeasy/debug.h $(1)/usr/include/easy/
|
||||
$(CP) $(PKG_BUILD_DIR)/libeasy/libeasy*.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Build/InstallDev/libwifi
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
@@ -116,9 +135,11 @@ define Build/InstallDev/libwifi
|
||||
endef
|
||||
|
||||
define Build/InstallDev/libdsl
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/include/xdsl
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libdsl/xdsl.h $(1)/usr/include/
|
||||
$(CP) $(PKG_BUILD_DIR)/libdsl/xdsl.h $(1)/usr/include/xdsl
|
||||
$(CP) $(PKG_BUILD_DIR)/libdsl/xtm.h $(1)/usr/include/xdsl
|
||||
$(CP) $(PKG_BUILD_DIR)/libdsl/common.h $(1)/usr/include/xdsl
|
||||
$(CP) $(PKG_BUILD_DIR)/libdsl/libdsl.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
@@ -140,6 +161,11 @@ define Build/InstallDev
|
||||
$(foreach dir,$(subdirs),$(call Build/InstallDev/$(dir),$(1),$(2));)
|
||||
endef
|
||||
|
||||
define Package/libeasy/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libeasy/libeasy*.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/libwifi/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libwifi/libwifi*.so* $(1)/usr/lib/
|
||||
@@ -159,6 +185,11 @@ ifeq ($(CONFIG_LIBDSL_TEST),y)
|
||||
endif
|
||||
endef
|
||||
|
||||
define Package/easy-soc-libs/install
|
||||
:
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libeasy))
|
||||
$(eval $(call BuildPackage,libwifi))
|
||||
$(eval $(call BuildPackage,libdsl))
|
||||
$(eval $(call BuildPackage,libethernet))
|
||||
|
||||
@@ -7,31 +7,40 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=0.2
|
||||
PKG_SOURCE_VERSION:=631e61b7ab5d86f2f4c86756a117badff9fb0f2c
|
||||
|
||||
PKG_VERSION:=0.4
|
||||
PKG_SOURCE_VERSION:=d87c1def50d9672dbeb9d5972f36a364b29334b9
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
ifeq ($(CONFIG_ENDPT_OPEN),y)
|
||||
BRCM_KERNEL_PROFILE=$(shell echo $(CONFIG_BCM_KERNEL_PROFILE) | sed s/\"//g)
|
||||
PKG_SOURCE:=endptmngr-$(BRCM_KERNEL_PROFILE)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://download.iopsys.eu/iopsys/opensdk/
|
||||
PKG_SOURCE_URL:=https://download.iopsys.eu/iopsys/opensdk/
|
||||
PKG_NAME:=endptmngr-open
|
||||
PATCH_DIR:=
|
||||
PKG_HASH:=skip
|
||||
else
|
||||
PKG_SOURCE_URL:=git@dev.iopsys.eu:iopsys/endptmngr
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/endptmngr.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_NAME:=endptmngr
|
||||
|
||||
PKG_LICENSE:=GPLv2
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
endif
|
||||
|
||||
RSTRIP:=true
|
||||
export BUILD_DIR
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
# All config variable that are passed to the make invocation, directly or
|
||||
# indirectly. This ensures that the package is rebuilt on config-changes.
|
||||
PKG_CONFIG_DEPENDS := \
|
||||
CONFIG_TARGET_BOARD
|
||||
|
||||
export CONFIG_BRCM_SDK_VER_504001
|
||||
export CONFIG_BRCM_SDK_VER_504002
|
||||
export CONFIG_BRCM_SDK_VER_504003
|
||||
export CONFIG_BRCM_SDK_VER_504004
|
||||
export CONFIG_BRCM_SDK_VER_504005
|
||||
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
@@ -44,7 +53,7 @@ define Package/endptmngr
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Brcmslic
|
||||
URL:=
|
||||
DEPENDS:= +libubox +ubus +libpicoevent +PACKAGE_bcmkernel:bcmkernel +PACKAGE_bcmopen:bcmopen
|
||||
DEPENDS:= +libubox +ubus +libpicoevent +bcmkernel @TARGET_HAS_VOICE @BCM_VOICE
|
||||
endef
|
||||
|
||||
define Package/endptmngr/description
|
||||
|
||||
45
ethmngr/Makefile
Normal file
45
ethmngr/Makefile
Normal file
@@ -0,0 +1,45 @@
|
||||
#
|
||||
# Copyright (C) 2020 Iopsys
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ethmngr
|
||||
PKG_VERSION:=1.0.4
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=b7135381aedf1bde6f7ab10b41be372a9bd7d155
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/ethmngr.git
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_LICENSE:=GPL-2.0-only
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ethmngr
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Ethernet status and configration utility
|
||||
DEPENDS:=+libethernet +libuci +libubox +ubus +libpthread +libnl-genl
|
||||
endef
|
||||
|
||||
define Package/ethmngr/description
|
||||
This package can be used to configure and provide status about
|
||||
the ethernet interfaces and ports through UBUS.
|
||||
It uses APIs from the libethernet.so library.
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-I$(STAGING_DIR)/usr/include \
|
||||
-I$(STAGING_DIR)/usr/include/libnl3 \
|
||||
-D_GNU_SOURCE
|
||||
|
||||
define Package/ethmngr/install
|
||||
$(INSTALL_DIR) $(1)/etc/init.d $(1)/usr/sbin
|
||||
$(INSTALL_BIN) ./files/ethmngr.init $(1)/etc/init.d/ethmngr
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ethmngr $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ethmngr))
|
||||
@@ -1,15 +1,14 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=96
|
||||
START=95
|
||||
STOP=10
|
||||
|
||||
USE_PROCD=1
|
||||
PROG=/usr/sbin/wifixd
|
||||
PROG=/usr/sbin/ethmngr
|
||||
|
||||
start_service() {
|
||||
procd_open_instance
|
||||
procd_set_param command ${PROG}
|
||||
# procd_set_param env IOP_LLA_LIBS_DEBUG=3 #for debugging only
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2016 Nikil Mehta <nikil.mehta@gmail.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fping
|
||||
PKG_VERSION:=4.0
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://fping.org/dist/
|
||||
PKG_HASH:=67eb4152b98ad34f99d2eec4e1098a0bb52caf13c0c89cd147349d08190fe8ce
|
||||
|
||||
PKG_MAINTAINER:=Nikil Mehta <nikil.mehta@gmail.com>
|
||||
PKG_LICENSE:=BSD-4-Clause
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/fping
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=sends ICMP ECHO_REQUEST packets to network hosts
|
||||
URL:=http://fping.org/
|
||||
endef
|
||||
|
||||
|
||||
define Package/fping/description
|
||||
fping is a ping like program which uses the Internet Control Message Protocol
|
||||
(ICMP) echo request to determine if a target host is responding. fping
|
||||
differs from ping in that you can specify any number of targets on the command
|
||||
line, or specify a file containing the lists of targets to ping. Instead of
|
||||
sending to one target until it times out or replies, fping will send out a
|
||||
ping packet and move on to the next target in a round-robin fashion.
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS+= \
|
||||
--enable-ipv4 \
|
||||
--enable-ipv6
|
||||
|
||||
TARGET_CFLAGS += -std=gnu99
|
||||
|
||||
define Package/fping/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/fping $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,fping))
|
||||
@@ -129,6 +129,8 @@ static int canyon_led_probe(struct platform_device *pdev)
|
||||
if (ret < 0) {
|
||||
dev_warn(&pdev->dev, "Could not read led-count property\n");
|
||||
leds->led_count = SK9822_DEFAULT_NUM_LEDS;
|
||||
} else {
|
||||
printk(KERN_INFO "Got led count: %u\n", leds->led_count);
|
||||
}
|
||||
|
||||
leds->led_colors = devm_kzalloc(&pdev->dev,
|
||||
@@ -140,7 +142,7 @@ static int canyon_led_probe(struct platform_device *pdev)
|
||||
|
||||
platform_set_drvdata(pdev, leds);
|
||||
|
||||
#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 16, 0)
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
|
||||
leds->clock_gpio = gpiod_get_index(&pdev->dev, "led", 0);
|
||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
|
||||
leds->clock_gpio = gpiod_get_index(&pdev->dev, "led", 0, GPIOD_OUT_HIGH);
|
||||
@@ -148,6 +150,12 @@ static int canyon_led_probe(struct platform_device *pdev)
|
||||
dev_warn(&pdev->dev, "Kernel version Not supported\n");
|
||||
exit(1);
|
||||
#endif
|
||||
if (IS_ERR(leds->clock_gpio)) {
|
||||
dev_err(&pdev->dev, "Failed to acquire clock GPIO %ld\n",
|
||||
PTR_ERR(leds->clock_gpio));
|
||||
leds->clock_gpio = NULL;
|
||||
return PTR_ERR(leds->clock_gpio);
|
||||
}
|
||||
|
||||
gpiod_direction_output(leds->clock_gpio, 1);
|
||||
if (IS_ERR(leds->clock_gpio)) {
|
||||
@@ -160,7 +168,7 @@ static int canyon_led_probe(struct platform_device *pdev)
|
||||
gpiod_set_value(leds->clock_gpio, 0);
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 16, 0)
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
|
||||
leds->data_gpio = gpiod_get_index(&pdev->dev, "led", 1);
|
||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
|
||||
leds->data_gpio = gpiod_get_index(&pdev->dev, "led", 1, GPIOD_OUT_HIGH);
|
||||
@@ -168,6 +176,12 @@ static int canyon_led_probe(struct platform_device *pdev)
|
||||
dev_warn(&pdev->dev, "Kernel version Not supported\n");
|
||||
exit(1);
|
||||
#endif
|
||||
if (IS_ERR(leds->data_gpio)) {
|
||||
dev_err(&pdev->dev, "Failed to acquire data GPIO %ld\n",
|
||||
PTR_ERR(leds->data_gpio));
|
||||
leds->data_gpio = NULL;
|
||||
return PTR_ERR(leds->data_gpio);
|
||||
}
|
||||
|
||||
gpiod_direction_output(leds->data_gpio, 1);
|
||||
if (IS_ERR(leds->data_gpio)) {
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2019 iopsys Software Solutions AB
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=icgroupd
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=0
|
||||
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
PKG_LICENSE_FILES:=
|
||||
|
||||
PKG_MAINTAINER:=Inteno Broadband AB
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/icgroupd
|
||||
SECTION:=base
|
||||
CATEGORY:=Base system
|
||||
TITLE:=Inteno cgroup daemon
|
||||
DEPENDS:=+uci +busybox
|
||||
endef
|
||||
|
||||
define Package/icgroupd/description
|
||||
This package contains Intenos cgroup daemon and associated
|
||||
configuration and startup scripts.
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
true
|
||||
endef
|
||||
|
||||
define Package/icgroupd/install
|
||||
$(INSTALL_DIR) $(1)/sbin $(1)/etc/init.d $(1)/etc/config
|
||||
|
||||
$(INSTALL_CONF) ./files/cgroups.config $(1)/etc/config/cgroups
|
||||
$(INSTALL_BIN) ./files/cgroups.init $(1)/etc/init.d/cgroups
|
||||
$(INSTALL_BIN) ./files/cgroupd $(1)/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,icgroupd))
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
CGBASEDIR=$1
|
||||
CGCONFIG=$2
|
||||
[ -n "$CGBASEDIR" -a -n "$CGCONFIG" ] || exit 1
|
||||
|
||||
[ -r /lib/functions.sh ] || exit 1
|
||||
. /lib/functions.sh
|
||||
|
||||
CGPROCMAP=/tmp/cgprocmap
|
||||
CGPERIOD=3s
|
||||
|
||||
DBGLOG=/tmp/cgroupd.log
|
||||
DEBUG=0
|
||||
|
||||
|
||||
add_to_procmap () {
|
||||
local name_grp=$1
|
||||
local name grp
|
||||
|
||||
name=$(echo $name_grp |awk -F= '{print $1}')
|
||||
grp=$(echo $name_grp |awk -F= '{print $2}')
|
||||
|
||||
echo "($name) $grp" >> $CGPROCMAP
|
||||
}
|
||||
|
||||
# Read configuration file and create process:group look-up table
|
||||
# in /tmp file
|
||||
read_config () {
|
||||
local enab
|
||||
|
||||
config_load $CGCONFIG
|
||||
|
||||
config_get enab cgroups enabled "1"
|
||||
[ $enab -eq 0 ] && exit 1
|
||||
|
||||
config_get CGDEFGROUP cgroups defgroup "_undef_"
|
||||
[ "$CGDEFGROUP" == "_undef_" ] && exit 1
|
||||
[ "$DEBUG" == "1" ] && echo "default $CGDEFGROUP" >> $DBGLOG
|
||||
|
||||
echo -n '' > $CGPROCMAP
|
||||
config_list_foreach procmap procmap add_to_procmap
|
||||
[ "$DEBUG" == "1" ] && cat $CGPROCMAP >> $DBGLOG
|
||||
}
|
||||
|
||||
# Move all process except init from cgroup root to cgroups according
|
||||
# to /tmp look-up table
|
||||
move_wild_procs () {
|
||||
local wild_procs=$(cat $CGBASEDIR/cgroup.procs)
|
||||
local pid name grp
|
||||
|
||||
for pid in $wild_procs; do
|
||||
|
||||
[ $pid -eq 1 ] && continue
|
||||
if [ -d /proc/$pid ]; then
|
||||
|
||||
name=$(awk '{print $2}' /proc/$pid/stat)
|
||||
grp=$(awk "\$1==\"$name\" {print \$2}" $CGPROCMAP)
|
||||
|
||||
[ "$grp" == "." ] && continue
|
||||
[ -n "$grp" ] || grp=$CGDEFGROUP
|
||||
|
||||
[ "$DEBUG" == "1" ] && \
|
||||
echo "Moving proc $pid $name to $grp" >> $DBGLOG
|
||||
echo $pid > $CGBASEDIR/$grp/cgroup.procs
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
[ "$DEBUG" == "1" ] && echo "$0 started $(date)" >> $DBGLOG
|
||||
read_config
|
||||
while true; do
|
||||
move_wild_procs
|
||||
sleep $CGPERIOD
|
||||
done
|
||||
@@ -1,48 +0,0 @@
|
||||
config cgroups cgroups
|
||||
option enabled 1
|
||||
option defgroup iopsys/normal
|
||||
|
||||
config cgroup _root_
|
||||
# list option cpu.rt_runtime_us=50000
|
||||
list option memory.move_charge_at_immigrate=1
|
||||
|
||||
config cgroup iopsys
|
||||
list option cpu.shares=4096
|
||||
# list option cpu.rt_runtime_us=40000
|
||||
list option memory.limit_in_bytes=-1
|
||||
list option memory.move_charge_at_immigrate=1
|
||||
|
||||
config cgroup iopsys_normal
|
||||
list option cpu.shares=1024
|
||||
# list option cpu.rt_runtime_us=10000
|
||||
list option memory.limit_in_bytes=-1
|
||||
list option memory.move_charge_at_immigrate=1
|
||||
|
||||
config cgroup iopsys_high
|
||||
list option cpu.shares=4096
|
||||
# list option cpu.rt_runtime_us=30000
|
||||
list option memory.limit_in_bytes=-1
|
||||
list option memory.move_charge_at_immigrate=1
|
||||
|
||||
config cgroup 3prt
|
||||
list option cpu.shares=1024
|
||||
# list option cpu.rt_runtime_us=10000
|
||||
list option memory.limit_in_bytes=75M
|
||||
list option memory.move_charge_at_immigrate=1
|
||||
|
||||
config cgroup 3prt_normal
|
||||
list option cpu.shares=1024
|
||||
# list option cpu.rt_runtime_us=2500
|
||||
list option memory.limit_in_bytes=75M
|
||||
list option memory.move_charge_at_immigrate=1
|
||||
|
||||
config cgroup 3prt_high
|
||||
list option cpu.shares=4096
|
||||
# list option cpu.rt_runtime_us=7500
|
||||
list option memory.limit_in_bytes=75M
|
||||
list option memory.move_charge_at_immigrate=1
|
||||
|
||||
config procmap procmap
|
||||
list procmap kthreadd=.
|
||||
list procmap minidlna=3prt/normal
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=01
|
||||
USE_PROCD=1
|
||||
PROCD_DEBUG=1
|
||||
NAME=cgroupd
|
||||
|
||||
CGBASEDIR=/sys/fs/cgroup
|
||||
CGCONFIG="cgroups"
|
||||
|
||||
DBGLOG=/tmp/cginit.log
|
||||
DEBUG=0
|
||||
|
||||
|
||||
cgroupinit_set_knob_value () {
|
||||
local knob_val=$1
|
||||
local dir=$2
|
||||
local knob val
|
||||
|
||||
knob=$(echo $knob_val |awk -F= '{print $1}')
|
||||
val=$(echo $knob_val |awk -F= '{print $2}')
|
||||
/bin/echo $val > $CGBASEDIR/$dir/$knob
|
||||
[ "$DEBUG" == "1" ] && \
|
||||
echo "/bin/echo $val > $CGBASEDIR/$dir/$knob (ret=$?)" >> $DBGLOG
|
||||
}
|
||||
|
||||
cgroupinit_create_group () {
|
||||
local cgrp=$1
|
||||
local dir
|
||||
|
||||
[ "$DEBUG" == "1" ] && echo "Create group $cgrp:" >> $DBGLOG
|
||||
if [ "$cgrp" == "_root_" ]; then
|
||||
dir=.
|
||||
else
|
||||
dir=$(echo $cgrp |tr '_' '/')
|
||||
|
||||
if [ ! -d $CGBASEDIR/$dir ]; then
|
||||
mkdir $CGBASEDIR/$dir
|
||||
[ "$DEBUG" == "1" ] && \
|
||||
echo "mkdir $CGBASEDIR/$dir (ret=$?)" >> $DBGLOG
|
||||
fi
|
||||
fi
|
||||
|
||||
config_list_foreach $cgrp option cgroupinit_set_knob_value $dir
|
||||
}
|
||||
|
||||
cgroupinit_configure_cgroups () {
|
||||
local enab defgrp
|
||||
|
||||
[ "$DEBUG" == "1" ] && echo "$0 started $(date)" >> $DBGLOG
|
||||
config_load $CGCONFIG
|
||||
|
||||
config_get enab cgroups enabled "1"
|
||||
[ $enab -eq 0 ] && return 1
|
||||
|
||||
config_get defgrp cgroups defgroup "_undef_"
|
||||
[ "$defgrp" == "_undef_" ] && return 1
|
||||
|
||||
if ! grep -q " $CGBASEDIR cgroup " /proc/mounts; then
|
||||
mount -t cgroup -o nodev,noexec,nosuid cgroup $CGBASEDIR
|
||||
[ $? -eq 0 ] || return 1
|
||||
fi
|
||||
|
||||
config_foreach cgroupinit_create_group cgroup
|
||||
return 0
|
||||
}
|
||||
|
||||
start_service () {
|
||||
cgroupinit_configure_cgroups
|
||||
[ $? -eq 0 ] || return
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command /sbin/cgroupd $CGBASEDIR $CGCONFIG
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop_service () {
|
||||
local cgdir procs prc
|
||||
|
||||
for cgdir in $(find $CGBASEDIR -type d -mindepth 1 -depth); do
|
||||
procs=$(cat $cgdir/cgroup.procs)
|
||||
for prc in $procs; do
|
||||
echo $prc > $CGBASEDIR/cgroup.procs
|
||||
done
|
||||
rmdir $cgdir
|
||||
done
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger $CGCONFIG
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if PACKAGE_icwmp-curl || PACKAGE_icwmp-zstream
|
||||
if PACKAGE_icwmp
|
||||
|
||||
config CWMP_SCRIPTS_FULL
|
||||
bool "Install all icwmp scripts"
|
||||
@@ -22,6 +22,6 @@ config CWMP_DEBUG
|
||||
config CWMP_DEVEL_DEBUG
|
||||
bool "Compile with development debug options"
|
||||
default n
|
||||
|
||||
|
||||
endif
|
||||
|
||||
|
||||
160
icwmp/Makefile
160
icwmp/Makefile
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2019 iopsys Software Solutions AB
|
||||
# Copyright (C) 2020 iopsys Software Solutions AB
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
@@ -8,11 +8,11 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=icwmp
|
||||
PKG_VERSION:=4.0-2019-10-01
|
||||
PKG_VERSION:=6.2-2020-12-17
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/icwmp.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=ed781436f96f2dc3cf58b35adc640c6f9f6783d1
|
||||
PKG_SOURCE_VERSION:=80382e4dc769fa5eccd819d9a63ec59826f1bd36
|
||||
PKG_RELEASE=$(PKG_SOURCE_VERSION)
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
@@ -26,73 +26,25 @@ PKG_CONFIG_DEPENDS:= \
|
||||
CONFIG_CWMP_DEBUG \
|
||||
CONFIG_CWMP_DEVEL_DEBUG
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
CWMP_REVISION=$(shell svnversion ./src/ -n|cut -f2 -d:)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/icwmp_stun
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=TR-069 stun Client
|
||||
DEPENDS:=+libubus +libuci +libubox +libjson-c +libopenssl +libblobmsg-json
|
||||
endef
|
||||
|
||||
define Package/icwmp_xmpp
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=TR-069 xmpp feature
|
||||
DEPENDS:=+libuci +libubox +libexpat +libstrophe
|
||||
endef
|
||||
|
||||
define Package/icwmp_twamp
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=TR-069 twamp feature
|
||||
DEPENDS:=+libuci
|
||||
endef
|
||||
|
||||
define Package/icwmp_udpechoserver
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=TR-069 udpechoserver feature
|
||||
DEPENDS:=+libuci
|
||||
endef
|
||||
|
||||
define Package/icwmp_bulkdata
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=TR-069 BulkData Collection
|
||||
DEPENDS:=+libubus +libuci +libubox +libjson-c +libcurl +curl +libblobmsg-json +libbbfdm
|
||||
endef
|
||||
|
||||
define Package/icwmp/Default
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=TRx69
|
||||
TITLE:=CWMP client
|
||||
DEPENDS:=+libuci +libmicroxml +libubox +jshn +libubus +libblobmsg-json +libpthread +ubusd +shflags +getopt +zlib +libjson-c +libopenssl +curl +libbbfdm +(PACKAGE_libtr098):libtr098
|
||||
DEPENDS:=+libuci +libmicroxml +libubox +jshn +libubus +libblobmsg-json +libpthread +ubusd +shflags +getopt +zlib +libjson-c +libopenssl +curl +libcurl +libbbfdm +libbbf_api
|
||||
endef
|
||||
|
||||
define Package/icwmp/description
|
||||
define Package/$(PKG_NAME)/description
|
||||
A free client implementation of CWMP (TR-069) protocol
|
||||
endef
|
||||
|
||||
define Package/icwmp-curl
|
||||
$(call Package/icwmp/Default)
|
||||
TITLE+= (using libcurl)
|
||||
DEPENDS+= +libcurl
|
||||
VARIANT:=curl
|
||||
endef
|
||||
|
||||
define Package/icwmp-zstream
|
||||
$(call Package/icwmp/Default)
|
||||
TITLE+= (using libzstream)
|
||||
DEPENDS+= +libzstream
|
||||
VARIANT:=zstream
|
||||
endef
|
||||
|
||||
define Package/icwmp-zstream/config
|
||||
define Package/$(PKG_NAME)/config
|
||||
source "$(SOURCE)/Config_cwmp.in"
|
||||
endef
|
||||
|
||||
@@ -103,10 +55,6 @@ define Build/Prepare
|
||||
endef
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_TARGET_iopsys_ramips),y)
|
||||
TARGET_CFLAGS += -DEX400
|
||||
endif
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-D_GNU_SOURCE -D_AADJ
|
||||
|
||||
@@ -126,17 +74,6 @@ CONFIGURE_ARGS += \
|
||||
--with-uci-include-path=$(STAGING_DIR)/usr/include \
|
||||
--with-libubox-include-path=$(STAGING_DIR)/usr/include \
|
||||
--with-libubus-include-path=$(STAGING_DIR)/usr/include
|
||||
|
||||
ifeq ($(BUILD_VARIANT),zstream)
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-http=zstream \
|
||||
--with-zstream-include-path=$(STAGING_DIR)/usr/include
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_VARIANT),curl)
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-http=curl
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CWMP_ACS_MULTI),y)
|
||||
CONFIGURE_ARGS += \
|
||||
@@ -158,28 +95,10 @@ CONFIGURE_ARGS += \
|
||||
--enable-devel
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_PACKAGE_libtr098),y)
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-tr098
|
||||
endif
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-tr181
|
||||
|
||||
define Package/icwmp-$(BUILD_VARIANT)/install
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/etc/icwmpd
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(CP) $(PKG_BUILD_DIR)/bin/icwmpd $(1)/usr/sbin
|
||||
ifeq ($(CONFIG_PACKAGE_libtr098),y)
|
||||
$(CP) $(PKG_BUILD_DIR)/bin/icwmp_tr098d $(1)/usr/sbin
|
||||
endif
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/config/cwmp $(1)/etc/config
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/config/firewall.cwmp $(1)/etc/firewall.cwmp
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init/icwmpd.init $(1)/etc/init.d/icwmpd
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/uci-defaults/90-cwmpfirewall $(1)/etc/uci-defaults/90-cwmpfirewall
|
||||
ifeq ($(CONFIG_CWMP_SCRIPTS_FULL),y)
|
||||
$(INSTALL_DIR) $(1)/usr/share/icwmp
|
||||
$(CP) $(PKG_BUILD_DIR)/scripts/defaults $(1)/usr/share/icwmp
|
||||
@@ -190,55 +109,8 @@ endif
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
|
||||
define Package/icwmp_stun/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/icwmp_stund $(1)/usr/sbin/icwmp_stund
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init/icwmp_stund $(1)/etc/init.d/icwmp_stund
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/config/cwmp_stun $(1)/etc/config
|
||||
endef
|
||||
|
||||
define Package/icwmp_xmpp/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/icwmp_xmppd $(1)/usr/sbin/icwmp_xmppd
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init/icwmp_xmppd $(1)/etc/init.d/icwmp_xmppd
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/config/cwmp_xmpp $(1)/etc/config
|
||||
$(CP) ./xmpp-files/* $(1)/
|
||||
endef
|
||||
|
||||
define Package/icwmp_udpechoserver/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/icwmp_udpechoserverd $(1)/usr/sbin/icwmp_udpechoserverd
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init/icwmp_udpechoserverd $(1)/etc/init.d/icwmp_udpechoserverd
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/config/cwmp_udpechoserver $(1)/etc/config
|
||||
endef
|
||||
|
||||
define Package/icwmp_twamp/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/icwmp_twampd $(1)/usr/sbin/icwmp_twampd
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init/icwmp_twampd $(1)/etc/init.d/icwmp_twampd
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/config/cwmp_twamp $(1)/etc/config
|
||||
endef
|
||||
|
||||
define Package/icwmp_bulkdata/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/icwmp_bulkdatad $(1)/usr/sbin/icwmp_bulkdatad
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init/icwmp_bulkdatad $(1)/etc/init.d/icwmp_bulkdatad
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/config/cwmp_bulkdata $(1)/etc/config
|
||||
endef
|
||||
|
||||
define Package/icwmp-$(BUILD_VARIANT)/postinst
|
||||
define Package/$(PKG_NAME)/postinst
|
||||
#!/bin/sh
|
||||
echo "$(CWMP_BKP_FILE)" >> $${IPKG_INSTROOT}/etc/sysupgrade.conf
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
echo "Enabling rc.d symlink for icwmpd"
|
||||
/etc/init.d/icwmpd enable
|
||||
@@ -246,7 +118,7 @@ define Package/icwmp-$(BUILD_VARIANT)/postinst
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Package/icwmp-$(BUILD_VARIANT)/prerm
|
||||
define Package/$(PKG_NAME)/prerm
|
||||
#!/bin/sh
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
echo "Disabling rc.d symlink for icwmpd"
|
||||
@@ -255,10 +127,4 @@ define Package/icwmp-$(BUILD_VARIANT)/prerm
|
||||
exit 0
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,icwmp-curl))
|
||||
$(eval $(call BuildPackage,icwmp_stun))
|
||||
$(eval $(call BuildPackage,icwmp_xmpp))
|
||||
$(eval $(call BuildPackage,icwmp_udpechoserver))
|
||||
$(eval $(call BuildPackage,icwmp_twamp))
|
||||
$(eval $(call BuildPackage,icwmp_bulkdata))
|
||||
$(eval $(call BuildPackage,icwmp-zstream))
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
|
||||
136
icwmp/README
136
icwmp/README
@@ -1,136 +0,0 @@
|
||||
1)Build
|
||||
Requirements<74>:
|
||||
librairies:
|
||||
- libuci.so
|
||||
- libexpat.so
|
||||
- libcurl.so
|
||||
- libpthread.so
|
||||
- libopenssl.so
|
||||
- libz.so
|
||||
- libcrypto.so
|
||||
the librairies should be present in the "staging_dir/target-i386_uClibc-0.9.30.1/usr/lib/" or "staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/lib"
|
||||
|
||||
header files and folders:
|
||||
- expat.h
|
||||
- expat_external.h
|
||||
- uci.h
|
||||
- uci_config.h
|
||||
- zlib.h
|
||||
- curl folder
|
||||
- openssl folder
|
||||
the header files and folders should be present in the staging_dir/target-i386_uClibc-0.9.30.1/usr/include/ or staging_dir/toolchain-i386_gcc-4.1.2_uClibc-0.9.30.1/usr/include/
|
||||
|
||||
|
||||
if a librairie doesn't exist:
|
||||
a- run make menuconfig and select the librarie
|
||||
b- build the librarie package
|
||||
|
||||
2) Build
|
||||
|
||||
this software is composed of 3 packages:
|
||||
- icwmp package: contains icwmpd daemon
|
||||
- cwmp lib package: contains cwmplib and contains cwmp_value_change binary. They could be used by other user space applications in order to notify the icwmp daemon when paramter changes
|
||||
- cwmp kernel package: contains cwmp kernel module. This module could be used by other kernel modules to notify the icwmpd daemon when kernel parameter changes
|
||||
|
||||
The three packages should be selected in the make menu config in order to get the three packages compiled.
|
||||
To compile the three packages: $ make package/cwmpd/compile
|
||||
|
||||
3) OpenWRT settings
|
||||
in the OpenWRT, Add the following lines in the /usr/share/udhcpc/default.script file:
|
||||
uci_set_state provisioning iup tr069url "$url"
|
||||
uci_set_state provisioning iup provisioningcode "$provisioningcode"
|
||||
|
||||
4) Run
|
||||
Requirements:
|
||||
- libuci package should be installed
|
||||
- libexpat package should be installed
|
||||
- libcurl package should be installed
|
||||
- libpthread package should be installed
|
||||
- libopenssl package should be installed
|
||||
- libz package should be installed
|
||||
- libcrypto package should be installed
|
||||
|
||||
Configure the acs url in the /etc/config/icwmp
|
||||
and then start the cwmpd service: /etc/init.d/icwmpd start
|
||||
for the help: /etc/init.d/icwmpd
|
||||
|
||||
5) Value Change
|
||||
|
||||
5.1) value change for user space applications (using the libcwmp)
|
||||
|
||||
Before using the libcwmp, we should check that the libcwmp package is selected in "make menu config". and we should check that the package is compiled.
|
||||
The libcwmp should be installed uin the OpenWRT firmware
|
||||
|
||||
example of using libcwmp
|
||||
in myapplication.c
|
||||
|
||||
#...
|
||||
#include <cwmp_lib.h>
|
||||
#...
|
||||
|
||||
int anyfunction ()
|
||||
{
|
||||
.....
|
||||
/* parameter change here */
|
||||
/* so we inform the icwmp: */
|
||||
lib_api_cwmp_value_change_call (3, "InternetGatewayDevice.LANDevice.{i}.LANHostConfigManagement.IPInterface.{i}.IPInterfaceIPAddress","lan2","3");
|
||||
.....
|
||||
/*
|
||||
Description of lib_api_cwmp_value_change_call input parameters
|
||||
parameter 1 : is the number of input string in the function lib_api_cwmp_value_change_call
|
||||
parameter 2 : is the parameter path
|
||||
parameter 3 : is the first correspondence related to the first indice
|
||||
parameter 4 : is the second correspondence related to the second indice
|
||||
.
|
||||
.
|
||||
.
|
||||
parameter n : is the (n-2) correspondence related to the (n-2) indice
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
5.2) value change for user space applications (using the cwmp_value_change CLI)
|
||||
|
||||
Before using the libcwmp, we should check that the libcwmp package is selected in "make menu config". and we should check that the package is compiled.
|
||||
The libcwmp should be installed uin the OpenWRT firmware
|
||||
|
||||
in OpenWRT:
|
||||
|
||||
root@OpenWrt:~# cwmp_value_change InternetGatewayDevice.LANDevice.{i}.LANHostConfigManagement.IPInterface.{i}.IPInterfaceIPAddress "lan2" "3"
|
||||
|
||||
in this case the command will force cwmp client to send a notification to the ACS (if and only if the parameter path as configured as active or as passive parameter using the setAttributeParameter method)
|
||||
|
||||
5.3) value change for kernel space modules
|
||||
Before using the cwmp kernel module for value change, we should check that the kernel module package is selected in "make menu config". and we should check that the package is compiled.
|
||||
The kernel module should be installed uin the OpenWRT firmware and should be insert before all other kernel modules
|
||||
|
||||
example of using cwmp kernel module
|
||||
in mykernelmodule.c
|
||||
|
||||
#...
|
||||
#include <linux/cwmp_kernel.h>
|
||||
#...
|
||||
|
||||
int anykernelfunction ()
|
||||
{
|
||||
.....
|
||||
/* parameter change here */
|
||||
/* so we inform the cwmp: */
|
||||
kernel_api_cwmp_value_change_call (3, "InternetGatewayDevice.LANDevice.{i}.LANHostConfigManagement.IPInterface.{i}.IPInterfaceIPAddress","lan2","3");
|
||||
.....
|
||||
/*
|
||||
Description of lib_api_cwmp_value_change_call input parameters
|
||||
parameter 1 : is the number of input string in the function lib_api_cwmp_value_change_call
|
||||
parameter 2 : is the parameter path
|
||||
parameter 3 : is the first correspondence related to the first indice
|
||||
parameter 4 : is the second correspondence related to the second indice
|
||||
.
|
||||
.
|
||||
.
|
||||
parameter n : is the (n-2) correspondence related to the (n-2) indice
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
48
icwmp/files/etc/config/cwmp
Normal file
48
icwmp/files/etc/config/cwmp
Normal file
@@ -0,0 +1,48 @@
|
||||
config acs 'acs'
|
||||
option url ''
|
||||
option userid '' #$OUI-$SER
|
||||
option passwd 'iopsys'
|
||||
option periodic_inform_enable 'true'
|
||||
option periodic_inform_interval '1800'
|
||||
option periodic_inform_time '0'
|
||||
option ParameterKey ''
|
||||
option dhcp_discovery 'enable'
|
||||
# compression possible configs: GZIP, Deflate, Disabled
|
||||
option compression 'Disabled'
|
||||
# possible configs interval :[1:65535]
|
||||
option retry_min_wait_interval '5'
|
||||
# possible configs interval :[1000:65535]
|
||||
option retry_interval_multiplier '2000'
|
||||
option https_ssl_capath ''
|
||||
option ipv6_enable '0'
|
||||
option ip_version '4'
|
||||
|
||||
config cpe 'cpe'
|
||||
option interface 'eth0.1'
|
||||
option default_wan_interface 'wan'
|
||||
option log_to_console 'disable'
|
||||
option log_to_file 'enable'
|
||||
# log_severity: INFO (Default)
|
||||
# log_severity possible configs: EMERG, ALERT, CRITIC ,ERROR, WARNING, NOTICE, INFO, DEBUG
|
||||
option log_severity 'INFO'
|
||||
option log_file_name '/var/log/icwmpd.log'
|
||||
option log_max_size '102400'
|
||||
option userid '' #$OUI-$SER
|
||||
option passwd 'iopsys'
|
||||
option port '7547'
|
||||
option ubus_socket '/var/run/ubus.sock'
|
||||
option provisioning_code ''
|
||||
option amd_version '5'
|
||||
# compression possible configs: InstanceNumber, InstanceAlias
|
||||
option instance_mode 'InstanceNumber'
|
||||
option session_timeout '60'
|
||||
option notification '1'
|
||||
option datamodel 'tr181'
|
||||
option exec_download '0'
|
||||
option periodic_notify_enable '1'
|
||||
option periodic_notify_interval '10'
|
||||
|
||||
config lwn 'lwn'
|
||||
option enable '1'
|
||||
option hostname ''
|
||||
option port '0'
|
||||
21
icwmp/files/etc/firewall.cwmp
Normal file
21
icwmp/files/etc/firewall.cwmp
Normal file
@@ -0,0 +1,21 @@
|
||||
#created by the icwmp package
|
||||
zone_name=""
|
||||
port=""
|
||||
if [ "$zone_name" = "" ]; then
|
||||
exit 0
|
||||
elif [ "$zone_name" = "icwmp" ]; then
|
||||
iptables -nL zone_icwmp_input 2> /dev/null
|
||||
if [ $? != 0 ]; then
|
||||
iptables -N zone_icwmp_input
|
||||
iptables -t filter -A INPUT -j zone_icwmp_input
|
||||
iptables -I zone_icwmp_input -p tcp --dport $port -j REJECT
|
||||
else
|
||||
iptables -F zone_icwmp_input
|
||||
iptables -I zone_icwmp_input -p tcp --dport $port -j REJECT
|
||||
fi
|
||||
else
|
||||
iptables -F zone_icwmp_input 2> /dev/null
|
||||
iptables -t filter -D INPUT -j zone_icwmp_input 2> /dev/null
|
||||
iptables -X zone_icwmp_input 2> /dev/null
|
||||
fi
|
||||
#iptables -I FW_ZONE -p tcp -s ACS_ADDRESS --dport PORT -j ACCEPT --comment "Open ACS port"
|
||||
202
icwmp/files/etc/init.d/icwmpd
Executable file
202
icwmp/files/etc/init.d/icwmpd
Executable file
@@ -0,0 +1,202 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2015-2019 iopsys Software Solutions AB
|
||||
|
||||
. /lib/functions.sh
|
||||
include /lib/network
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
START=99
|
||||
STOP=10
|
||||
|
||||
USE_PROCD=1
|
||||
PROG="/usr/sbin/icwmpd"
|
||||
|
||||
EXTRA_COMMANDS="notify"
|
||||
EXTRA_HELP=" start [GetRPCMethods] Start icwmpd service and send GetRPCMethods"
|
||||
|
||||
validate_url() {
|
||||
# SCHEMA_LIST: contain list of possible schemas that could be present in the acs url
|
||||
# Example: SCHEMA_LIST="http https"
|
||||
SCHEMA_LIST="http"
|
||||
|
||||
for schema in $SCHEMA_LIST; do
|
||||
dest=`echo $1 | sed 's/$schema:\/\///g' | cut -f1 -d \/ | cut -f1 -d:`
|
||||
if [ "_$dest" != "_" ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
build_dmmap_instance() {
|
||||
[ ! -e /etc/icwmpd/.icwmpd_backup_session.xml ] && /usr/sbin/icwmp get name "" 0 >/dev/null 2>&1
|
||||
}
|
||||
|
||||
get_acs_url() {
|
||||
local default_acs="http://10.10.1.6:8000/openacs/acs"
|
||||
local acs_dhcp_discovery="$(uci -q get cwmp.acs.dhcp_discovery)"
|
||||
local url="$(uci -q get cwmp.acs.url)"
|
||||
local dhcp_url="$(uci -P /var/state -q get cwmp.acs.dhcp_url)"
|
||||
|
||||
if [ "$acs_dhcp_discovery" == "enable" -a -n "$dhcp_url" -o -z "$url" ]; then
|
||||
url="$dhcp_url"
|
||||
echo "ACS URL from DHCP server: $url"
|
||||
[ -n "$url" ] && uci -P /var/state -q set cwmp.acs.url="$url" || url="$default_acs"
|
||||
elif [ -n "$url" ];then
|
||||
url="$(uci -q get cwmp.acs.url)"
|
||||
echo "ACS URL from configuration: $url"
|
||||
else
|
||||
url="$default_acs"
|
||||
echo "Using default ACS URL: $url"
|
||||
[ -n "$url" ] && uci -P /var/state -q set cwmp.acs.url="$url"
|
||||
fi
|
||||
|
||||
validate_url "$url"
|
||||
if [ "$?" != "0" ];then
|
||||
echo "Invalid ACS URL: $url"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
enable_dhcp_option43() {
|
||||
local wan=$1
|
||||
local discovery=0
|
||||
case $2 in
|
||||
enable|1) discovery=1 ;;
|
||||
esac
|
||||
|
||||
### Ask for DHCP Option 43 only if CWMP is enabled ###
|
||||
local enabled
|
||||
local newreqopts=
|
||||
local baseopts=
|
||||
local reqopts="$(uci -q get network.$wan.reqopts)"
|
||||
local proto="$(uci -q get network.$wan.proto)"
|
||||
local tropts="43"
|
||||
local oldreqopts="$reqopts"
|
||||
local ropt iopt
|
||||
for ropt in $reqopts; do
|
||||
case $ropt in
|
||||
43) ;;
|
||||
*) baseopts="$baseopts $ropt" ;;
|
||||
esac
|
||||
done
|
||||
ropt=""
|
||||
reqopts="$baseopts $tropts"
|
||||
for ropt in $reqopts; do
|
||||
case $ropt in
|
||||
43) [ $discovery -eq 1 ] && newreqopts="$newreqopts $ropt" ;;
|
||||
*) newreqopts="$newreqopts $ropt" ;;
|
||||
esac
|
||||
done
|
||||
if [ $proto == "dhcp" ]; then
|
||||
newreqopts="$(echo $newreqopts | tr ' ' '\n' | sort -n | tr '\n' ' ' | sed 's/^[ \t]*//;s/[ \t]*$//')"
|
||||
oldreqopts="$(echo $oldreqopts | tr ' ' '\n' | sort -n | tr '\n' ' ' | sed 's/^[ \t]*//;s/[ \t]*$//')"
|
||||
[ "$newreqopts" == "$oldreqopts" ] && return
|
||||
uci -q set network.$wan.reqopts="$newreqopts"
|
||||
uci commit network
|
||||
ubus call network reload
|
||||
fi
|
||||
########################################################
|
||||
}
|
||||
|
||||
wait_for_option43() {
|
||||
local time=$1
|
||||
local default_wan_interface dhcp_discovery url
|
||||
|
||||
config_get default_wan_interface cpe default_wan_interface "wan"
|
||||
config_get dhcp_discovery acs dhcp_discovery "0"
|
||||
config_get url acs url
|
||||
|
||||
enable_dhcp_option43 $default_wan_interface $dhcp_discovery
|
||||
|
||||
local tm=0
|
||||
|
||||
if [ "$dhcp_discovery" == "enable" -o "$dhcp_discovery" == "1" ]
|
||||
then
|
||||
echo "Waiting for discovery of ACS URL from dhcp server ..."
|
||||
while [ $tm -le $time ]
|
||||
do
|
||||
acs_url=`uci -P /var/state -q get cwmp.acs.dhcp_url`
|
||||
if [ "$acs_url" != "" ]
|
||||
then
|
||||
break
|
||||
else
|
||||
sleep 1
|
||||
fi
|
||||
tm=$((tm+1))
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
wait_for_resolvfile() {
|
||||
local time=$1
|
||||
local tm=1
|
||||
|
||||
local resolvfile="$(uci -q get dhcp.@dnsmasq[0].resolvfile)"
|
||||
[ -n "$resolvfile" ] || return
|
||||
|
||||
while [ ! -f $resolvfile ]; do
|
||||
sleep 1
|
||||
[ $tm -ge $time ] && break
|
||||
tm=$((tm+1))
|
||||
done
|
||||
}
|
||||
|
||||
set_wan_interface() {
|
||||
local l3_device=""
|
||||
local default_wan_interface=""
|
||||
|
||||
config_get default_wan_interface cpe default_wan_interface "wan"
|
||||
json_load "$(ifstatus $default_wan_interface)"
|
||||
json_get_var l3_device l3_device
|
||||
if [ "$l3_device" != "" ];then
|
||||
uci -q set cwmp.cpe.interface="$l3_device"
|
||||
uci -q commit cwmp
|
||||
fi
|
||||
}
|
||||
|
||||
start_service() {
|
||||
if [ ! -f /tmp/.icwmpd_boot ]; then
|
||||
touch /etc/icwmpd/.icwmpd_boot
|
||||
touch /tmp/.icwmpd_boot
|
||||
else
|
||||
[ -f /sbin/netifd ] && echo "Waiting for Network to be started ..." && ubus -t 5 wait_for network.interface
|
||||
[ -f /etc/config/wireless ] && echo "Waiting for WiFi to be started ..." && ubus -t 5 wait_for network.wireless
|
||||
[ -f /usr/sbin/dnsmasq ] && echo "Waiting for DNS Proxy to be started ..." && ubus -t 5 wait_for dnsmasq
|
||||
[ -f /etc/config/dhcp ] && echo "Waiting for DNS Server(s) ..." && wait_for_resolvfile 20
|
||||
[ -f /usr/sbin/asterisk ] && echo "Waiting for Voice to be started ..." && ubus -t 5 wait_for asterisk
|
||||
|
||||
config_load cwmp
|
||||
build_dmmap_instance
|
||||
set_wan_interface
|
||||
wait_for_option43 20
|
||||
get_acs_url
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG"
|
||||
if [ "$1" = "GetRPCMethods" ];then
|
||||
procd_append_param command -g
|
||||
elif [ -f /etc/icwmpd/.icwmpd_boot ]; then
|
||||
procd_append_param command -b
|
||||
fi
|
||||
procd_set_param respawn "3" "7" "0"
|
||||
procd_close_instance
|
||||
#procd_open_instance
|
||||
#[ "$(uci -q get cwmp.cpe.notification)" == "1" ] && procd_append_param command "/usr/sbin/icwmp_notifd"
|
||||
#procd_close_instance
|
||||
fi
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
notify() {
|
||||
ubus -t 1 call tr069 notify >/dev/null 2>&1 &
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_config_trigger "config.change" "cwmp" /etc/init.d/icwmpd reload
|
||||
}
|
||||
|
||||
32
icwmp/files/etc/uci-defaults/85-cwmp-set-userid
Normal file
32
icwmp/files/etc/uci-defaults/85-cwmp-set-userid
Normal file
@@ -0,0 +1,32 @@
|
||||
# Copy defaults by the factory to the cwmp UCI user section.
|
||||
|
||||
|
||||
# Get factory base MAC.
|
||||
baseMac=$(db -q get hw.board.basemac)
|
||||
|
||||
# Erase colon and space characters.
|
||||
baseMac=${baseMac//:/}
|
||||
baseMac=${baseMac// /}
|
||||
|
||||
# Caseing and fixed length string.
|
||||
mac=$(printf "%12.12X" $((0x$baseMac)))
|
||||
|
||||
# Get system serial number.
|
||||
serial=$(db -q get hw.board.serial_number)
|
||||
|
||||
# Get userid values
|
||||
acs_userid=$(uci -q get cwmp.acs.userid)
|
||||
cpe_userid=$(uci -q get cwmp.cpe.userid)
|
||||
|
||||
# Only set if they are empty
|
||||
if [ -z "$acs_userid" ]
|
||||
then
|
||||
uci -q set cwmp.acs.userid="${mac:0:6}-${serial}"
|
||||
fi
|
||||
|
||||
if [ -z "$cpe_userid" ]
|
||||
then
|
||||
uci -q set cwmp.cpe.userid="${mac:0:6}-${serial}"
|
||||
fi
|
||||
|
||||
# No need for commit here, it is done by uci_apply_defaults().
|
||||
12
icwmp/files/etc/uci-defaults/90-cwmpfirewall
Normal file
12
icwmp/files/etc/uci-defaults/90-cwmpfirewall
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOT
|
||||
delete firewall.cwmp
|
||||
set firewall.cwmp=include
|
||||
set firewall.cwmp.path=/etc/firewall.cwmp
|
||||
set firewall.cwmp.reload=1
|
||||
commit firewall
|
||||
EOT
|
||||
|
||||
exit 0
|
||||
|
||||
1
icwmp/files/lib/upgrade/keep.d/icwmp
Normal file
1
icwmp/files/lib/upgrade/keep.d/icwmp
Normal file
@@ -0,0 +1 @@
|
||||
/etc/icwmpd/.icwmpd_backup_session.xml
|
||||
29
icwmp/files/lib/upgrade/post-rootfs-fixup.d/215-icwmp
Executable file
29
icwmp/files/lib/upgrade/post-rootfs-fixup.d/215-icwmp
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
# As part of sysupgrade we copy CWMP Backup Session XML file.
|
||||
|
||||
|
||||
# Abort on any error.
|
||||
set -e
|
||||
|
||||
|
||||
# Do nothing if user want to discard old settings.
|
||||
if [ -n "$SAVE_CONFIG" ] && [ $SAVE_CONFIG -eq 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Source functions.
|
||||
for f in /lib/upgrade/iopsys*.sh; do
|
||||
[ -r "$f" -a -s "$f" ] || continue
|
||||
source $f
|
||||
done
|
||||
|
||||
|
||||
if [ -s "${2}/etc/icwmpd/.icwmpd_backup_session.xml" ]; then
|
||||
cat "${2}/etc/icwmpd/.icwmpd_backup_session.xml" > "/etc/icwmpd/.icwmpd_backup_session.xml"
|
||||
fi
|
||||
|
||||
# Report success.
|
||||
log "post-hooks" "CWMP Backup Session XML file migrated"
|
||||
|
||||
exit 0
|
||||
29
ieee1905/Config.in
Normal file
29
ieee1905/Config.in
Normal file
@@ -0,0 +1,29 @@
|
||||
if PACKAGE_ieee1905 || PACKAGE_lib1905al
|
||||
|
||||
menu "developer/debug options"
|
||||
|
||||
config IEEE1905_MAP_COMPLETE_NETWORK
|
||||
bool "Create network topology for complete network"
|
||||
default n
|
||||
|
||||
config IEEE1905_SPEED_UP_DISCOVERY
|
||||
bool "Speed up discovery of an AL in network"
|
||||
default y
|
||||
|
||||
config IEEE1905_DO_NOT_ACCEPT_UNAUTHENTICATED_COMMANDS
|
||||
bool "Do not accept M1/M2 messages from unknown AL(s)"
|
||||
default y
|
||||
|
||||
choice
|
||||
prompt "Select ALME support"
|
||||
default IEEE1905_ALME_OVER_UBUS
|
||||
|
||||
config IEEE1905_ALME_OVER_UBUS
|
||||
bool "ALME methods supported over ubus"
|
||||
|
||||
#config IEEE1905_ALME_OVER_TCP
|
||||
# bool "ALME server over TCP port"
|
||||
|
||||
endchoice
|
||||
endmenu
|
||||
endif
|
||||
141
ieee1905/Makefile
Normal file
141
ieee1905/Makefile
Normal file
@@ -0,0 +1,141 @@
|
||||
#
|
||||
# Copyright (C) 2019 Iopsys
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ieee1905
|
||||
PKG_VERSION:=2.1.32
|
||||
|
||||
LOCAL_DEV:=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=2bb1c564d31a99d80a3f977c1f817777722a601d
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/ieee1905.git
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
endif
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ieee1905
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=IEEE1905 daemon
|
||||
DEPENDS:= +libuci +libjson-c +libieee1905 +ubox +libpcap +libopenssl +libwifi +libeasy
|
||||
endef
|
||||
|
||||
define Package/ieee1905/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
define Package/ieee1905/description
|
||||
IEEE1905 stack with extended functionalities.
|
||||
endef
|
||||
|
||||
define Package/libieee1905
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=IEEE1905 cmdu tlv utility library
|
||||
endef
|
||||
|
||||
define Package/libwsc
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Wifi Simple Configuration building and processing library
|
||||
DEPENDS= +libopenssl +libuci +libubus
|
||||
endef
|
||||
|
||||
define Package/lib1905hle
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=IEEE1905 hle stack library
|
||||
endef
|
||||
|
||||
LIBS := \
|
||||
$(if $(CONFIG_PACKAGE_libwsc),libwsc.so)
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-I$(STAGING_DIR)/usr/include \
|
||||
-D_GNU_SOURCE \
|
||||
-fstrict-aliasing \
|
||||
-Wall \
|
||||
-Wextra
|
||||
|
||||
MAKE_FLAGS += \
|
||||
LIBS="$(LIBS)"
|
||||
|
||||
ifeq ($(CONFIG_IEEE1905_SPEED_UP_DISCOVERY),y)
|
||||
TARGET_CFLAGS += -DSPEED_UP_DISCOVERY
|
||||
endif
|
||||
ifeq ($(CONFIG_IEEE1905_DO_NOT_ACCEPT_UNAUTHENTICATED_COMMANDS),y)
|
||||
TARGET_CFLAGS += -DDO_NOT_ACCEPT_UNAUTHENTICATED_COMMANDS
|
||||
endif
|
||||
ifeq ($(CONFIG_IEEE1905_ALME_OVER_TCP),y)
|
||||
TARGET_CFLAGS += -DALME_OVER_TCP
|
||||
endif
|
||||
ifeq ($(CONFIG_IEEE1905_ALME_OVER_UBUS),y)
|
||||
TARGET_CFLAGS += -DALME_OVER_UBUS
|
||||
endif
|
||||
ifeq ($(CONFIG_IEEE1905_MAP_COMPLETE_NETWORK),y)
|
||||
TARGET_CFLAGS += -DIEEE1905_MAP_COMPLETE_NETWORK
|
||||
endif
|
||||
|
||||
ifeq ($(LOCAL_DEV),1)
|
||||
define Build/Prepare
|
||||
$(CP) -rf ~/git/ieee1905/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/ieee1905/install
|
||||
$(INSTALL_DIR) $(1)/etc
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DIR) $(1)/etc/ieee1905
|
||||
$(INSTALL_DIR) $(1)/usr/
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) ./files/etc/init.d/ieee1905 $(1)/etc/init.d/ieee1905
|
||||
$(INSTALL_DATA) ./files/etc/config/ieee1905 $(1)/etc/config/ieee1905
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ieee1905d $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
define Package/lib1905hle/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/lib/lib1905hle.so $(1)/usr/lib/lib1905hle.so
|
||||
endef
|
||||
|
||||
define Package/libieee1905/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/lib/libieee1905.so $(1)/usr/lib/libieee1905.so
|
||||
endef
|
||||
|
||||
define Package/libwsc/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/lib/libwsc.so $(1)/usr/lib/libwsc.so
|
||||
endef
|
||||
|
||||
define Build/InstallDev/libwsc.so
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libwsc/include/wsc.h $(1)/usr/include/
|
||||
$(CP) $(PKG_BUILD_DIR)/lib/libwsc.so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/include/ieee1905
|
||||
$(INSTALL_DIR) $(1)/usr/include/ieee1905
|
||||
$(INSTALL_DIR) $(1)/usr/include/lib1905hle
|
||||
$(CP) $(PKG_BUILD_DIR)/include/*.h $(1)/usr/include/ieee1905/
|
||||
$(CP) $(PKG_BUILD_DIR)/libieee1905/include/*.h $(1)/usr/include/ieee1905/
|
||||
$(CP) $(PKG_BUILD_DIR)/lib1905hle/include/*.h $(1)/usr/include/lib1905hle/
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/lib/libieee1905.so $(1)/usr/lib
|
||||
$(foreach lib,$(LIBS),$(call Build/InstallDev/$(lib),$(1),$(2));)
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libieee1905))
|
||||
$(eval $(call BuildPackage,lib1905hle))
|
||||
$(eval $(call BuildPackage,libwsc))
|
||||
$(eval $(call BuildPackage,ieee1905))
|
||||
17
ieee1905/files/etc/config/ieee1905
Normal file
17
ieee1905/files/etc/config/ieee1905
Normal file
@@ -0,0 +1,17 @@
|
||||
config ieee1905 'ieee1905'
|
||||
option enabled '1'
|
||||
option debug true
|
||||
option debug_level 2
|
||||
option macaddress 'auto'
|
||||
option registrar 0
|
||||
option cmdu_event 1
|
||||
option map_plugin 1
|
||||
|
||||
config security 'security'
|
||||
list method 'PBC'
|
||||
|
||||
config al-iface
|
||||
option enabled 1
|
||||
option ifname 'br-lan'
|
||||
option media 'bridge'
|
||||
|
||||
72
ieee1905/files/etc/init.d/ieee1905
Normal file
72
ieee1905/files/etc/init.d/ieee1905
Normal file
@@ -0,0 +1,72 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=96
|
||||
STOP=22
|
||||
|
||||
USE_PROCD=1
|
||||
PROG=/usr/sbin/ieee1905d
|
||||
|
||||
validate_ieee1905_section()
|
||||
{
|
||||
uci_validate_section ieee1905 ieee1905 "${1}" \
|
||||
'debug:bool:false' \
|
||||
'enabled:bool:false'
|
||||
}
|
||||
|
||||
configure_ieee1905()
|
||||
{
|
||||
local enabled debug
|
||||
|
||||
validate_ieee1905_section ${1} || {
|
||||
echo "Validation of ieee1905 section failed"
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if [ ${debug} -eq 1 ]; then
|
||||
# Forward stdout of the command to logd
|
||||
procd_set_param stdout 1
|
||||
# Same for stderr
|
||||
procd_set_param stderr 1
|
||||
fi
|
||||
|
||||
if [ ${enabled} -ne 1 ]; then
|
||||
exit 0;
|
||||
fi
|
||||
}
|
||||
|
||||
configure_network()
|
||||
{
|
||||
ebtables -L FORWARD|grep -iqE "1:80:C2:(0)+:(0)+:13.*-j.*DROP"
|
||||
if [ "$?" -ne 0 ]; then
|
||||
echo "Applying drop rule to drop pkts forwared by kernel to 1905.1 multicast mac"
|
||||
ebtables -A FORWARD -d 01:80:c2:00:00:13 -j DROP
|
||||
fi
|
||||
}
|
||||
|
||||
service_running() {
|
||||
ubus -t 2 wait_for wifi
|
||||
}
|
||||
|
||||
start_service() {
|
||||
|
||||
[ -d /usr/lib/ieee1905 ] || mkdir -p /usr/lib/ieee1905
|
||||
|
||||
procd_open_instance ieee1905
|
||||
procd_set_param command ${PROG}
|
||||
configure_ieee1905 "ieee1905"
|
||||
configure_network
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "network"
|
||||
procd_add_reload_trigger "wireless"
|
||||
procd_add_reload_trigger "netmode"
|
||||
procd_add_reload_trigger "ieee1905"
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2018 iopsys Software Solutions AB
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=ifbt
|
||||
PKG_VERSION:=0.2
|
||||
|
||||
PKG_SOURCE_VERSION:=f6edff47b6c0a154ab892301acf767d19ac8ad73
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/ifbt.git
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
PKG_LICENSE_FILES:=README
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
ifeq ($(CONFIG_TARGET_iopsys_brcm63xx_mips),y)
|
||||
TARGET_PLATFORM:=-DIOPSYS_BROADCOM
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_brcm63xx_arm),y)
|
||||
TARGET_PLATFORM:=-DIOPSYS_BROADCOM
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_linksys),y)
|
||||
TARGET_PLATFORM:=-DIOPSYS_MARVELL
|
||||
else ifeq ($(CONFIG_TARGET_intel_mips),y)
|
||||
TARGET_PLATFORM:=-DIOPSYS_INTEL
|
||||
else ifeq ($(CONFIG_TARGET_iopsys_ramips),y)
|
||||
TARGET_PLATFORM:=-DIOPSYS_MEDIATEK
|
||||
else
|
||||
$(info (UNEXPECTED CONFIG TARGET))
|
||||
endif
|
||||
|
||||
export TARGET_PLATFORM
|
||||
|
||||
define Package/ifbt
|
||||
CATEGORY:=Utilities
|
||||
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libwifi +libjson-c
|
||||
TITLE:=Fast BSS Transition
|
||||
endef
|
||||
|
||||
define Package/ifbt/description
|
||||
ifbt is Iopsys application for fast BSS transition
|
||||
endef
|
||||
|
||||
define Package/ifbt/install
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ifbt $(1)/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ifbt))
|
||||
@@ -9,10 +9,10 @@ include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=inbd
|
||||
PKG_VERSION:=1.0.0
|
||||
PKG_VERSION:=1.0.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_VERSION:=53ca7f58edb87976b5897ccaf487bb0cbbf39d07
|
||||
PKG_SOURCE_VERSION:=3135944f3357a7a2c1c206be7b65bbb7ac6d1e58
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/inbd
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=inotify-tools
|
||||
PKG_VERSION:=3.14
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_VERSION:=1df9af4d6cd0f4af4b1b19254bcf056aed4ae395
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/rvoicilas/inotify-tools.git
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_LICENSE:=GPLv2
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
|
||||
# support parallel build
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
#re create configure scripts if not present.
|
||||
PKG_FIXUP:=autoreconf
|
||||
|
||||
# run install target when cross compiling. basically, make install DESTDIR=$(PKG_INSTALL_DIR)
|
||||
# this way we don't need to pick out the resulting files from the build dir.
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/inotify-tools
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Tools to trace filesystem events.
|
||||
URL:=
|
||||
endef
|
||||
|
||||
define Package/inotify-tools/description
|
||||
Tools to trace filesystem events.
|
||||
endef
|
||||
|
||||
define Package/inotify-tools/install
|
||||
$(INSTALL_DIR) $(1)/usr
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_DIR) $(1)/usr/lib/
|
||||
$(CP) ./files/* $(1)/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/libinotifytools.so.0.4.1 $(1)/usr/lib/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/libinotifytools.so.0 $(1)/usr/lib/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/libinotifytools.so $(1)/usr/lib/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/inotifywait $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/inotifywatch $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,inotify-tools))
|
||||
@@ -1,13 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
# is the real root mounted ?
|
||||
if [ ! -f /tmp/inotify_real_root/etc/preinit ]
|
||||
then
|
||||
ubivol=$( cat /proc/cmdline | sed -e "s/.*root=\(ubi:rootfs_.\).*/\1/" )
|
||||
mkdir /tmp/inotify_real_root
|
||||
mount -t ubifs $ubivol /tmp/inotify_real_root
|
||||
fi
|
||||
|
||||
inotifywait -r -m -e modify -e create -e attrib -e delete -e move /tmp/inotify_real_root
|
||||
|
||||
|
||||
123
iop/config
123
iop/config
@@ -7,20 +7,26 @@ CONFIG_PACKAGE_6in4=y
|
||||
CONFIG_PACKAGE_6rd=y
|
||||
CONFIG_PACKAGE_6to4=y
|
||||
CONFIG_PACKAGE_alsa-lib=y
|
||||
CONFIG_PACKAGE_atftp=m
|
||||
CONFIG_PACKAGE_atftpd=m
|
||||
CONFIG_PACKAGE_bulkdata=y
|
||||
CONFIG_PACKAGE_chat=y
|
||||
CONFIG_PACKAGE_comgt=y
|
||||
CONFIG_PACKAGE_comgt-directip=y
|
||||
CONFIG_PACKAGE_comgt-ncm=y
|
||||
CONFIG_PACKAGE_crashlog=y
|
||||
CONFIG_PACKAGE_ddns-scripts=y
|
||||
CONFIG_PACKAGE_ds-lite=y
|
||||
CONFIG_PACKAGE_easy-qos=y
|
||||
CONFIG_PACKAGE_gdb=m
|
||||
CONFIG_PACKAGE_ethtool=y
|
||||
CONFIG_PACKAGE_getopt=y
|
||||
CONFIG_PACKAGE_glib2=y
|
||||
CONFIG_PACKAGE_icwmp-curl=y
|
||||
CONFIG_PACKAGE_ifbt=y
|
||||
CONFIG_PACKAGE_imonitor=y
|
||||
CONFIG_PACKAGE_icwmp=y
|
||||
CONFIG_PACKAGE_ieee1905=y
|
||||
CONFIG_PACKAGE_map-1905=y
|
||||
CONFIG_PACKAGE_map-topology=y
|
||||
CONFIG_PACKAGE_mosquitto-client-ssl=y
|
||||
CONFIG_PACKAGE_mosquitto-ssl=y
|
||||
CONFIG_PACKAGE_wfadatad=y
|
||||
CONFIG_PACKAGE_imonitor=m
|
||||
CONFIG_PACKAGE_inbd=y
|
||||
CONFIG_PACKAGE_iopupgrade=y
|
||||
CONFIG_PACKAGE_ip-full=y
|
||||
@@ -32,47 +38,23 @@ CONFIG_PACKAGE_iptables-mod-filter=y
|
||||
CONFIG_PACKAGE_iptables-mod-ipopt=y
|
||||
# CONFIG_PACKAGE_iwatchdog is not set
|
||||
CONFIG_PACKAGE_juci=y
|
||||
CONFIG_PACKAGE_juci-config-backup=y
|
||||
CONFIG_PACKAGE_juci-ddns=y
|
||||
CONFIG_PACKAGE_juci-diagnostics=y
|
||||
CONFIG_PACKAGE_juci-dnsmasq-dhcp=y
|
||||
CONFIG_PACKAGE_juci-dropbear=y
|
||||
CONFIG_PACKAGE_juci-easyqos=y
|
||||
CONFIG_PACKAGE_juci-event=y
|
||||
CONFIG_PACKAGE_juci-firewall-fw3=y
|
||||
CONFIG_PACKAGE_juci-icwmp=y
|
||||
CONFIG_PACKAGE_juci-igmpinfo=y
|
||||
CONFIG_PACKAGE_juci-minidlna=y
|
||||
CONFIG_PACKAGE_juci-mod-status=y
|
||||
CONFIG_PACKAGE_juci-mod-system=y
|
||||
CONFIG_PACKAGE_juci-mwan3=y
|
||||
CONFIG_PACKAGE_juci-netmode=y
|
||||
CONFIG_PACKAGE_juci-network-device=y
|
||||
CONFIG_PACKAGE_juci-network-dsl=y
|
||||
CONFIG_PACKAGE_juci-network-netifd=y
|
||||
CONFIG_PACKAGE_juci-network-port=y
|
||||
CONFIG_PACKAGE_juci-openvpn=y
|
||||
CONFIG_PACKAGE_juci-owsd=y
|
||||
CONFIG_PACKAGE_juci-realtime-graphs=y
|
||||
CONFIG_PACKAGE_juci-samba=y
|
||||
CONFIG_PACKAGE_juci-snmpd=y
|
||||
CONFIG_PACKAGE_juci-sysupgrade=y
|
||||
CONFIG_PACKAGE_juci-upnp=y
|
||||
CONFIG_PACKAGE_juci-usb=y
|
||||
CONFIG_PACKAGE_juci-voice-client=y
|
||||
CONFIG_PACKAGE_juci-wifilife=y
|
||||
CONFIG_PACKAGE_juci-wireless=y
|
||||
CONFIG_PACKAGE_juci-theme-iopsys=y
|
||||
CONFIG_PACKAGE_kmod-siit=y
|
||||
CONFIG_PACKAGE_libcgroup-daemon=y
|
||||
CONFIG_PACKAGE_libcgroup=y
|
||||
# CONFIG_PACKAGE_libcgroup-utils is not set
|
||||
CONFIG_PACKAGE_libdaemon=y
|
||||
CONFIG_PACKAGE_libffmpeg-mini=y
|
||||
CONFIG_PACKAGE_libgmp=y
|
||||
CONFIG_PACKAGE_libreadline=y
|
||||
CONFIG_PACKAGE_loop-detector=m
|
||||
CONFIG_PACKAGE_minidlna=y
|
||||
CONFIG_PACKAGE_libreswan=m
|
||||
CONFIG_PACKAGE_libwifi=y
|
||||
CONFIG_PACKAGE_lscpu=y
|
||||
CONFIG_PACKAGE_map=y
|
||||
CONFIG_PACKAGE_miniupnpd=y
|
||||
CONFIG_PACKAGE_mwan3=y
|
||||
CONFIG_PACKAGE_nand-utils=y
|
||||
@@ -87,9 +69,9 @@ CONFIG_PACKAGE_openssl-util=y
|
||||
CONFIG_OPENSSL_WITH_COMPRESSION=y
|
||||
CONFIG_PACKAGE_openvpn-easy-rsa=y
|
||||
CONFIG_PACKAGE_openvpn-openssl=y
|
||||
CONFIG_PACKAGE_owsd=y
|
||||
CONFIG_PACKAGE_peripheral_manager=y
|
||||
CONFIG_PACKAGE_port-management=y
|
||||
CONFIG_PACKAGE_power-management=y
|
||||
CONFIG_PACKAGE_ppp-mod-pppoa=y
|
||||
CONFIG_PACKAGE_ppp-mod-pppoe=y
|
||||
CONFIG_PACKAGE_ppp-mod-pppol2tp=y
|
||||
@@ -103,45 +85,42 @@ CONFIG_PACKAGE_rdnssd=y
|
||||
CONFIG_PACKAGE_relayd=y
|
||||
CONFIG_PACKAGE_resolveip=y
|
||||
CONFIG_PACKAGE_rpcd=y
|
||||
CONFIG_PACKAGE_rpcd-mod-rpcsys=y
|
||||
CONFIG_PACKAGE_rsync=y
|
||||
CONFIG_PACKAGE_rulengd=y
|
||||
CONFIG_PACKAGE_samba3=y
|
||||
CONFIG_PACKAGE_samba3-nmbd=y
|
||||
CONFIG_PACKAGE_snmpd=y
|
||||
CONFIG_PACKAGE_strace=y
|
||||
CONFIG_PACKAGE_swmodd=m
|
||||
CONFIG_PACKAGE_tc=y
|
||||
CONFIG_PACKAGE_tcpdump=y
|
||||
CONFIG_PACKAGE_terminfo=y
|
||||
CONFIG_PACKAGE_tptest=y
|
||||
CONFIG_PACKAGE_traceroute6=y
|
||||
CONFIG_PACKAGE_uledd=y
|
||||
CONFIG_PACKAGE_umbim=y
|
||||
CONFIG_PACKAGE_uqmi=y
|
||||
CONFIG_PACKAGE_usb-modeswitch=y
|
||||
CONFIG_PACKAGE_usbreset=y
|
||||
CONFIG_PACKAGE_uspd=y
|
||||
CONFIG_PACKAGE_vsftpd-tls=m
|
||||
CONFIG_PACKAGE_wget=y
|
||||
CONFIG_PACKAGE_wwan=y
|
||||
CONFIG_PACKAGE_libwifi=y
|
||||
CONFIG_PACKAGE_wifilife=y
|
||||
CONFIG_PACKAGE_wifimngr=y
|
||||
CONFIG_PACKAGE_libwifix=y
|
||||
CONFIG_PACKAGE_wifixd=y
|
||||
CONFIG_PACKAGE_xl2tpd=y
|
||||
CONFIG_PACKAGE_zoneinfo-core=y
|
||||
CONFIG_PACKAGE_zoneinfo-europe=y
|
||||
CONFIG_TARGET_CUSTOMER="IOPSYS"
|
||||
CONFIG_TARGET_ROOTFS_TARGZ=y
|
||||
# CONFIG_USE_SSTRIP is not set
|
||||
CONFIG_USE_STRIP=y
|
||||
CONFIG_BUILD_LOG=y
|
||||
CONFIG_BUSYBOX_CONFIG_ADDUSER=y
|
||||
CONFIG_BUSYBOX_CONFIG_ARPING=y
|
||||
CONFIG_BUSYBOX_CONFIG_ASH_IDLE_TIMEOUT=y
|
||||
CONFIG_BUSYBOX_CONFIG_ASH_RANDOM_SUPPORT=y
|
||||
CONFIG_BUSYBOX_CONFIG_CTTYHACK=y
|
||||
CONFIG_BUSYBOX_CONFIG_DELUSER=y
|
||||
# CONFIG_BUSYBOX_CONFIG_DEVMEM is not set
|
||||
CONFIG_BUSYBOX_CONFIG_FEATURE_UDHCP_8021Q=y
|
||||
CONFIG_BUSYBOX_CONFIG_FIRST_SYSTEM_ID=100
|
||||
CONFIG_BUSYBOX_CONFIG_HTTPD=y
|
||||
# CONFIG_BUSYBOX_CONFIG_HTTPD is not set
|
||||
# CONFIG_BUSYBOX_CONFIG_INSMOD is not set
|
||||
# CONFIG_BUSYBOX_CONFIG_MODINFO is not set
|
||||
# CONFIG_BUSYBOX_CONFIG_MODPROBE is not set
|
||||
@@ -185,14 +164,64 @@ CONFIG_BUSYBOX_CONFIG_FEATURE_TFTP_PUT=y
|
||||
# CONFIG_BUSYBOX_CONFIG_PAM is not set
|
||||
# CONFIG_BUSYBOX_CONFIG_TFTP_DEBUG is not set
|
||||
# CONFIG_BUSYBOX_CONFIG_NTPD is not set
|
||||
CONFIG_BUSYBOX_CONFIG_MOUNTPOINT=y
|
||||
CONFIG_BUSYBOX_CONFIG_RUN_PARTS=y
|
||||
CONFIG_BUSYBOX_CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS=y
|
||||
CONFIG_BUSYBOX_CONFIG_FEATURE_RUN_PARTS_FANCY=y
|
||||
CONFIG_BUSYBOX_CONFIG_FEATURE_GZIP_LEVELS=y
|
||||
CONFIG_BUSYBOX_CONFIG_GZIP_FAST=2
|
||||
CONFIG_BUSYBOX_CONFIG_FEATURE_FANCY_SLEEP=y
|
||||
CONFIG_BUSYBOX_CONFIG_FEATURE_FLOAT_SLEEP=y
|
||||
CONFIG_BUSYBOX_CONFIG_FLOAT_DURATION=y
|
||||
CONFIG_BUSYBOX_CONFIG_USLEEP=y
|
||||
CONFIG_BUSYBOX_CONFIG_REALPATH=y
|
||||
CONFIG_BUSYBOX_CONFIG_TTY=y
|
||||
CONFIG_BUSYBOX_CONFIG_BLOCKDEV=y
|
||||
CONFIG_BUSYBOX_CONFIG_PARTPROBE=y
|
||||
CONFIG_BUSYBOX_CONFIG_LFS=y
|
||||
CONFIG_BUSYBOX_CONFIG_FDISK=y
|
||||
CONFIG_BUSYBOX_CONFIG_FDISK_SUPPORT_LARGE_DISKS=y
|
||||
CONFIG_BUSYBOX_CONFIG_FEATURE_FDISK_WRITABLE=y
|
||||
CONFIG_BUSYBOX_CONFIG_FEATURE_GPT_LABEL=y
|
||||
CONFIG_BUSYBOX_CONFIG_FEATURE_FDISK_ADVANCED=y
|
||||
CONFIG_BUSYBOX_CONFIG_IONICE=y
|
||||
CONFIG_BUSYBOX_CONFIG_RENICE=y
|
||||
CONFIG_BUSYBOX_CONFIG_FEATURE_VOLUMEID_BTRFS=y
|
||||
CONFIG_BUSYBOX_CONFIG_FEATURE_VOLUMEID_F2FS=y
|
||||
CONFIG_BUSYBOX_CONFIG_FEATURE_VOLUMEID_LINUXSWAP=y
|
||||
CONFIG_BUSYBOX_CONFIG_FEATURE_VOLUMEID_SQUASHFS=y
|
||||
CONFIG_BUSYBOX_CONFIG_FEATURE_VOLUMEID_UBIFS=y
|
||||
CONFIG_BUSYBOX_CONFIG_TIMEOUT=y
|
||||
CONFIG_LIBCURL_CRYPTO_AUTH=y
|
||||
# CONFIG_LIBCURL_MBEDTLS is not set
|
||||
CONFIG_LIBCURL_OPENSSL=y
|
||||
CONFIG_OPENVPN_openssl_ENABLE_IPROUTE2=y
|
||||
# CONFIG_SAMBA3_CONFIG_NO_PRINTING is not set
|
||||
# CONFIG_SIGNED_PACKAGES is not set
|
||||
CONFIG_KERNEL_DEVTMPFS=y
|
||||
CONFIG_KERNEL_DEVTMPFS_MOUNT=y
|
||||
# CONFIG_BUSYBOX_CONFIG_IP is not set
|
||||
LOCAL_MIRROR="http://download.iopsys.eu/iopsys/mirror/"
|
||||
CONFIG_LOCALMIRROR="https://download.iopsys.eu/iopsys/mirror/"
|
||||
|
||||
# Generation of /etc/banner.
|
||||
CONFIG_IMAGEOPT=y
|
||||
CONFIG_VERSIONOPT=y
|
||||
CONFIG_VERSION_MANUFACTURER="iopsysWrt"
|
||||
CONFIG_VERSION_MANUFACTURER_URL="https://iopsys.eu/"
|
||||
|
||||
# Disable as much as possible of OpenWrt messy "pre-init" stuff.
|
||||
CONFIG_PREINITOPT=y
|
||||
# CONFIG_TARGET_PREINIT_SUPPRESS_STDERR is not set
|
||||
CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE=y
|
||||
CONFIG_TARGET_PREINIT_TIMEOUT=1
|
||||
# CONFIG_TARGET_PREINIT_SHOW_NETMSG is not set
|
||||
# CONFIG_TARGET_PREINIT_SUPPRESS_FAILSAFE_NETMSG is not set
|
||||
CONFIG_TARGET_PREINIT_IFNAME=""
|
||||
CONFIG_TARGET_PREINIT_IP=""
|
||||
CONFIG_TARGET_PREINIT_NETMASK=""
|
||||
CONFIG_TARGET_PREINIT_BROADCAST=""
|
||||
|
||||
# The urandom-seed package is very strange. It seeds urandom with urandom...
|
||||
# Disable it. Most SoCs nowadays has HW random generators anyway.
|
||||
# CONFIG_PACKAGE_urandom-seed is not set
|
||||
# CONFIG_PACKAGE_urngd is not set
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ _iop()
|
||||
iopcmds="bootstrap cfe_upgrade cfe_upgrade_latest extract_core \
|
||||
feeds_update genconfig generate_tarballs install_key \
|
||||
scp_changes setup_host ssh_install_key status \
|
||||
update_package update_feed_branches ssh_upgrade"
|
||||
update_package update_feed_branches ssh_upgrade smoketest"
|
||||
|
||||
if [ $COMP_CWORD -eq 1 ] ; then
|
||||
|
||||
|
||||
@@ -6,13 +6,9 @@ function extract_core {
|
||||
topdir=$(pwd)
|
||||
|
||||
# Paths to packages that should be exported.
|
||||
paths+='package/network/services/dnsmasq '
|
||||
paths+='package/network/config/firewall '
|
||||
paths+='package/network/config/netifd '
|
||||
paths+='package/network/config/qos-scripts '
|
||||
paths+='package/utils/busybox '
|
||||
paths+='package/base-files '
|
||||
paths+='package/system/procd '
|
||||
paths+='package/system/rpcd '
|
||||
paths+='package/network/services/openvpn '
|
||||
|
||||
@@ -24,7 +20,13 @@ function extract_core {
|
||||
echo ""
|
||||
echo "Example: $0 extract_core"
|
||||
echo " -p package/utils/busybox"
|
||||
echo " -r feeds/lede_core"
|
||||
echo " -r feeds/openwrt_core"
|
||||
echo " -b devel"
|
||||
echo ""
|
||||
echo "Extract all default packages:"
|
||||
echo "$0 extract_core"
|
||||
echo " -p default"
|
||||
echo " -r feeds/openwrt_core"
|
||||
echo " -b devel"
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,11 @@ function feeds_update {
|
||||
|
||||
# replace core packages with iopsys versions
|
||||
if [ $override == 1 ]; then
|
||||
./scripts/feeds install -f -p lede_core -a
|
||||
./scripts/feeds install -f -p openwrt_core -a
|
||||
fi
|
||||
|
||||
# targets need to be installed explicitly
|
||||
targets="iopsys-brcm63xx-mips iopsys-brcm63xx-arm iopsys-ramips intel_mips"
|
||||
targets="iopsys-brcm63xx-arm iopsys-ramips intel_mips iopsys-x86 iopsys-armvirt iopsys-bcm27xx"
|
||||
for target in $targets
|
||||
do
|
||||
rm -f target/linux/$target
|
||||
@@ -57,6 +57,3 @@ function feeds_update {
|
||||
|
||||
register_command "feeds_update" "Update feeds to point to commit hashes from feeds.conf"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ function genconfig {
|
||||
export IMPORT=1
|
||||
export SRCTREEOVERR=0
|
||||
export FILEDIR="files/"
|
||||
export THEMEDIR="themes"
|
||||
export THEMEDIR="tmp/juci-themes"
|
||||
CURRENT_CONFIG_FILE=".current_config_file"
|
||||
export CONFIGPATH="package/feeds/iopsys/iop"
|
||||
CUSTPATH="customerconfigs"
|
||||
@@ -13,11 +13,13 @@ function genconfig {
|
||||
export VERBOSE=0
|
||||
export DEVELOPER=0
|
||||
target="bogus"
|
||||
config_path=""
|
||||
brcm63xx_mips="target/linux/iopsys-brcm63xx-mips"
|
||||
target_config_path=""
|
||||
bcm27xx="target/linux/iopsys-bcm27xx"
|
||||
brcm63xx_arm="target/linux/iopsys-brcm63xx-arm"
|
||||
ramips="target/linux/iopsys-ramips"
|
||||
intel_mips="target/linux/intel_mips"
|
||||
x86="target/linux/iopsys-x86"
|
||||
armvirt="target/linux/iopsys-armvirt"
|
||||
|
||||
Red='\033[0;31m' # Red
|
||||
Color_Off='\033[0m' # Text Reset
|
||||
@@ -79,20 +81,49 @@ function genconfig {
|
||||
|
||||
# Takes a board name and returns the target name in global var $target
|
||||
set_target() {
|
||||
local profile=$1
|
||||
local profile=$1
|
||||
|
||||
[ -n "$profile" ] || return
|
||||
|
||||
if [ -n "$TARGET" -a -d "./target/linux/$TARGET" ]; then
|
||||
local targetpath="./target/linux/$TARGET"
|
||||
local profiles=
|
||||
local pfound=0
|
||||
|
||||
if [ -e "$targetpath/genconfig" ]; then
|
||||
profiles=$(cd $targetpath; ./genconfig)
|
||||
|
||||
for p in $profiles; do
|
||||
if [ $p == $profile ]; then
|
||||
pfound=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ $pfound -eq 1 ]; then
|
||||
target="$(echo $TARGET | tr '-' '_')"
|
||||
target_config_path="$targetpath/config"
|
||||
fi
|
||||
|
||||
return
|
||||
fi
|
||||
|
||||
[ -e $brcm63xx_mips/genconfig ] &&
|
||||
iopsys_brcm63xx_mips=$(cd $brcm63xx_mips; ./genconfig)
|
||||
[ -e $brcm63xx_arm/genconfig ] &&
|
||||
iopsys_brcm63xx_arm=$(cd $brcm63xx_arm; ./genconfig)
|
||||
[ -e $ramips/genconfig ] &&
|
||||
iopsys_ramips=$(cd $ramips; ./genconfig)
|
||||
[ -e $intel_mips/genconfig ] &&
|
||||
iopsys_intel_mips=$(cd $intel_mips; ./genconfig)
|
||||
[ -e $x86/genconfig ] &&
|
||||
iopsys_x86=$(cd $x86; ./genconfig)
|
||||
[ -e $armvirt/genconfig ] &&
|
||||
iopsys_armvirt=$(cd $armvirt; ./genconfig)
|
||||
[ -e $bcm27xx/genconfig ] &&
|
||||
iopsys_bcm27xx=$(cd $bcm27xx; ./genconfig)
|
||||
|
||||
if [ "$profile" == "LIST" ]; then
|
||||
for list in iopsys_brcm63xx_mips iopsys_brcm63xx_arm iopsys_ramips iopsys_intel_mips; do
|
||||
for list in iopsys_brcm63xx_arm iopsys_ramips iopsys_intel_mips iopsys_x86 iopsys_armvirt iopsys_bcm27xx; do
|
||||
echo "$list based boards:"
|
||||
for b in ${!list}; do
|
||||
echo -e "\t$b"
|
||||
@@ -101,18 +132,10 @@ function genconfig {
|
||||
return
|
||||
fi
|
||||
|
||||
for p in $iopsys_brcm63xx_mips; do
|
||||
if [ $p == $profile ]; then
|
||||
target="iopsys_brcm63xx_mips"
|
||||
config_path="$brcm63xx_mips/config"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
for p in $iopsys_brcm63xx_arm; do
|
||||
if [ $p == $profile ]; then
|
||||
target="iopsys_brcm63xx_arm"
|
||||
config_path="$brcm63xx_arm/config"
|
||||
target_config_path="$brcm63xx_arm/config"
|
||||
return
|
||||
fi
|
||||
done
|
||||
@@ -120,7 +143,7 @@ function genconfig {
|
||||
for p in $iopsys_ramips; do
|
||||
if [ $p == $profile ]; then
|
||||
target="iopsys_ramips"
|
||||
config_path="$ramips/config"
|
||||
target_config_path="$ramips/config"
|
||||
return
|
||||
fi
|
||||
done
|
||||
@@ -128,27 +151,49 @@ function genconfig {
|
||||
for p in $iopsys_intel_mips; do
|
||||
if [ $p == $profile ]; then
|
||||
target="intel_mips"
|
||||
config_path="$intel_mips/config"
|
||||
target_config_path="$intel_mips/config"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
for p in $iopsys_x86; do
|
||||
if [ $p == $profile ]; then
|
||||
target="iopsys_x86"
|
||||
target_config_path="$x86/config"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
for p in $iopsys_armvirt; do
|
||||
if [ $p == $profile ]; then
|
||||
target="iopsys_armvirt"
|
||||
target_config_path="$armvirt/config"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
for p in $iopsys_bcm27xx; do
|
||||
if [ $p == $profile ]; then
|
||||
target="iopsys_bcm27xx"
|
||||
target_config_path="$bcm27xx/config"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
git remote -v | grep -q http || {
|
||||
git remote -v | grep -qE '(git@|ssh://)' && {
|
||||
DEVELOPER=1
|
||||
|
||||
bcmAllowed=0
|
||||
endptAllowed=0
|
||||
natalieAllowed=0
|
||||
mediatekAllowed=0
|
||||
wifilifeAllowed=0
|
||||
#mediatekAllowed=0
|
||||
|
||||
git ls-remote git@dev.iopsys.eu:broadcom/bcmcreator.git -q 2>/dev/null && bcmAllowed=1
|
||||
git ls-remote git@dev.iopsys.eu:mediatek/linux.git -q 2>/dev/null && mediatekAllowed=1
|
||||
#git ls-remote git@dev.iopsys.eu:mediatek/linux.git -q 2>/dev/null && mediatekAllowed=1
|
||||
git ls-remote git@dev.iopsys.eu:dialog/natalie-dect-12.26.git -q 2>/dev/null && natalieAllowed=1
|
||||
git ls-remote git@dev.iopsys.eu:iopsys/endptmngr.git -q 2>/dev/null && endptAllowed=1
|
||||
git ls-remote git@dev.iopsys.eu:iopsys/wifilife.git -q 2>/dev/null && wifilifeAllowed=1
|
||||
}
|
||||
|
||||
v() {
|
||||
@@ -162,6 +207,7 @@ function genconfig {
|
||||
echo -e " -c|--clean\t\tRemove all files under ./files and import from config "
|
||||
echo -e " -v|--verbose\t\tVerbose"
|
||||
echo -e " -n|--no-update\tDo NOT! Update customer config before applying"
|
||||
echo -e " -t|--target\t\tExplicitly specify the linux target to build the board profile from"
|
||||
echo -e " -s|--override\t\tEnable 'Package source tree override'"
|
||||
echo -e " -S|--brcmsingle\tForce build of bcmkernel to use only one thread"
|
||||
echo -e " -h|--help\t\tShow this message"
|
||||
@@ -169,7 +215,7 @@ function genconfig {
|
||||
echo -e " -a|--list-all\t\tList all Customers and their board types"
|
||||
echo -e " -b|--boards\t\tList all board types"
|
||||
echo
|
||||
echo "Example ./iop genconfig dg200 TELIA"
|
||||
echo "Example ./iop genconfig eg400 OPERATORX"
|
||||
echo "(if no customerconfig is chosen, iopsys config will be used)"
|
||||
echo
|
||||
exit 0
|
||||
@@ -220,28 +266,30 @@ function genconfig {
|
||||
|
||||
generate_config()
|
||||
{
|
||||
DIFFFILE="$1"
|
||||
MASTERFILE="$2"
|
||||
while read p; do
|
||||
v "$p"
|
||||
sed -r -i "$p" $MASTERFILE
|
||||
done < $DIFFFILE
|
||||
DIFFFILE="$1"
|
||||
MASTERFILE="$2"
|
||||
while read p; do
|
||||
v "$p"
|
||||
sed -r -i "$p" $MASTERFILE
|
||||
done < $DIFFFILE
|
||||
}
|
||||
|
||||
setup_dirs()
|
||||
{
|
||||
if git ls-remote $CUSTREPO -q 2>/dev/null; then
|
||||
if [ ! -d "$CUSTPATH" ]; then
|
||||
git clone "$CUSTREPO" "$CUSTPATH"
|
||||
elif [ $IMPORT -eq 1 ]; then
|
||||
cd $CUSTPATH
|
||||
v "git pull"
|
||||
git pull
|
||||
cd - >/dev/null #go back
|
||||
git remote -v | grep -q http || {
|
||||
if git ls-remote $CUSTREPO -q 2>/dev/null; then
|
||||
if [ ! -d "$CUSTPATH" ]; then
|
||||
git clone "$CUSTREPO" "$CUSTPATH"
|
||||
elif [ $IMPORT -eq 1 ]; then
|
||||
cd $CUSTPATH
|
||||
v "git pull"
|
||||
git pull
|
||||
cd - >/dev/null #go back
|
||||
fi
|
||||
else
|
||||
echo "You do not have access to $CUSTREPO"
|
||||
fi
|
||||
else
|
||||
echo "You do not have access to $CUSTREPO"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ ! -d "$FILEDIR" ]; then
|
||||
mkdir -p $FILEDIR
|
||||
@@ -291,14 +339,16 @@ function genconfig {
|
||||
v "cp $CONFIGPATH/config .config"
|
||||
cp $CONFIGPATH/config .config
|
||||
|
||||
if [ -f $config_path/config ]; then
|
||||
cat $config_path/config >> .config
|
||||
if [ -f $target_config_path/config ]; then
|
||||
cat $target_config_path/config >> .config
|
||||
echo "" >> .config
|
||||
fi
|
||||
if [ -f $config_path/$BOARDTYPE/config ]; then
|
||||
cat $config_path/$BOARDTYPE/config >> .config
|
||||
if [ -f $target_config_path/$BOARDTYPE/config ]; then
|
||||
cat $target_config_path/$BOARDTYPE/config >> .config
|
||||
echo "" >> .config
|
||||
fi
|
||||
|
||||
#special handling for intel_mips which use TARGET_DEVICES
|
||||
#special handling for intel_mips/iopsys_ramips which use TARGET_DEVICES
|
||||
if [ "$target" = "intel_mips" ]; then
|
||||
subtarget="xrx500"
|
||||
echo "CONFIG_TARGET_${target}=y" >> .config
|
||||
@@ -307,6 +357,18 @@ function genconfig {
|
||||
echo "CONFIG_TARGET_PER_DEVICE_ROOTFS=y" >> .config
|
||||
device=$(echo $BOARDTYPE | tr a-z A-Z)
|
||||
echo "CONFIG_TARGET_DEVICE_${target}_${subtarget}_DEVICE_${device}=y" >> .config
|
||||
elif [ "$target" = "iopsys_ramips" ]; then
|
||||
subtarget="mt7621"
|
||||
echo "CONFIG_TARGET_${target}=y" >> .config
|
||||
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
|
||||
echo "CONFIG_TARGET_${target}_${subtarget}_DEVICE_${BOARDTYPE}=y" >> .config
|
||||
elif [ "$target" = "iopsys_bcm27xx" ]; then
|
||||
subtarget="iopsys_bcm2711"
|
||||
echo "CONFIG_TARGET_${target}=y" >> .config
|
||||
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
|
||||
echo "CONFIG_TARGET_MULTI_PROFILE=y" >> .config
|
||||
echo "CONFIG_TARGET_PER_DEVICE_ROOTFS=y" >> .config
|
||||
echo "CONFIG_TARGET_DEVICE_${target}_${subtarget}_DEVICE_${BOARDTYPE}=y" >> .config
|
||||
else
|
||||
echo "CONFIG_TARGET_${target}=y" >> .config
|
||||
echo "CONFIG_TARGET_${target}_${BOARDTYPE}=y" >> .config
|
||||
@@ -333,10 +395,12 @@ function genconfig {
|
||||
if [ -e "$CUSTCONF/$CUSTOMER/common/common.diff" ]; then
|
||||
v "Apply $CUSTCONF/$CUSTOMER/common/common.diff"
|
||||
cat $CUSTCONF/$CUSTOMER/common/common.diff >> .config
|
||||
echo "" >> .config
|
||||
fi
|
||||
if [ -e "$CUSTCONF/$CUSTOMER/$BOARDTYPE/$BOARDTYPE.diff" ]; then
|
||||
v "Apply $CUSTCONF/$CUSTOMER/$BOARDTYPE/$BOARDTYPE.diff"
|
||||
cat $CUSTCONF/$CUSTOMER/$BOARDTYPE/$BOARDTYPE.diff >> .config
|
||||
echo "" >> .config
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@@ -344,6 +408,8 @@ function genconfig {
|
||||
# Set target version
|
||||
local GIT_TAG=$(git describe --abbrev=0 --tags)
|
||||
echo "CONFIG_TARGET_VERSION=\"${GIT_TAG}\"" >> .config
|
||||
echo "CONFIG_VERSION_CODE=\"${GIT_TAG}\"" >> .config
|
||||
echo "CONFIG_VERSION_PRODUCT=\"$BOARDTYPE"\" >> .config
|
||||
|
||||
# Enable Pckage source tree override if selected
|
||||
[ $SRCTREEOVERR -eq 1 ] && echo CONFIG_SRC_TREE_OVERRIDE=y >> .config
|
||||
@@ -356,15 +422,13 @@ function genconfig {
|
||||
[ $bcmAllowed -eq 0 ] && echo "CONFIG_BCM_OPEN=y" >> .config
|
||||
[ $endptAllowed -eq 0 ] && echo "CONFIG_ENDPT_OPEN=y" >> .config
|
||||
[ $natalieAllowed -eq 0 ] && echo "CONFIG_NATALIE_OPEN=y" >> .config
|
||||
[ $mediatekAllowed -eq 0 ] && echo "CONFIG_MEDIATEK_OPEN=y" >> .config
|
||||
[ $wifilifeAllowed -eq 0 ] && echo "CONFIG_WIFILIFE_OPEN=y" >> .config
|
||||
#[ $mediatekAllowed -eq 0 ] && echo "CONFIG_MEDIATEK_OPEN=y" >> .config
|
||||
else
|
||||
echo "# CONFIG_GITMIRROR_REWRITE is not set" >>.config
|
||||
echo "CONFIG_BCM_OPEN=y" >> .config
|
||||
echo "CONFIG_ENDPT_OPEN=y" >> .config
|
||||
echo "CONFIG_NATALIE_OPEN=y" >> .config
|
||||
echo "CONFIG_MEDIATEK_OPEN=y" >> .config
|
||||
echo "CONFIG_WIFILIFE_OPEN=y" >> .config
|
||||
#echo "CONFIG_MEDIATEK_OPEN=y" >> .config
|
||||
fi
|
||||
|
||||
if [ -n "$BRCM_MAX_JOBS" ]
|
||||
@@ -380,7 +444,7 @@ function genconfig {
|
||||
touch package/kernel/linux/Makefile
|
||||
|
||||
# we need to signal to bradcom SDK that we have changed the board id
|
||||
# currently boardparms.c and boardparms_voice.c is the only place that is depending on inteno boardid name
|
||||
# currently boardparms.c and boardparms_voice.c is the only place that is depending on boardid name
|
||||
# so just touch that file.
|
||||
[ -d ./build_dir ] && find build_dir/ -name "boardparms*c" -print0 2>/dev/null | xargs -0 touch 2>/dev/null
|
||||
|
||||
@@ -417,6 +481,7 @@ function genconfig {
|
||||
-c|--clean) export CLEAN=1;;
|
||||
-n|--no-update) export IMPORT=0;;
|
||||
-v|--verbose) export VERBOSE="$(($VERBOSE + 1))";;
|
||||
-t|--target) export TARGET="$2"; shift;;
|
||||
-p|--profile) export PROFILE="$2"; shift;;
|
||||
-r|--repo) export CUSTREPO="$2"; shift;;
|
||||
-s|--override) export SRCTREEOVERR=1;;
|
||||
|
||||
461
iop/scripts/genconfig_min.sh
Normal file
461
iop/scripts/genconfig_min.sh
Normal file
@@ -0,0 +1,461 @@
|
||||
#!/bin/bash
|
||||
|
||||
function genconfig_min {
|
||||
export CLEAN=0
|
||||
export SRCTREEOVERR=0
|
||||
export FILEDIR="files/"
|
||||
CURRENT_CONFIG_FILE=".current_config_file"
|
||||
export CONFIGPATH="package/feeds/iopsys/iop"
|
||||
CUSTPATH="customerconfigs"
|
||||
export CUSTCONF="customerconfigs/customers"
|
||||
export VERBOSE=0
|
||||
#always use the mirror
|
||||
export DEVELOPER=0
|
||||
target="bogus"
|
||||
config_path=""
|
||||
bcm27xx="target/linux/iopsys-bcm27xx"
|
||||
brcm63xx_arm="target/linux/iopsys-brcm63xx-arm"
|
||||
ramips="target/linux/iopsys-ramips"
|
||||
intel_mips="target/linux/intel_mips"
|
||||
x86="target/linux/iopsys-x86"
|
||||
armvirt="target/linux/iopsys-armvirt"
|
||||
|
||||
Red='\033[0;31m' # Red
|
||||
Color_Off='\033[0m' # Text Reset
|
||||
Yellow='\033[0;33m' # Yellow
|
||||
|
||||
function find_last {
|
||||
egrep "^[ #]*${1}[ =]" $2 | tail -n1
|
||||
}
|
||||
|
||||
function is_new {
|
||||
for opt in $conf_warned
|
||||
do
|
||||
if [ "$opt" == "$1" ]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
# option not found return true
|
||||
return 0
|
||||
}
|
||||
|
||||
function verify_config {
|
||||
IFS=$'\n'
|
||||
org=$(<.genconfig.config)
|
||||
unset IFS
|
||||
local num
|
||||
local conf_opt
|
||||
local conf_org
|
||||
local conf_new
|
||||
|
||||
#echo "lines to check $tot_lines"
|
||||
num=0
|
||||
for line in $org
|
||||
do
|
||||
conf_opt=$(echo $line | grep CONFIG_ | sed 's|.*\(CONFIG_[^ =]*\)[ =].*|\1|')
|
||||
if [ -n "${conf_opt}" ]
|
||||
then
|
||||
conf_org=$(find_last ${conf_opt} .genconfig.config)
|
||||
conf_new=$(find_last ${conf_opt} .config)
|
||||
if [ "$conf_org" != "$conf_new" ]
|
||||
then
|
||||
if is_new $conf_opt
|
||||
then
|
||||
echo -e "config option [${Red}$conf_opt${Color_Off}] is not set correctly in .config"
|
||||
echo -e "got value [${Yellow}$conf_new${Color_Off}] but wanted [${Yellow}$conf_org${Color_Off}]"
|
||||
echo "This is a real problem somebody needs to investigate"
|
||||
echo ""
|
||||
conf_warned="$conf_warned $conf_opt"
|
||||
fi
|
||||
else
|
||||
true
|
||||
# for debug to see all options
|
||||
#echo -e "wanted [$conf_org] got [$conf_new]"
|
||||
fi
|
||||
fi
|
||||
num=$((num+1))
|
||||
done
|
||||
}
|
||||
|
||||
# Takes a board name and returns the target name in global var $target
|
||||
set_target() {
|
||||
local profile=$1
|
||||
|
||||
[ -n "$profile" ] || return
|
||||
|
||||
if [ -n "$TARGET" -a -d "./target/linux/$TARGET" ]; then
|
||||
local targetpath="./target/linux/$TARGET"
|
||||
local profiles=
|
||||
local pfound=0
|
||||
|
||||
if [ -e "$targetpath/genconfig" ]; then
|
||||
profiles=$(cd $targetpath; ./genconfig)
|
||||
|
||||
for p in $profiles; do
|
||||
if [ $p == $profile ]; then
|
||||
pfound=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ $pfound -eq 1 ]; then
|
||||
target="$(echo $TARGET | tr '-' '_')"
|
||||
config_path="$targetpath/config"
|
||||
fi
|
||||
|
||||
return
|
||||
fi
|
||||
|
||||
[ -e $brcm63xx_arm/genconfig ] &&
|
||||
iopsys_brcm63xx_arm=$(cd $brcm63xx_arm; ./genconfig)
|
||||
[ -e $ramips/genconfig ] &&
|
||||
iopsys_ramips=$(cd $ramips; ./genconfig)
|
||||
[ -e $intel_mips/genconfig ] &&
|
||||
iopsys_intel_mips=$(cd $intel_mips; ./genconfig)
|
||||
[ -e $x86/genconfig ] &&
|
||||
iopsys_x86=$(cd $x86; ./genconfig)
|
||||
[ -e $armvirt/genconfig ] &&
|
||||
iopsys_armvirt=$(cd $armvirt; ./genconfig)
|
||||
[ -e $bcm27xx/genconfig ] &&
|
||||
iopsys_bcm27xx=$(cd $bcm27xx; ./genconfig)
|
||||
|
||||
if [ "$profile" == "LIST" ]; then
|
||||
for list in iopsys_brcm63xx_arm iopsys_ramips iopsys_intel_mips iopsys_x86 iopsys_armvirt iopsys_bcm27xx; do
|
||||
echo "$list based boards:"
|
||||
for b in ${!list}; do
|
||||
echo -e "\t$b"
|
||||
done
|
||||
done
|
||||
return
|
||||
fi
|
||||
|
||||
for p in $iopsys_brcm63xx_arm; do
|
||||
if [ $p == $profile ]; then
|
||||
target="iopsys_brcm63xx_arm"
|
||||
config_path="$brcm63xx_arm/config"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
for p in $iopsys_ramips; do
|
||||
if [ $p == $profile ]; then
|
||||
target="iopsys_ramips"
|
||||
config_path="$ramips/config"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
for p in $iopsys_intel_mips; do
|
||||
if [ $p == $profile ]; then
|
||||
target="intel_mips"
|
||||
config_path="$intel_mips/config"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
for p in $iopsys_x86; do
|
||||
if [ $p == $profile ]; then
|
||||
target="iopsys_x86"
|
||||
config_path="$x86/config"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
for p in $iopsys_armvirt; do
|
||||
if [ $p == $profile ]; then
|
||||
target="iopsys_armvirt"
|
||||
config_path="$armvirt/config"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
for p in $iopsys_bcm27xx; do
|
||||
if [ $p == $profile ]; then
|
||||
target="iopsys_bcm27xx"
|
||||
config_path="$bcm27xx/config"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
git remote -v | grep -q http || {
|
||||
DEVELOPER=1
|
||||
|
||||
bcmAllowed=0
|
||||
endptAllowed=0
|
||||
natalieAllowed=0
|
||||
mediatekAllowed=0
|
||||
|
||||
git ls-remote git@dev.iopsys.eu:broadcom/bcmcreator.git -q 2>/dev/null && bcmAllowed=1
|
||||
git ls-remote git@dev.iopsys.eu:mediatek/linux.git -q 2>/dev/null && mediatekAllowed=1
|
||||
git ls-remote git@dev.iopsys.eu:dialog/natalie-dect-12.26.git -q 2>/dev/null && natalieAllowed=1
|
||||
git ls-remote git@dev.iopsys.eu:iopsys/endptmngr.git -q 2>/dev/null && endptAllowed=1
|
||||
}
|
||||
|
||||
v() {
|
||||
[ "$VERBOSE" -ge 1 ] && echo "$@"
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo
|
||||
echo 1>&2 "Usage: $0 [ OPTIONS ] < Board_Type > [ Customer [customer2 ]...]"
|
||||
echo
|
||||
echo -e " -c|--clean\t\tRemove all files under ./files and import from config "
|
||||
echo -e " -v|--verbose\t\tVerbose"
|
||||
echo -e " -n|--no-update\tDo NOT! Update customer config before applying"
|
||||
echo -e " -t|--target\t\tExplicitly specify the linux target to build the board profile from"
|
||||
echo -e " -s|--override\t\tEnable 'Package source tree override'"
|
||||
echo -e " -S|--brcmsingle\tForce build of bcmkernel to use only one thread"
|
||||
echo -e " -h|--help\t\tShow this message"
|
||||
echo -e " -l|--list [customer]\tList all Customers or all boards for one customer"
|
||||
echo -e " -a|--list-all\t\tList all Customers and their board types"
|
||||
echo -e " -b|--boards\t\tList all board types"
|
||||
echo
|
||||
echo "Example ./iop genconfig dg400prime IOPSYS"
|
||||
echo
|
||||
exit 0
|
||||
}
|
||||
|
||||
list_customers()
|
||||
{
|
||||
local ALL="$1"
|
||||
local CUSTOMER="$2"
|
||||
if [ "$CUSTOMER" -a -d "$CUSTCONF/$CUSTOMER" ]; then
|
||||
local boards="$(ls -1 "$CUSTCONF/$CUSTOMER" | grep -v common )"
|
||||
if [ "$boards" ]; then
|
||||
echo "$CUSTOMER has following boards:"
|
||||
for board in $boards; do
|
||||
echo -e "\t$board"
|
||||
done
|
||||
else
|
||||
echo "No boards found for $CUSTOMER"
|
||||
fi
|
||||
elif [ "$CUSTOMER" ]; then
|
||||
echo "No customer called $CUSTOMER"
|
||||
exit 1
|
||||
elif [ -d $CUSTCONF ]; then
|
||||
local customers="$(ls -1 $CUSTCONF)"
|
||||
if [ "$customers" -a "$ALL" == 1 ]; then
|
||||
for customer in $customers; do
|
||||
echo $customer
|
||||
local boards="$(ls -1 $CUSTCONF/$customer | grep -v common )"
|
||||
if [ "$boards" ]; then
|
||||
for board in $boards; do
|
||||
echo -e "\t$board"
|
||||
done
|
||||
else
|
||||
echo "has no boards"
|
||||
fi
|
||||
done
|
||||
elif [ "$customers" ]; then
|
||||
echo -e "$customers"
|
||||
else
|
||||
echo "no customers found"
|
||||
fi
|
||||
else
|
||||
echo "No $CUSTCONF folder found"
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
generate_config()
|
||||
{
|
||||
DIFFFILE="$1"
|
||||
MASTERFILE="$2"
|
||||
while read p; do
|
||||
v "$p"
|
||||
sed -r -i "$p" $MASTERFILE
|
||||
done < $DIFFFILE
|
||||
}
|
||||
|
||||
setup_dirs()
|
||||
{
|
||||
|
||||
if [ ! -d "$FILEDIR" ]; then
|
||||
mkdir -p $FILEDIR
|
||||
elif [ -d "$FILEDIR" -a $CLEAN -eq 1 ]; then
|
||||
v "rm -rf $FILEDIR*"
|
||||
rm -rf $FILEDIR*
|
||||
fi
|
||||
}
|
||||
|
||||
create_and_copy_files()
|
||||
{
|
||||
local BOARDTYPE=$1
|
||||
shift
|
||||
local CUSTOMERS=$@
|
||||
|
||||
# Validate seleced board and customers
|
||||
set_target $BOARDTYPE
|
||||
if [ $target == "bogus" ]; then
|
||||
echo "Hardware profile does not exist"
|
||||
exit 1
|
||||
elif [ -n "$CUSTOMERS" ]; then
|
||||
for CUSTOMER in $CUSTOMERS; do
|
||||
if [ ! -d "$CUSTCONF/$CUSTOMER/" ]; then
|
||||
echo "Customer profile for '$CUSTOMER' does not exist"
|
||||
exit 1
|
||||
elif [ ! -d "$CUSTCONF/$CUSTOMER/$BOARDTYPE/" ]; then
|
||||
echo "'$BOARDTYPE' board profile does not exist for customer '$CUSTOMER'"
|
||||
if [ -f "$CUSTCONF/$CUSTOMER/common/common.diff" ]; then
|
||||
echo "Common profile configuration will be used"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Generate base config
|
||||
rm -f .config
|
||||
v "Config $BOARDTYPE selected"
|
||||
v "cp $CONFIGPATH/config .config"
|
||||
cp $CONFIGPATH/config .config
|
||||
|
||||
if [ -f $config_path/config ]; then
|
||||
cat $config_path/config >> .config
|
||||
fi
|
||||
if [ -f $config_path/$BOARDTYPE/config ]; then
|
||||
cat $config_path/$BOARDTYPE/config >> .config
|
||||
fi
|
||||
|
||||
#special handling for intel_mips/iopsys_ramips which use TARGET_DEVICES
|
||||
if [ "$target" = "intel_mips" ]; then
|
||||
subtarget="xrx500"
|
||||
echo "CONFIG_TARGET_${target}=y" >> .config
|
||||
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
|
||||
echo "CONFIG_TARGET_MULTI_PROFILE=y" >> .config
|
||||
echo "CONFIG_TARGET_PER_DEVICE_ROOTFS=y" >> .config
|
||||
device=$(echo $BOARDTYPE | tr a-z A-Z)
|
||||
echo "CONFIG_TARGET_DEVICE_${target}_${subtarget}_DEVICE_${device}=y" >> .config
|
||||
elif [ "$target" = "iopsys_ramips" ]; then
|
||||
subtarget="mt7621"
|
||||
echo "CONFIG_TARGET_${target}=y" >> .config
|
||||
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
|
||||
echo "CONFIG_TARGET_${target}_${subtarget}_DEVICE_${BOARDTYPE}=y" >> .config
|
||||
elif [ "$target" = "iopsys_bcm27xx" ]; then
|
||||
subtarget="iopsys_bcm2711"
|
||||
echo "CONFIG_TARGET_${target}=y" >> .config
|
||||
echo "CONFIG_TARGET_${target}_${subtarget}=y" >> .config
|
||||
echo "CONFIG_TARGET_MULTI_PROFILE=y" >> .config
|
||||
echo "CONFIG_TARGET_PER_DEVICE_ROOTFS=y" >> .config
|
||||
device=$(echo $BOARDTYPE | tr a-z A-Z)
|
||||
echo "CONFIG_TARGET_DEVICE_${target}_${subtarget}_DEVICE_${BOARDTYPE}=y" >> .config
|
||||
else
|
||||
echo "CONFIG_TARGET_${target}=y" >> .config
|
||||
echo "CONFIG_TARGET_${target}_${BOARDTYPE}=y" >> .config
|
||||
fi
|
||||
|
||||
echo "$CUSTOMERS $BOARDTYPE" > $CURRENT_CONFIG_FILE
|
||||
|
||||
# Add customerconfig diff if a customer is selected
|
||||
if [ -n "$CUSTOMERS" ]; then
|
||||
for CUSTOMER in $CUSTOMERS; do
|
||||
if [ -d "$CUSTCONF/$CUSTOMER/common/fs" ]; then
|
||||
v "cp -ar $CUSTCONF/$CUSTOMER/common/fs/* $FILEDIR"
|
||||
cp -ar $CUSTCONF/$CUSTOMER/common/fs/* $FILEDIR
|
||||
fi
|
||||
if [ -d "$CUSTCONF/$CUSTOMER/$BOARDTYPE/fs" ]; then
|
||||
v "cp -ar $CUSTCONF/$CUSTOMER/$BOARDTYPE/fs/* $FILEDIR"
|
||||
cp -ar $CUSTCONF/$CUSTOMER/$BOARDTYPE/fs/* $FILEDIR
|
||||
fi
|
||||
if [ -e "$CUSTCONF/$CUSTOMER/common/common.diff" ]; then
|
||||
v "Apply $CUSTCONF/$CUSTOMER/common/common.diff"
|
||||
cat $CUSTCONF/$CUSTOMER/common/common.diff >> .config
|
||||
fi
|
||||
if [ -e "$CUSTCONF/$CUSTOMER/$BOARDTYPE/$BOARDTYPE.diff" ]; then
|
||||
v "Apply $CUSTCONF/$CUSTOMER/$BOARDTYPE/$BOARDTYPE.diff"
|
||||
cat $CUSTCONF/$CUSTOMER/$BOARDTYPE/$BOARDTYPE.diff >> .config
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Set target version
|
||||
local GIT_TAG=$(git describe --abbrev=0 --tags)
|
||||
echo "CONFIG_TARGET_VERSION=\"${GIT_TAG}\"" >> .config
|
||||
echo "CONFIG_VERSION_CODE=\"${GIT_TAG}\"" >> .config
|
||||
echo "CONFIG_VERSION_PRODUCT=\"$BOARDTYPE"\" >> .config
|
||||
|
||||
|
||||
# Enable Package source tree override if selected
|
||||
[ $SRCTREEOVERR -eq 1 ] && echo CONFIG_SRC_TREE_OVERRIDE=y >> .config
|
||||
|
||||
# developer mode selected ?
|
||||
echo "CONFIG_DEVEL=y" >>.config
|
||||
|
||||
if [ -n "$BRCM_MAX_JOBS" ]
|
||||
then
|
||||
echo "CONFIG_BRCM_MAX_JOBS=\"1\"" >>.config
|
||||
fi
|
||||
|
||||
# Force regeneration of kernel Makefile
|
||||
# Needed to disable kmods for iopsys-brcm targets
|
||||
touch package/kernel/linux/Makefile
|
||||
|
||||
# we need to signal to bradcom SDK that we have changed the board id
|
||||
# currently boardparms.c and boardparms_voice.c is the only place that is depending on boardid name
|
||||
# so just touch that file.
|
||||
[ -d ./build_dir ] && find build_dir/ -name "boardparms*c" -print0 2>/dev/null | xargs -0 touch 2>/dev/null
|
||||
|
||||
# Store generated config
|
||||
cp .config .genconfig.config
|
||||
|
||||
# Set default values based on selected parameters
|
||||
v "$(make defconfig 2>&1)"
|
||||
|
||||
echo Set version to $(grep -w CONFIG_TARGET_VERSION .config | cut -d'=' -f2 | tr -d '"')
|
||||
|
||||
# Clean base-file package to force rebuild when changing profile
|
||||
v "$(make package/base-files/clean 2>&1)"
|
||||
|
||||
verify_config
|
||||
}
|
||||
|
||||
####### main #####
|
||||
if [ ! -e tmp/.iop_bootstrap ]; then
|
||||
echo "You have not installed feeds. Running genconfig in this state would create a non functional configuration."
|
||||
echo "Run: iop feeds_update"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo Current profile:
|
||||
cat $CURRENT_CONFIG_FILE
|
||||
echo "Try ./iop genconfig -h' to get instructions if you want to change current config"
|
||||
exit 0
|
||||
else
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
|
||||
-c|--clean) export CLEAN=1;;
|
||||
-n|--no-update) export IMPORT=0;;
|
||||
-v|--verbose) export VERBOSE="$(($VERBOSE + 1))";;
|
||||
-t|--target) export TARGET="$2"; shift;;
|
||||
-p|--profile) export PROFILE="$2"; shift;;
|
||||
-r|--repo) export CUSTREPO="$2"; shift;;
|
||||
-s|--override) export SRCTREEOVERR=1;;
|
||||
-S|--brcmsingel) export BRCM_MAX_JOBS=1;;
|
||||
-h|--help) usage;;
|
||||
-l|--list) list_customers 0 $2;;
|
||||
-a|--list-all)list_customers 1;;
|
||||
-b|--boards)set_target LIST;exit 0;;
|
||||
-*)
|
||||
echo "Invalid option: $1 "
|
||||
echo "Try -h or --help for more information."
|
||||
exit 1
|
||||
;;
|
||||
*) break;;
|
||||
esac
|
||||
shift;
|
||||
done
|
||||
|
||||
setup_dirs
|
||||
create_and_copy_files "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
register_command "genconfig_min" "Generate configuration for customer with manual board configuration"
|
||||
@@ -1,21 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# shellcheck disable=SC2029
|
||||
|
||||
build_bcmkernel_consumer() {
|
||||
local tarfile bcmkernelcommith sdkversion
|
||||
sdkversion=$(grep "CONFIG_BRCM_SDK_VER.*=y" .config | awk -F'[_,=]' '{print$5}')
|
||||
sdkversion=${sdkversion:0:4}${sdkversion:(-1)}
|
||||
bcmkernelcommith=$(grep -w "PKG_SOURCE_VERSION:" $curdir/feeds/broadcom/bcmkernel/${sdkversion:0:5}*.mk | cut -d'=' -f2)
|
||||
local tarfile bcmkernelcommith sdkversion serverpath serverlink
|
||||
|
||||
sdkversion="$(grep "CONFIG_BRCM_SDK_VER.*=y" .config | awk -F'[_,=]' '{print$5}')"
|
||||
sdkversion="${sdkversion:0:4}${sdkversion:(-1)}"
|
||||
bcmkernelcommith="$(grep -w "PKG_SOURCE_VERSION:" "$curdir/feeds/broadcom/bcmkernel/${sdkversion:0:5}"*".mk" | cut -d'=' -f2)"
|
||||
|
||||
[ -n "$board" ] && [ -n "$bcmkernelcommith" ] || return
|
||||
|
||||
serverpath="$FPATH/bcmopen-$board-$bcmkernelcommith.tar.gz"
|
||||
serverlink="$FPATH/bcmopen-$board-$majver.$minver-latest"
|
||||
|
||||
# do not build bcmopen sdk if it was already built before
|
||||
[ -n "$board" -a -n "$bcmkernelcommith" ] || return
|
||||
ssh $SERVER "test -f $FPATH/bcmopen-$board-$bcmkernelcommith.tar.gz" && return
|
||||
cd ./build_dir/target-*/bcmkernel-*-${sdkversion:0:4}*/bcm963xx/release
|
||||
bash do_consumer_release -p $profile -y -F
|
||||
# if it was, check if there's a symlink in place and create it if missing
|
||||
ssh "$SERVER" "test -f '$serverpath' && { test -L '$serverlink' || ln -sf '$serverpath' '$serverlink'; }" && return
|
||||
|
||||
cd "./build_dir/target-"*"/bcmkernel-"*"-${sdkversion:0:4}"*"/bcm963xx/release"
|
||||
bash do_consumer_release -p "$profile" -y -F
|
||||
|
||||
tarfile='out/bcm963xx_*_consumer.tar.gz'
|
||||
[ $(ls -1 $tarfile |wc -l) -ne 1 ] && echo "Too many tar files: '$tarfile'" && return
|
||||
scp -pv $tarfile $SERVER:$FPATH/bcmopen-$board-$bcmkernelcommith.tar.gz
|
||||
ssh $SERVER "[ -f $FPATH/bcmopen-$board-$bcmkernelcommith.tar.gz ] && ln -sf $FPATH/bcmopen-$board-$bcmkernelcommith.tar.gz $FPATH/bcmopen-$board-$majver.$minver-latest"
|
||||
[ $(ls -1 $tarfile | wc -l) -ne 1 ] && echo "Too many tar files: '$tarfile'" && return
|
||||
|
||||
scp -pv $tarfile "$SERVER":"$serverpath"
|
||||
ssh "$SERVER" "test -f '$serverpath' && ln -sf '$serverpath' '$serverlink'"
|
||||
rm -f $tarfile
|
||||
|
||||
cd "$curdir"
|
||||
}
|
||||
|
||||
@@ -25,7 +36,7 @@ build_natalie_consumer() {
|
||||
grep -q "CONFIG_TARGET_NO_DECT=y" .config && return
|
||||
natalieversion=$(grep -w "PKG_VERSION:" ./feeds/iopsys/natalie-dect/Makefile | cut -d'=' -f2)
|
||||
nataliecommith=$(grep -w "PKG_SOURCE_VERSION:" ./feeds/iopsys/natalie-dect/Makefile | cut -d'=' -f2)
|
||||
[ -n "$profile" -a -n "$natalieversion" -a -n "$nataliecommith" ] || return
|
||||
[ -n "$profile" ] && [ -n "$natalieversion" ] && [ -n "$nataliecommith" ] || return
|
||||
ssh $SERVER "test -f $FPATH/natalie-dect-$profile-$natalieversion-$nataliecommith.tar.gz" && return
|
||||
cd ./build_dir/target-*/natalie-dect-$natalieversion/
|
||||
mkdir natalie-dect-open-$natalieversion
|
||||
@@ -44,7 +55,7 @@ build_endptmngr_consumer() {
|
||||
grep -q "CONFIG_TARGET_NO_VOICE=y" .config && return
|
||||
endptversion=$(grep -w "PKG_VERSION:" ./feeds/iopsys/endptmngr/Makefile | cut -d'=' -f2)
|
||||
endptcommith=$(grep -w "PKG_SOURCE_VERSION:" ./feeds/iopsys/endptmngr/Makefile | cut -d'=' -f2)
|
||||
[ -n "$profile" -a -n "$endptversion" -a -n "$endptcommith" ] || return
|
||||
[ -n "$profile" ] && [ -n "$endptversion" ] && [ -n "$endptcommith" ] || return
|
||||
ssh $SERVER "test -f $FPATH/endptmngr-$profile-$endptversion-$endptcommith.tar.gz" && return
|
||||
cd ./build_dir/target-*/endptmngr-$endptversion/
|
||||
mkdir endptmngr-open-$endptversion
|
||||
@@ -59,45 +70,19 @@ build_endptmngr_consumer() {
|
||||
cd "$curdir"
|
||||
}
|
||||
|
||||
build_wifilife_consumer() {
|
||||
local ver commit
|
||||
ver=$(grep -w "PKG_VERSION:" ./feeds/iopsys/wifilife/Makefile | cut -d'=' -f2)
|
||||
commit=$(grep -w "PKG_SOURCE_VERSION:" ./feeds/iopsys/wifilife/Makefile | cut -d'=' -f2)
|
||||
[ -n "$ver" -a -n "$commit" ] || return
|
||||
ssh $SERVER "test -f $FPATH/wifilife-$target-${ver}_${commit}.tar.xz" && return
|
||||
cd ./build_dir/target-*/wifilife-$ver/ipkg-* || cd ./build_dir/target-mips*musl-*/wifilife-$ver/ipkg-*
|
||||
mkdir -p wifilife-$ver/src
|
||||
cp -rf wifilife/usr/sbin/* wifilife-$ver/src/
|
||||
tar Jcf wifilife-${target}-${ver}_${commit}.tar.xz wifilife-$ver
|
||||
scp -pv wifilife-$target-${ver}_${commit}.tar.xz $SERVER:$FPATH/
|
||||
cp wifilife-${target}-${ver}_${commit}.tar.xz $curdir/
|
||||
rm -rf wifilife-$ver
|
||||
rm -f wifilife-${target}-${ver}_${commit}.tar.xz
|
||||
cd "$curdir"
|
||||
}
|
||||
|
||||
build_mediatek_kernel() {
|
||||
local mediatek_commit kernel_version kernel
|
||||
local mediatek_commit kernel
|
||||
|
||||
mediatek_commit=$(grep CONFIG_KERNEL_GIT_COMMIT .config | cut -d '=' -f2 | tr -d '"')
|
||||
kernel_version=$(grep KERNEL_PATCHVER target/linux/iopsys-ramips/Makefile | cut -d '=' -f2)
|
||||
kernel=linux-${kernel_version}.*
|
||||
kernel=linux-git*
|
||||
[ -n "$mediatek_commit" ] || return
|
||||
ssh $SERVER "test -f $FPATH/mediatek-kernel-open-$mediatek_commit.tar.gz" && return
|
||||
echo "Building mediatek kernel tarball from kernel commit:"
|
||||
echo $mediatek_commit
|
||||
cd build_dir/target-mipsel_1004kc*/linux-iopsys-ramips*/$kernel
|
||||
|
||||
# Save Kconfig files to recreate the same kernel config,
|
||||
# delete everyting else.
|
||||
find drivers/net/wireless/mt_wifi -type f ! -name Kconfig | xargs rm
|
||||
find drivers/net/wireless/rlt_wifi -type f ! -name Kconfig | xargs rm
|
||||
cd build_dir/target-mipsel_1004kc*/linux-iopsys-ramips*/linux-git*
|
||||
|
||||
# remove git repo
|
||||
rm -rf .git
|
||||
|
||||
# patch kernel for openstk
|
||||
ls consumer_release | while read line; do patch -p1 < consumer_release/$line; done
|
||||
cd ..
|
||||
|
||||
tar -czv $kernel -f mediatek-kernel-open-$mediatek_commit.tar.gz
|
||||
@@ -105,6 +90,26 @@ build_mediatek_kernel() {
|
||||
cd "$curdir"
|
||||
}
|
||||
|
||||
build_mediatek_wifi_consumer() {
|
||||
local ver commit
|
||||
local chip=$1
|
||||
|
||||
ver=$(grep -w "PKG_VERSION:" ./feeds/mediatek/mt${chip}/Makefile | cut -d'=' -f2)
|
||||
commit=$(grep -w "PKG_SOURCE_VERSION:" ./feeds/mediatek/mt${chip}/Makefile | cut -d'=' -f2)
|
||||
[ -n "$ver" ] && [ -n "$commit" ] || return
|
||||
ssh $SERVER "test -f $FPATH/mtk${chip}e-${ver}_${commit}.tar.xz" && return
|
||||
cd build_dir/target-mipsel_1004kc*/linux-iopsys-ramips*/mtk${chip}e-$ver/ipkg-*
|
||||
mkdir -p mtk${chip}e-$ver/src
|
||||
cp -rf kmod-mtk${chip}e/etc mtk${chip}e-$ver/src/
|
||||
cp -rf kmod-mtk${chip}e/lib mtk${chip}e-$ver/src/
|
||||
tar Jcf mtk${chip}e-${ver}_${commit}.tar.xz mtk${chip}e-$ver
|
||||
scp -pv mtk${chip}e-${ver}_${commit}.tar.xz $SERVER:$FPATH/
|
||||
cp mtk${chip}e-${ver}_${commit}.tar.xz $curdir/
|
||||
rm -rf mtk${chip}e-$ver
|
||||
rm -f mtk${chip}e-${ver}_${commit}.tar.xz
|
||||
cd "$curdir"
|
||||
}
|
||||
|
||||
function print_usage {
|
||||
echo "Usage: $0 generate_tarballs"
|
||||
echo " -t <target>"
|
||||
@@ -118,8 +123,7 @@ function generate_tarballs {
|
||||
set -e
|
||||
git remote -v | grep -q http && return # do not continue if this is an open SDK environment
|
||||
|
||||
target=$(grep CONFIG_TARGET_BOARD .config | cut -d'=' -f2 | tr -d '"')
|
||||
board=$(grep CONFIG_TARGET_IBOARDID .config | cut -d'=' -f2 | tr -d '"')
|
||||
board=$(grep CONFIG_TARGET_FAMILY .config | cut -d'=' -f2 | tr -d '"')
|
||||
profile=$(grep CONFIG_BCM_KERNEL_PROFILE .config | cut -d'=' -f2 | tr -d '"')
|
||||
majver=$(grep CONFIG_TARGET_VERSION .config | cut -d'=' -f2 | tr -d '"' | cut -f1 -d .)
|
||||
minver=$(grep CONFIG_TARGET_VERSION .config | cut -d'=' -f2 | tr -d '"' | cut -f2 -d .)
|
||||
@@ -143,7 +147,7 @@ function generate_tarballs {
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ! -n "$stk_target" ]; then
|
||||
if [ -z "$stk_target" ]; then
|
||||
print_usage
|
||||
exit 1
|
||||
fi
|
||||
@@ -152,10 +156,10 @@ function generate_tarballs {
|
||||
build_bcmkernel_consumer
|
||||
build_natalie_consumer
|
||||
build_endptmngr_consumer
|
||||
build_wifilife_consumer
|
||||
elif [ "$stk_target" == "mediatek" ]; then
|
||||
build_mediatek_kernel
|
||||
build_wifilife_consumer
|
||||
build_mediatek_wifi_consumer 7603
|
||||
build_mediatek_wifi_consumer 7615
|
||||
else
|
||||
echo "Invalid target: $stk_target"
|
||||
print_usage
|
||||
|
||||
@@ -9,8 +9,7 @@ function install_key {
|
||||
|
||||
echo "::sysinit:/etc/init.d/rcS S boot" >files/etc/inittab
|
||||
echo "::shutdown:/etc/init.d/rcS K shutdown" >>files/etc/inittab
|
||||
echo "tty/0::askfirst:/bin/ash --login" >>files/etc/inittab
|
||||
echo "console::askfirst:/bin/cttyhack /bin/ash --login" >>files/etc/inittab
|
||||
echo "console::askconsolelate:/bin/cttyhack /bin/ash --login" >>files/etc/inittab
|
||||
|
||||
echo Done
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ function ssh_upgrade {
|
||||
upd_fw_base=""
|
||||
upd_fw=""
|
||||
upd_host="192.168.1.1"
|
||||
upd_sysupgrade=0
|
||||
upd_sysupgrade=1
|
||||
do_dialog=0
|
||||
|
||||
while getopts "f:hnxt:iscb" opt; do
|
||||
@@ -280,6 +280,14 @@ function ssh_upgrade {
|
||||
set_config_string CONFIG_TARGET_BOARD
|
||||
firmwares=$(cd bin/targets/$CONFIG_TARGET_BOARD/generic/; ls -t *[0-9].y[3])
|
||||
|
||||
# if target uses pkgtb
|
||||
if [ -z "$firmwares"]
|
||||
then
|
||||
# pkgtb files can not be streamed so copy over the file witch scp
|
||||
use_scp=1
|
||||
firmwares=$(cd bin/targets/$CONFIG_TARGET_BOARD/generic/; ls -t last.pkgtb)
|
||||
fi
|
||||
|
||||
for upd_fw_base in $firmwares
|
||||
do
|
||||
#echo "firmware $upd_fw"
|
||||
@@ -313,10 +321,20 @@ function ssh_upgrade {
|
||||
[ $upd_forceboot -eq 1 ] && extra_args="$extra_args -b"
|
||||
|
||||
file_size_kb=`du -k "$upd_fw" | cut -f1`
|
||||
cat $upd_fw | pv -s ${file_size_kb}k | ssh root@$upd_host "iopu $extra_args"
|
||||
if [ "$use_scp" == "1" ]
|
||||
then
|
||||
scp $upd_fw root@$upd_host:/tmp/ &&
|
||||
ssh -o ConnectTimeout=60 root@$upd_host "iopu $extra_arg -f /tmp/$upd_fw_base"
|
||||
else
|
||||
cat $upd_fw | pv -s ${file_size_kb}k | ssh root@$upd_host "iopu $extra_args"
|
||||
fi
|
||||
else
|
||||
extra_args=""
|
||||
[ $upd_noreboot -eq 1 ] && extra_args="$extra_args -d"
|
||||
[ $upd_keepconf -eq 0 ] && extra_args="$extra_args -n"
|
||||
|
||||
scp $upd_fw root@$upd_host:/tmp/ &&
|
||||
ssh -o ConnectTimeout=60 root@$upd_host "sysupgrade -v $3 /tmp/$upd_fw_base" &&
|
||||
ssh -o ConnectTimeout=60 root@$upd_host "sysupgrade -v $extra_args /tmp/$upd_fw_base" &&
|
||||
echo "sysupgrade done!"
|
||||
fi
|
||||
}
|
||||
|
||||
35
iop/scripts/licenses_gen.sh
Normal file
35
iop/scripts/licenses_gen.sh
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
function license_report {
|
||||
LICDIR="/tmp/licenses-generator/"
|
||||
LICBIN="${LICDIR}/bin"
|
||||
|
||||
|
||||
dpkg -s python3 python3-requests python3-yaml python3-mako python3-six &> /dev/null
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "Missing dependencies"
|
||||
sudo apt-get update
|
||||
sudo apt-get install python3 python3-requests python3-yaml python3-mako python3-six
|
||||
|
||||
else
|
||||
echo "Dependecy check passed"
|
||||
fi
|
||||
|
||||
|
||||
if [ -d "$LICDIR" ]; then
|
||||
### Take action if $DIR exists ###
|
||||
echo "Creating json licences file and html formated report"
|
||||
else
|
||||
### Control will jump here if $DIR does NOT exists ###
|
||||
echo "Error: licenses-generator not found. getting from iopsys repo"
|
||||
git clone git@dev.iopsys.eu:iopsys/licenses-generator.git $LICDIR
|
||||
fi
|
||||
LICGET=`${LICBIN}/licenses-generator gen-License bin/`
|
||||
echo $LICGET
|
||||
${LICBIN}/licenses-generator gen-licrprt $LICGET
|
||||
exit 0
|
||||
|
||||
}
|
||||
|
||||
|
||||
register_command "license_report" "Generate a Licence report on latest build in json format and html under reports"
|
||||
@@ -1,70 +0,0 @@
|
||||
# this is a developer helper script to SCP changed files to remote host
|
||||
|
||||
ROOT=build_dir/target-mips_uClibc-0.9.33.2/root-iopsys-brcm63xx-mips/
|
||||
ROOT_OLD=tmp/root_old/
|
||||
ROOT_TMP=tmp/root_tmp/
|
||||
|
||||
function scp_changes_reset {
|
||||
{ cd `dirname $0`
|
||||
rm -rf "$ROOT_OLD"
|
||||
mkdir -p "$ROOT_OLD"
|
||||
cp -a "$ROOT"* "$ROOT_OLD"
|
||||
}
|
||||
}
|
||||
|
||||
function scp_changes {
|
||||
if [ -z "$1" ] ; then
|
||||
echo "usage: $0 scp_changes <host/-r(eset)/-p(retend)>"
|
||||
echo "Error: host required"
|
||||
exit 1
|
||||
fi
|
||||
{ cd `dirname $0`
|
||||
if [ ! -d $ROOT ]; then
|
||||
echo "$ROOT does not exist"
|
||||
echo "please build the project first"
|
||||
exit 1;
|
||||
fi
|
||||
if [ "$1" = "-r" ]; then
|
||||
echo "reset changes"
|
||||
scp_changes_reset
|
||||
exit 0
|
||||
fi
|
||||
if [ ! -d $ROOT_OLD ]; then
|
||||
echo "$ROOT_OLD does not exist"
|
||||
echo "you didn't store state of previous buildroot"
|
||||
#echo "please run ./scp_changes_reset.sh"
|
||||
echo "doing it now"
|
||||
scp_changes_reset
|
||||
exit 1;
|
||||
fi
|
||||
FILES=`diff -rq "$ROOT" "$ROOT_OLD" 2>&1 | sed -ne "s?^Files .* and $ROOT_OLD\\(.*\\) differ?\\1?p" -ne "s?^Only in $ROOT\\(.*\\): \\(.*\\)?\\1/\\2?p"`
|
||||
if [ "$1" = "-p" ]; then
|
||||
echo "files that would be copied:"
|
||||
echo $FILES
|
||||
exit 0
|
||||
fi
|
||||
for f in $FILES
|
||||
do
|
||||
mkdir -p "$ROOT_TMP`dirname $f`"
|
||||
cp -af "$ROOT$f" "$ROOT_TMP$f"
|
||||
done
|
||||
if [ -d "$ROOT_TMP" ]; then
|
||||
echo "scp changed files to $1"
|
||||
pushd "$ROOT_TMP" 2>&1 >/dev/null
|
||||
scp -r * root@$1:/
|
||||
RETVAL=$?
|
||||
popd 2>&1 >/dev/null
|
||||
rm -rf "$ROOT_TMP"
|
||||
if [ "$RETVAL" -eq 0 ]; then
|
||||
scp_changes_reset
|
||||
else
|
||||
echo "scp error"
|
||||
exit $RETVAL
|
||||
fi
|
||||
else
|
||||
echo "no change"
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
register_command "scp_changes" "<host/-r(eset)/-p(retend)> SCP only changed files to device"
|
||||
95
iop/scripts/taas.sh
Normal file
95
iop/scripts/taas.sh
Normal file
@@ -0,0 +1,95 @@
|
||||
|
||||
# Shorthand command for doing a HIL runtime smoketest on the
|
||||
# latest built image. Does the image boot up correctly?
|
||||
# More info here:
|
||||
# https://dev.iopsys.eu/iopsys/iopsys-taas
|
||||
|
||||
|
||||
#--------------------------------------------------------------
|
||||
function taas-init() {
|
||||
local f
|
||||
|
||||
# Path to TaaS binarys. Try some likely ones.
|
||||
if ! which taas-smoketest >/dev/null; then
|
||||
PATH="${PATH}:${PWD}/../iopsys-taas/bin"
|
||||
PATH="${PATH}:${PWD}/../taas/bin"
|
||||
PATH="${PATH}:${HOME}/iopsys-taas/bin"
|
||||
PATH="${PATH}:${HOME}/taas/bin"
|
||||
PATH="${PATH}:${HOME}/bin"
|
||||
PATH="${PATH}:/opt/iopsys-taas/bin"
|
||||
PATH="${PATH}:/opt/taas/bin"
|
||||
fi
|
||||
|
||||
if ! which taas-smoketest >/dev/null; then
|
||||
echo "Error; TaaS is missing! Install it with:"
|
||||
echo "git clone git@dev.iopsys.eu:iopsys/iopsys-taas.git ../iopsys-taas"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# NAND erase block size.
|
||||
nandBlkSz=$(grep CONFIG_TARGET_NAND_BLOCKSZ .config | \
|
||||
tr -s "=\"" " " | cut -d " " -f 2)
|
||||
nandBlkSz=$((nandBlkSz / 1024))
|
||||
|
||||
# Create a list of all images which might be of use.
|
||||
for f in ${PWD}/bin/targets/iopsys-*/generic/last.* \
|
||||
${PWD}/build_dir/target-arm*/bcmkernel/bcm963xx/targets/9*/bcm*_linux_raw_image_${nandBlkSz}.bin; do
|
||||
[[ -s "$f" ]] && images+=("$f")
|
||||
done
|
||||
|
||||
# Convert Iopsys target name to the TaaS product name format
|
||||
# according to what is available in the remote lab for HIL.
|
||||
# Also find a suitable image.
|
||||
product=$(grep CONFIG_TARGET_PROFILE .config | \
|
||||
tr -s "=\"" " " | cut -d " " -f 2) || exit
|
||||
case "$product" in
|
||||
smarthub3)
|
||||
export product="SmartHub3a"
|
||||
;;
|
||||
dg400prime|eg400|ex600)
|
||||
export product=$(echo -n "$product" | tr [[:lower:]] [[:upper:]])
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported target; skipping!"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ ${#images[@]} -eq 0 ]]; then
|
||||
echo "No image found"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------
|
||||
function taas-smoketest {
|
||||
declare -a images
|
||||
|
||||
taas-init || return
|
||||
echo "Testing a $product with ${images[@]}..."
|
||||
command taas-smoketest "${images[@]}" "$product" "$@"
|
||||
}
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------
|
||||
function taas-bootstrap {
|
||||
declare -a images
|
||||
|
||||
if [[ -n "$1" ]]; then
|
||||
taas-init || return
|
||||
echo "Flashing $1..."
|
||||
command taas-bootstrap "${images[@]}" "$@"
|
||||
else
|
||||
echo "Usage: ./iop taas-bootstrap dutX"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
register_command "taas-bootstrap" "Write image to a remote lab device."
|
||||
register_command "taas-smoketest" "Write image to a remote lab device and test it."
|
||||
|
||||
@@ -25,6 +25,7 @@ log_stdout=1 # set to 0 to prevent the log to also print to stdout
|
||||
upd_noreboot=0 # set to 1 if we should not reboot after programming
|
||||
upd_forceimage=0 # set this to force upgrade even if image is for wrong board.
|
||||
upd_forceboot=0 # set this to force upgrade of boot loader
|
||||
upd_keepconfig=0 # set this to keep the current configuration.
|
||||
###############################################################################
|
||||
# import external functions
|
||||
source /lib/upgrade/iopsys.sh
|
||||
@@ -51,25 +52,41 @@ function log {
|
||||
# anyhting it calls as stdout/stderr might no longer exist
|
||||
function finish {
|
||||
|
||||
if [ "$run_cleanup" == "1" ]
|
||||
if [ $run_cleanup -eq 1 ]
|
||||
then
|
||||
|
||||
function_call upd_cleanup
|
||||
run_cleanup=0
|
||||
log ""
|
||||
fi
|
||||
|
||||
if [ "$run_mount_cleanup" == "1" ]
|
||||
if [ $run_mount_cleanup -eq 1 ]
|
||||
then
|
||||
log "Cleaning up after mount"
|
||||
umount_newroot
|
||||
fi
|
||||
# always kill the timeout process, will leave the sleep but that is harmless
|
||||
# as long as the kill will nerver be run.
|
||||
kill $TIMEOUT_PID 2>/dev/null
|
||||
if [ -n "$TIMEOUT_PID" ]; then
|
||||
kill $TIMEOUT_PID 2>/dev/null
|
||||
TIMEOUT_PID=""
|
||||
fi
|
||||
|
||||
lock -u /tmp/iopu.lock
|
||||
}
|
||||
|
||||
function ctrl_c {
|
||||
|
||||
# on ctrl-c we remove the exit handler as it is called directly.
|
||||
trap - EXIT
|
||||
|
||||
# call cleanup function
|
||||
finish
|
||||
|
||||
# do not continue program
|
||||
exit 1
|
||||
}
|
||||
|
||||
function sig_pipe {
|
||||
log_stdout=0 # stdin,stdout,stderr do not exist anymore
|
||||
log "Got sigpipe. Turning of log printing to stdout"
|
||||
@@ -77,7 +94,6 @@ function sig_pipe {
|
||||
|
||||
# if a timout happens terminate
|
||||
function timeout {
|
||||
finish
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -133,6 +149,7 @@ function umount_newroot {
|
||||
umount /tmp/newroot_overlay/rom
|
||||
umount /tmp/newroot_overlay
|
||||
umount /tmp/newroot
|
||||
rmdir /tmp/newroot_overlay /tmp/newroot
|
||||
run_mount_cleanup=0
|
||||
}
|
||||
|
||||
@@ -141,11 +158,82 @@ function usage {
|
||||
echo ""
|
||||
echo "opts:"
|
||||
echo ""
|
||||
echo " -n Do not do the final reboot of the target board"
|
||||
echo " -c Keep configuration"
|
||||
echo " -x Force install even if firmware is not for this board"
|
||||
echo " -b Force install of bootloader regardless of version installed"
|
||||
echo " -r Jump into chroot env of other system"
|
||||
echo " -n Do not do the final reboot of the target board"
|
||||
echo " -c Keep configuration"
|
||||
echo " -x Force install even if firmware is not for this board"
|
||||
echo " -b Force install of bootloader regardless of version installed"
|
||||
echo " -r Jump into chroot env of other system"
|
||||
echo " -f Firmware file to use"
|
||||
echo " -C \"command\" Execute command in chroot env of other system"
|
||||
}
|
||||
|
||||
# Execute command in newroot(other system root)
|
||||
function newroot_exec {
|
||||
|
||||
upd_vol=$(get_flashbank_next)
|
||||
mount_newroot
|
||||
(ENV=/sbin/iopu_chroot_env chroot /tmp/newroot_overlay "$@")
|
||||
echo ""
|
||||
umount_newroot
|
||||
|
||||
}
|
||||
|
||||
function system_is_y_image {
|
||||
|
||||
# find out what rootfs volume is active.
|
||||
cur_vol=$(get_flashbank_current)
|
||||
upd_vol=$(get_flashbank_next)
|
||||
|
||||
# convert volume name "rootfs_$upd_vol" into ubi volume id
|
||||
upd_ubi_id=$(ubinfo -d 0 -N rootfs_$upd_vol | awk "/Volume ID:/ {print \$3}")
|
||||
log "installing Root Fileystem into UBI volume rootfs_$upd_vol"
|
||||
|
||||
# prepare to match dsl.
|
||||
function_call upd_conf_dsl
|
||||
|
||||
log "now starting writing data to flash with [ iopupgrade $cmdline -M "$cmdline_match" -u ubi0_$upd_ubi_id ]"
|
||||
run_cleanup=1 # When we start to actually write data there might be some
|
||||
# things that need cleanup if we get an error/crash
|
||||
if ! iopupgrade $cmdline -M "$cmdline_match" -u ubi0_$upd_ubi_id; then
|
||||
log "iopupgrade program Failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "Firmware programmed to flash."
|
||||
|
||||
# Force upgrade of boot loader
|
||||
[ $upd_forceboot -eq 1 ] && chroot_cmdline="$chroot_cmdline -b"
|
||||
|
||||
if [ $upd_keepconfig -eq 1 ]; then
|
||||
log "Transfering configuration to new system."
|
||||
chroot_cmdline="$chroot_cmdline -c"
|
||||
fi
|
||||
|
||||
mount_newroot
|
||||
if ! chroot /tmp/newroot_overlay /sbin/iopu_chroot $chroot_cmdline; then
|
||||
log "Configuration migration failed!"
|
||||
exit 1
|
||||
fi
|
||||
umount_newroot
|
||||
|
||||
log "New firmware fully installed."
|
||||
run_cleanup=0
|
||||
|
||||
|
||||
# Now make sure that we actually boot the new system on the next reboot
|
||||
upd_finnish
|
||||
|
||||
}
|
||||
|
||||
function system_is_FIT_image {
|
||||
|
||||
# prepare to match dsl.
|
||||
#function_call upd_conf_dsl
|
||||
|
||||
#here we write data
|
||||
bcm_flasher $firmware_file
|
||||
bcm_bootstate 1
|
||||
log "Firmware programmed to flash."
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
@@ -161,10 +249,11 @@ then
|
||||
fi
|
||||
|
||||
trap finish EXIT
|
||||
trap ctrl_c INT
|
||||
trap timeout SIGALRM
|
||||
trap sig_pipe SIGPIPE
|
||||
|
||||
while getopts "nrxbh" opt; do
|
||||
while getopts "nrxbhcC:f:" opt; do
|
||||
case $opt in
|
||||
n)
|
||||
upd_noreboot=1
|
||||
@@ -175,13 +264,19 @@ while getopts "nrxbh" opt; do
|
||||
b)
|
||||
upd_forceboot=1
|
||||
;;
|
||||
c)
|
||||
upd_keepconfig=1
|
||||
;;
|
||||
r)
|
||||
upd_vol=$(get_flashbank_next)
|
||||
mount_newroot
|
||||
(ENV=/sbin/iopu_chroot_env chroot /tmp/newroot_overlay /bin/sh)
|
||||
echo ""
|
||||
umount_newroot
|
||||
exit 0
|
||||
newroot_exec /bin/sh
|
||||
exit
|
||||
;;
|
||||
C)
|
||||
newroot_exec "${OPTARG}"
|
||||
exit
|
||||
;;
|
||||
f)
|
||||
firmware_file="${OPTARG}"
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
@@ -193,8 +288,7 @@ done
|
||||
# put a timeout on this if it takes longer than 120 seconds we should abort
|
||||
# and clean up
|
||||
(
|
||||
sleep 120 # if 2 minutes pass
|
||||
kill -ALRM $$ 2>/dev/null # send it a SIGALRM signal
|
||||
sleep 120 && kill -ALRM $$ 2>/dev/null # send it a SIGALRM signal
|
||||
)&
|
||||
TIMEOUT_PID=$!
|
||||
|
||||
@@ -203,56 +297,18 @@ log "Firmware upgrade started"
|
||||
# Should board name be checked
|
||||
if [ $upd_forceimage -eq 0 ]
|
||||
then
|
||||
board=$(db get hw.board.iopVerBoard)
|
||||
board=$(db get hw.board.model_name)
|
||||
cmdline_match="board=$board"
|
||||
fi
|
||||
|
||||
# find out what rootfs volume is active.
|
||||
cur_vol=$(get_flashbank_current)
|
||||
upd_vol=$(get_flashbank_next)
|
||||
|
||||
# convert volume name "rootfs_$upd_vol" into ubifs volume id
|
||||
upd_ubi_id=$(ubinfo -d 0 -N rootfs_$upd_vol | awk "/Volume ID:/ {print \$3}")
|
||||
log "installing Root Fileystem into UBI volume rootfs_$upd_vol"
|
||||
|
||||
# prepare to match dsl.
|
||||
function_call upd_conf_dsl
|
||||
|
||||
# prepare to update CFE if it exists
|
||||
function_call upd_conf_cfe
|
||||
|
||||
# prepare to update kernel if it is stored in MTD/JFFS2
|
||||
function_call upd_conf_kernel
|
||||
|
||||
log "now starting writing data to flash with [ iopupgrade $cmdline -M "$cmdline_match" -u ubi0_$upd_ubi_id ]"
|
||||
run_cleanup=1 # When we start to actually write data there might be some
|
||||
# things that need cleanup if we get an error/crash
|
||||
iopupgrade $cmdline -M "$cmdline_match" -u ubi0_$upd_ubi_id
|
||||
|
||||
# in case of any error we abort
|
||||
if [ $? -ne 0 ]; then
|
||||
log "iopupgrade program Failed"
|
||||
exit 1
|
||||
# BUG: should probably read a config file.
|
||||
if [ -f /proc/nvram/boardid ]
|
||||
then
|
||||
system_is_FIT_image
|
||||
else
|
||||
system_is_y_image
|
||||
fi
|
||||
|
||||
log "Firmware programmed to flash."
|
||||
|
||||
|
||||
log "Transfering configuration to new system."
|
||||
|
||||
# Force upgrade of boot loader
|
||||
[ $upd_forceboot -eq 1 ] && chroot_cmdline="$chroot_cmdline -b"
|
||||
|
||||
mount_newroot
|
||||
chroot /tmp/newroot_overlay /sbin/iopu_chroot $chroot_cmdline
|
||||
umount_newroot
|
||||
|
||||
log "Update fully installed."
|
||||
run_cleanup=0
|
||||
|
||||
# Now make sure that we actually boot the new system on the next reboot
|
||||
upd_finnish
|
||||
|
||||
# spawn the reboot to a subshell to allow the main program to quit before reset
|
||||
# to avoid any hanged network connection like ssh
|
||||
if [ $upd_noreboot -eq 0 ]
|
||||
@@ -271,8 +327,3 @@ else
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
# by functions declared in this script
|
||||
upd_forceboot=0
|
||||
log_stdout=1 # set to 0 to prevent the log to also print to stdout
|
||||
upd_keepconfig=0 # set this to keep the current configuration.
|
||||
|
||||
###############################################################################
|
||||
# import external functions
|
||||
@@ -24,33 +25,36 @@ source /lib/upgrade/iopsys.sh
|
||||
|
||||
# only call function if it exists
|
||||
function_call() {
|
||||
if type "$1" 2>/dev/null >/dev/null
|
||||
then
|
||||
$1 $@
|
||||
fi
|
||||
if [ -n "$1" ] && type "$1" 2>/dev/null >/dev/null
|
||||
then
|
||||
$1 "$@" || exit
|
||||
fi
|
||||
}
|
||||
# Cleanup and error handling functions.
|
||||
function log {
|
||||
TIME=$(date)
|
||||
[ $log_stdout -eq 1 ] && echo "$@"
|
||||
echo "[$TIME] $@" >>/root/upd_log
|
||||
TIME=$(date)
|
||||
[ $log_stdout -eq 1 ] && echo "$@"
|
||||
echo "[$TIME] $@" >>/root/upd_log
|
||||
}
|
||||
|
||||
|
||||
while getopts "hb" opt; do
|
||||
case $opt in
|
||||
h)
|
||||
upd_usage
|
||||
exit 1
|
||||
;;
|
||||
b)
|
||||
upd_forceboot=1
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
while getopts "hbc" opt; do
|
||||
case $opt in
|
||||
h)
|
||||
upd_usage
|
||||
exit 1
|
||||
;;
|
||||
c)
|
||||
upd_keepconfig=1
|
||||
;;
|
||||
b)
|
||||
upd_forceboot=1
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# copy old install log over
|
||||
@@ -59,3 +63,9 @@ cp /tmp/oldroot/tmp/upd_log /root/upd_log
|
||||
# Upgrade boot loader if needed.
|
||||
function_call upd_program_boot
|
||||
|
||||
# Let the new upgrade do whatever it needs,
|
||||
# such as configuration migration etc.
|
||||
if [ $upd_keepconfig -eq 1 -a -x /lib/upgrade/post-rootfs-fixup ]; then
|
||||
(/lib/upgrade/post-rootfs-fixup /dev/null /tmp/oldroot) || exit
|
||||
fi
|
||||
|
||||
|
||||
36
iup/Makefile
36
iup/Makefile
@@ -1,36 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2006-2011 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=iup
|
||||
PKG_VERSION:=0.0.1
|
||||
PKG_RELEASE:=0
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/iup
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=iup client
|
||||
DEPENDS:=+libuci +uci +busybox
|
||||
endef
|
||||
|
||||
define Package/iup/description
|
||||
This package contains Inteno's IUP Client
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
true
|
||||
endef
|
||||
|
||||
define Package/iup/install
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
cp -r ./files/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,iup))
|
||||
@@ -1,17 +0,0 @@
|
||||
package 'provisioning'
|
||||
|
||||
config 'general' 'polling'
|
||||
option 'enabled' 'on'
|
||||
option 'starttime' '03'
|
||||
option 'interval' 'daily'
|
||||
|
||||
config 'server' 'configserver'
|
||||
option enabled 'off'
|
||||
|
||||
|
||||
config 'server' 'iup'
|
||||
option 'enabled' 'on'
|
||||
|
||||
config software 'uppgradeserver'
|
||||
option enabled 'off'
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# iup at boot
|
||||
# Copyright (C) 2007 OpenWrt.org
|
||||
|
||||
START=98
|
||||
STOP=15
|
||||
USE_PROCD=1
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
include /lib/network
|
||||
|
||||
CRONPATH="/etc/crontabs/root"
|
||||
RANGE=60
|
||||
|
||||
management_interfaces() {
|
||||
local DHCP_IFACES=""
|
||||
|
||||
is_notbridged_dhcp() {
|
||||
local config="$1"
|
||||
local proto="$(uci -q get network.$config.proto)"
|
||||
local typ="$(uci -q get network.$config.type)"
|
||||
if [ "$proto" == "dhcp" -a "$typ" != "bridge" ]; then
|
||||
DHCP_IFACES="$DHCP_IFACES $config"
|
||||
fi
|
||||
}
|
||||
|
||||
config_load network
|
||||
config_foreach is_notbridged_dhcp interface
|
||||
echo $DHCP_IFACES
|
||||
}
|
||||
|
||||
init_iup() {
|
||||
local polling_enabled
|
||||
local interval
|
||||
local starttime
|
||||
local nummber
|
||||
number=$RANDOM
|
||||
|
||||
[ -f $CRONPATH ] || touch $CRONPATH
|
||||
|
||||
config_load provisioning
|
||||
config_get polling_enabled polling enabled on
|
||||
config_get interval polling interval
|
||||
config_get starttime polling starttime
|
||||
|
||||
### Ask for IUP related DHCP options only if IUP is enabled ###
|
||||
new_reqopts() {
|
||||
local net=$1
|
||||
local enabled
|
||||
local newreqopts=
|
||||
local baseopts=
|
||||
local reqopts="$(uci -q get network.$net.reqopts)"
|
||||
local iupopts="66 67 128 224 225 226"
|
||||
local ropt iopt
|
||||
config_get enabled iup enabled "on"
|
||||
for ropt in $reqopts; do
|
||||
case $ropt in
|
||||
66|67|128|224|225|226) ;;
|
||||
*) baseopts="$baseopts $ropt" ;;
|
||||
esac
|
||||
done
|
||||
ropt=""
|
||||
reqopts="$baseopts $iupopts"
|
||||
for ropt in $reqopts; do
|
||||
case $ropt in
|
||||
66|67|128|224|225|226) [ $enabled == "on" ] && newreqopts="$newreqopts $ropt" ;;
|
||||
*) newreqopts="$newreqopts $ropt" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
newreqopts="$(echo $newreqopts | tr ' ' '\n' | sort -n | tr '\n' ' ' | sed 's/^[ \t]*//;s/[ \t]*$//')"
|
||||
echo "$newreqopts"
|
||||
}
|
||||
for net in $(management_interfaces); do
|
||||
uci -q set network.$net.reqopts="$(new_reqopts $net)"
|
||||
done
|
||||
uci commit network
|
||||
ubus call network reload
|
||||
#################################################################
|
||||
|
||||
if [ $polling_enabled == "off" ]; then
|
||||
sed -i "/\/sbin\/iup/d" $CRONPATH
|
||||
logger -s -t /etc/init.d/iup[$$] "Provisioning polling unscheduled" 2>/dev/console
|
||||
return
|
||||
fi
|
||||
|
||||
local log_hour=$starttime
|
||||
local log_minute
|
||||
local log_interval=$interval
|
||||
if [ $interval == "weekly" ]; then
|
||||
interval="0"
|
||||
log_interval="$log_interval/sunday"
|
||||
elif [ $interval == "hourly" ]; then
|
||||
interval='*'
|
||||
starttime='*'
|
||||
else
|
||||
interval='*'
|
||||
fi
|
||||
let "number %= $RANGE"
|
||||
if ! grep -q "$starttime \* \* \\$interval /sbin/iup" "$CRONPATH" ; then
|
||||
if grep -q "iup" "$CRONPATH" ; then
|
||||
sed -i "/iup/d" $CRONPATH
|
||||
fi
|
||||
echo "$number $starttime * * $interval /sbin/iup -v > /dev/null 2>&1" >> $CRONPATH
|
||||
fsync $CRONPATH
|
||||
/etc/init.d/cron restart
|
||||
fi
|
||||
log_minute=$(awk '/\/sbin\/iup/ {print $1}' /etc/crontabs/root)
|
||||
logger -s -t /etc/init.d/iup[$$] "Provisioning is scheduled at $log_hour:$log_minute $log_interval" 2>/dev/console
|
||||
}
|
||||
|
||||
start_service() {
|
||||
init_iup
|
||||
|
||||
/sbin/iup -v &
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
if [ -f "/tmp/run/iup.pid" ]; then
|
||||
kill -9 $(cat /tmp/run/iup.pid)
|
||||
rm -rf /tmp/run/iup.pid
|
||||
fi
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger provisioning
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
management_interfaces() {
|
||||
local DHCP_IFACES=""
|
||||
|
||||
is_notbridged_dhcp() {
|
||||
local config="$1"
|
||||
local proto="$(uci -q get network.$config.proto)"
|
||||
local typ="$(uci -q get network.$config.type)"
|
||||
if [ "$proto" == "dhcp" -a "$typ" != "bridge" ]; then
|
||||
DHCP_IFACES="$DHCP_IFACES $config"
|
||||
fi
|
||||
}
|
||||
|
||||
config_load network
|
||||
config_foreach is_notbridged_dhcp interface
|
||||
echo $DHCP_IFACES
|
||||
}
|
||||
|
||||
set_iup_reqopts() {
|
||||
### Ask for IUP related DHCP options only if IUP is enabled ###
|
||||
new_reqopts() {
|
||||
local net=$1
|
||||
local enabled="$(uci -q get provisioning.iup.enabled)"
|
||||
enabled="${enabled:-on}"
|
||||
local newreqopts=
|
||||
local baseopts=
|
||||
local reqopts="$(uci -q get network.$net.reqopts)"
|
||||
local iupopts="66 67 128 224 225 226"
|
||||
local ropt iopt
|
||||
local net
|
||||
for ropt in $reqopts; do
|
||||
case $ropt in
|
||||
66|67|128|224|225|226) ;;
|
||||
*) baseopts="$baseopts $ropt" ;;
|
||||
esac
|
||||
done
|
||||
ropt=""
|
||||
reqopts="$baseopts $iupopts"
|
||||
for ropt in $reqopts; do
|
||||
case $ropt in
|
||||
66|67|128|224|225|226) [ $enabled == "on" ] && newreqopts="$newreqopts $ropt" ;;
|
||||
*) newreqopts="$newreqopts $ropt" ;;
|
||||
esac
|
||||
done
|
||||
newreqopts="$(echo $newreqopts | tr ' ' '\n' | sort -n | tr '\n' ' ' | sed 's/^[ \t]*//;s/[ \t]*$//')"
|
||||
echo "$newreqopts"
|
||||
}
|
||||
for net in $(management_interfaces); do
|
||||
uci -q set network.$net.reqopts="$(new_reqopts $net)"
|
||||
done
|
||||
uci commit network
|
||||
}
|
||||
|
||||
set_iup_reqopts
|
||||
@@ -1,219 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# functions that take dhcp options received on the wan interface
|
||||
# and relay/repeat them for specific clients
|
||||
|
||||
#config dhcp_option_relay
|
||||
# option enable 1
|
||||
# list dhcp_option 43
|
||||
# list from_interface wan
|
||||
# option vendorclass '*SDX*'
|
||||
|
||||
# where:
|
||||
# dhcp_option_relay is the name of the section parsed by this script
|
||||
# enable/enabled - option, enable the uci section [default on]
|
||||
# dhcp_option/dhcp_options - list of dhcp options (0-255) to be relayed/repeated
|
||||
# overwrite - if same dhcp_option already exists in /etc/config/dhcp, overwrite it with this option [default off]
|
||||
# from_interface - list of interfaces (e.g. wan) to get the dhcp options from
|
||||
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
interface=""
|
||||
opt224=""
|
||||
opt225=""
|
||||
opt226=""
|
||||
opt43=""
|
||||
opt128=""
|
||||
opt66=""
|
||||
opt67=""
|
||||
opt132=""
|
||||
opt133=""
|
||||
newsectionid="0"
|
||||
|
||||
function parse_the_json()
|
||||
{
|
||||
local the_json="$@"
|
||||
|
||||
json_load "$the_json"
|
||||
json_get_var interface interface
|
||||
json_get_var opt224 privopt224
|
||||
json_get_var opt225 privopt225
|
||||
json_get_var opt226 privopt226
|
||||
json_get_var opt43 vendorspecinf # option 43
|
||||
json_get_var opt128 httpurl128
|
||||
json_get_var opt66 tftp # option 66
|
||||
json_get_var opt67 bootfile #option 67
|
||||
json_get_var opt132 vlanid # option 132
|
||||
json_get_var opt133 vlanpriority # option 133
|
||||
}
|
||||
|
||||
function add_section_dhcp_vendorclass()
|
||||
{
|
||||
local dhcp_option=$1
|
||||
local dhcp_option_value=$2
|
||||
local vendorclass=$3
|
||||
local new=
|
||||
newsectionid=$((newsectionid+1))
|
||||
|
||||
#echo "add_section_dchp_vendorclass $dhcp_option ${dhcp_option_value} $vendorclass"
|
||||
new=$(uci add dhcp vendorclass)
|
||||
uci set dhcp.$new.vendorclass="$vendorclass"
|
||||
uci set dhcp.$new.networkid="dhcp_option_relay_$newsectionid"
|
||||
uci add_list dhcp.$new.dhcp_option=$dhcp_option,\"${dhcp_option_value}\"
|
||||
|
||||
uci commit dhcp
|
||||
}
|
||||
|
||||
function dhcp_option_relay()
|
||||
{
|
||||
local section="$1"
|
||||
local enable="" enabled=""
|
||||
local dhcp_option="" dhcp_option_value=""
|
||||
local vendorclass=""
|
||||
#local overwrite=""
|
||||
local from_interface
|
||||
|
||||
#echo "section: $section"
|
||||
|
||||
# parse only enabled sections
|
||||
config_get_bool enabled $section enabled 1
|
||||
config_get_bool enable $section enable 1
|
||||
#echo "enabled: $enabled"
|
||||
#echo "enable : $enable"
|
||||
if [ "$enable" == "0" -o "$enabled" == "0" ] ; then
|
||||
#echo "section $section is not enabled"
|
||||
return
|
||||
fi
|
||||
# todo: for disabled sections: run only the removal of the dhcp options
|
||||
|
||||
# option overwrite 1
|
||||
#config_get_bool overwrite $section overwrite 0
|
||||
config_get vendorclass $section vendorclass
|
||||
if [ ${#vendorclass} -le 1 ]; then
|
||||
#echo "vendorclass must not be empty"
|
||||
return
|
||||
fi
|
||||
|
||||
# list to_interface lan
|
||||
# to_interface - list of interfaces (e.g. lan, guest) to advertise the dhcp options to
|
||||
#foreach_to_interface() {
|
||||
# local to_interface=$1
|
||||
# echo ""
|
||||
# echo " from_interface $from_interface"
|
||||
# echo " dhcp_option $dhcp_option"
|
||||
# echo " dhcp_option_value $dhcp_option_value"
|
||||
# echo " overwrite $overwrite"
|
||||
# echo " to_interface $to_interface"
|
||||
#
|
||||
# if [ ! $(uci -q get dhcp.$to_interface) ] ; then
|
||||
# echo "to_interface $to_interface does not exist in dhcp uci config"
|
||||
# return
|
||||
# fi
|
||||
#
|
||||
#}
|
||||
|
||||
|
||||
foreach_dhcp_option() {
|
||||
dhcp_option=$1
|
||||
|
||||
echo "dhcp_option: $dhcp_option"
|
||||
case $dhcp_option in
|
||||
43) dhcp_option_value=$opt43 ;;
|
||||
66) dhcp_option_value=$opt66 ;;
|
||||
67) dhcp_option_value=$opt67 ;;
|
||||
128) dhcp_option_value=$opt128 ;;
|
||||
132) dhcp_option_value=$opt132 ;;
|
||||
133) dhcp_option_value=$opt133 ;;
|
||||
224) dhcp_option_value=$opt224 ;;
|
||||
225) dhcp_option_value=$opt225 ;;
|
||||
226) dhcp_option_value=$opt226 ;;
|
||||
*) dhcp_option_value="unsupported" ;;
|
||||
esac
|
||||
|
||||
if [ "${dhcp_option_value}" == "unsupported" ] ; then
|
||||
echo "dhcp_option $dhcp_option is unsupported"
|
||||
return
|
||||
fi
|
||||
if [ "${dhcp_option_value}" == "" ] ; then
|
||||
echo "dhcp_option $dhcp_option is empty"
|
||||
return
|
||||
fi
|
||||
|
||||
#echo "dhcp_option: $dhcp_option dhcp_option_value: ${dhcp_option_value}"
|
||||
|
||||
#config_list_foreach $section to_interface foreach_to_interface
|
||||
|
||||
add_section_dhcp_vendorclass $dhcp_option ${dhcp_option_value} $vendorclass
|
||||
}
|
||||
|
||||
foreach_from_interface() {
|
||||
from_interface="$1"
|
||||
#echo "from_interface: $from_interface"
|
||||
if [ "$from_interface" != "$interface" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
dhcp_option=""
|
||||
config_list_foreach $section dhcp_option foreach_dhcp_option
|
||||
#config_list_foreach $section dhcp_options foreach_dhcp_option
|
||||
}
|
||||
|
||||
from_interface=""
|
||||
config_list_foreach $section from_interface foreach_from_interface
|
||||
}
|
||||
|
||||
|
||||
# in uci dhcp config:
|
||||
# remove all the vendorclass sections
|
||||
# that have previosly been configured by this script.
|
||||
# all are identified by "option networkid dhcp_option_relay_*"
|
||||
function dhcp_option_relay_clear_prev()
|
||||
{
|
||||
local to_remove=""
|
||||
|
||||
foreach_vendorclass() {
|
||||
local section="$1"
|
||||
local networkid
|
||||
config_get networkid $section networkid
|
||||
|
||||
case "$networkid"
|
||||
in dhcp_option_relay*)
|
||||
to_remove="$to_remove $section"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
config_load dhcp
|
||||
config_foreach foreach_vendorclass vendorclass
|
||||
|
||||
local sect
|
||||
for sect in $to_remove ; do
|
||||
uci_remove dhcp $sect
|
||||
done
|
||||
uci_commit dhcp
|
||||
}
|
||||
|
||||
|
||||
# the main function
|
||||
function dhcp_option_relay_parse()
|
||||
{
|
||||
local the_json="$@"
|
||||
parse_the_json "$the_json"
|
||||
|
||||
dhcp_option_relay_clear_prev
|
||||
|
||||
newsectionid="0"
|
||||
|
||||
config_load provisioning
|
||||
config_foreach dhcp_option_relay dhcp_option_relay
|
||||
#config_foreach dhcp_option_relay dhcp_options_relay
|
||||
#config_foreach dhcp_option_relay dhcpoption_relay
|
||||
#config_foreach dhcp_option_relay dhcpoptions_relay
|
||||
#config_foreach dhcp_option_relay dhcp_optionrelay
|
||||
#config_foreach dhcp_option_relay dhcp_optionsrelay
|
||||
#config_foreach dhcp_option_relay dhcpoptionrelay
|
||||
#config_foreach dhcp_option_relay dhcpoptionsrelay
|
||||
}
|
||||
|
||||
#dhcp_option_relay_parse
|
||||
@@ -1,595 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo $$ > /var/run/iup.pid
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/network.sh
|
||||
. /lib/functions/savecfg.sh
|
||||
. /lib/functions/dhcp_option_relay.sh
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
include /lib/upgrade
|
||||
include /lib/network
|
||||
|
||||
export IUPCONFFILES=/tmp/iup/sysupgrade.conffiles.tar.gz
|
||||
export IUPMD5=/etc/configchecksums
|
||||
export CONFILESLURP='/tmp/iup/*.conf'
|
||||
export IUPTEMP="/tmp/iup"
|
||||
export INTERACTIVE=0
|
||||
export VERBOSE=0
|
||||
export CONF=1
|
||||
export DESKEY=
|
||||
export MAC=
|
||||
export RANGE=10
|
||||
export RETRYSTOP=5
|
||||
export SLEEP=10
|
||||
|
||||
json_load "$(ubus call router.system info)"
|
||||
json_select system
|
||||
json_get_var MAC basemac
|
||||
json_select ..
|
||||
json_select keys
|
||||
json_get_var DESKEY des
|
||||
json_select ..
|
||||
|
||||
# MAC lowercase to uppercase and remove ':'
|
||||
MAC=$(echo $MAC | tr '[a-z]' '[A-Z]' | tr -d ':')
|
||||
|
||||
# Convert DESKEY to HEX format
|
||||
DESKEY=$(echo $DESKEY | tr -d '\n' | hexdump -e '16/1 "%02x"')
|
||||
|
||||
|
||||
# no verbose: no output
|
||||
# -v log to system log
|
||||
# -v -v log to system log and console
|
||||
# -v -v -v log to system log, console and stderr
|
||||
v() {
|
||||
[ "$VERBOSE" -eq 0 ] && return
|
||||
[ "$VERBOSE" -eq 1 ] && logger -t $0[$$] "$@" && return
|
||||
[ "$VERBOSE" -eq 2 ] && logger -s -t $0[$$] "$@" >/dev/console 2>&1 && return
|
||||
[ "$VERBOSE" -eq 3 ] && logger -s -t $0[$$] "$@" 2>&1 | tee /dev/console && return
|
||||
}
|
||||
|
||||
vv() {
|
||||
VERBOSE="$(($VERBOSE + 1))"
|
||||
v "$@"
|
||||
VERBOSE="$(($VERBOSE - 1))"
|
||||
|
||||
}
|
||||
|
||||
get_packages()
|
||||
{
|
||||
local pack
|
||||
pack=$(grep -w 'package' $1)
|
||||
pack=${pack//package/}
|
||||
#pack=${pack//[\'|\"]/}
|
||||
echo $pack | tr -d '\"' | tr -d "'"
|
||||
}
|
||||
|
||||
reload ()
|
||||
{
|
||||
local pack
|
||||
pack=$(get_packages $1)
|
||||
v "Calling ubus call uci commit for $pack"
|
||||
for packname in $pack
|
||||
do
|
||||
ubus call uci commit '{"config":"'$packname'"}'
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
save_usercfg()
|
||||
{
|
||||
savecfg_save_config fw_redirect fw_parental wifi
|
||||
}
|
||||
|
||||
apply_usercfg()
|
||||
{
|
||||
# decide to save the user changes based on keepuserconfig received through provisioning
|
||||
local keep
|
||||
config_load provisioning
|
||||
config_get_bool keep configserver keepuserconfig "0"
|
||||
v "apply_usercfg(): keepuserconfig = $keep"
|
||||
if [ "$keep" != "1" ] ; then
|
||||
savecfg_rm_files
|
||||
return
|
||||
fi
|
||||
|
||||
savecfg_apply_config fw_redirect fw_parental wifi
|
||||
}
|
||||
|
||||
handle_provisioning() {
|
||||
local config="$1"
|
||||
local default="$2"
|
||||
local enabled
|
||||
local url
|
||||
local tftpfile
|
||||
local host
|
||||
local md5
|
||||
local defaultreset
|
||||
local pack
|
||||
local packname
|
||||
local number=$RANDOM
|
||||
local retry=1
|
||||
local number
|
||||
local incsleep=$SLEEP
|
||||
let "number %= $RANGE"
|
||||
if [[ ! -e $IUPTEMP ]]; then
|
||||
mkdir $IUPTEMP
|
||||
fi
|
||||
touch $IUPCONFFILES
|
||||
config_get_bool enabled "$config" enabled "$default"
|
||||
config_get_bool defaultreset "$config" defaultreset
|
||||
config_get deckey "$config" deckey
|
||||
if [ "$enabled" -eq 1 ]; then
|
||||
if [ "$config" == "iup" ]; then
|
||||
v "Using url received in dhcp options"
|
||||
config_get url "$config" urliup
|
||||
else
|
||||
config_get url "$config" url
|
||||
fi
|
||||
url=${url//\$MAC/$MAC}
|
||||
v "Downloading from url \"$url\""
|
||||
|
||||
while [ $retry -le $RETRYSTOP ]
|
||||
do
|
||||
if [ ${url%%:*} == "tftp" ]; then
|
||||
tftpfile=${url#*\/\/}
|
||||
host=${tftpfile%%\/*}
|
||||
tftpfile=${tftpfile#*\/}
|
||||
|
||||
/usr/bin/tftp -l $IUPCONFFILES -r "$tftpfile" -g "$host"
|
||||
else
|
||||
get_image "$url" "cat" > $IUPCONFFILES
|
||||
fi
|
||||
if [ -s $IUPCONFFILES ]; then
|
||||
v "Download finished"
|
||||
retry=$((RETRYSTOP + 1))
|
||||
else
|
||||
v "Download failed, retrying in $incsleep seconds"
|
||||
sleep $incsleep
|
||||
incsleep=$((incsleep * retry + number))
|
||||
retry=$((retry+1))
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ ! -s "$IUPCONFFILES" ] && [ "$enabled" -eq 1 ]; then
|
||||
echo "File not Found"
|
||||
reboot="off"
|
||||
CONF=0
|
||||
else
|
||||
handle_Downloaded_file $deckey
|
||||
fi
|
||||
}
|
||||
|
||||
handle_Downloaded_file()
|
||||
{
|
||||
local DECKEY
|
||||
local KEY
|
||||
[ -n "$1" ] && DECKEY=$(echo $1 | tr -d '\n' | hexdump -e '16/1 "%02x"')
|
||||
KEY=${DECKEY:-$DESKEY}
|
||||
local img_type
|
||||
case "$(get_image_type "$IUPCONFFILES")" in
|
||||
"INTENO") img_type=2 ;;
|
||||
"CFE+FS") img_type=1 ;;
|
||||
"FS") img_type=0 ;;
|
||||
*) img_type="UNKNOWN";;
|
||||
esac
|
||||
|
||||
if [ "$img_type" == "UNKNOWN" ] ; then
|
||||
case "$(hexdump -v -n 2 -e '1/1 "%02x"' $IUPCONFFILES)" in
|
||||
1f8b)
|
||||
v "Downloaded file is an unencrypted config"
|
||||
md5=$(md5sum $IUPCONFFILES)
|
||||
md5="${md5%% *}" # remove the first space and everything after it
|
||||
md5sum "$IUPCONFFILES" >> "$IUPMD5.temp"
|
||||
if grep -q "$md5" "$IUPMD5"; then
|
||||
v "Config is already up to date, nothing to do"
|
||||
#because config is up to date we need to disable last step reboot if set
|
||||
reboot="off"
|
||||
rm -rf $IUPTEMP
|
||||
else
|
||||
save_usercfg
|
||||
cd $IUPTEMP
|
||||
tar xvzf $IUPCONFFILES
|
||||
for f in $CONFILESLURP
|
||||
do
|
||||
v "File to be applied $f and config $(cat $f)"
|
||||
uci -f $f import
|
||||
done
|
||||
pack=$(get_packages $CONFILESLURP)
|
||||
v "Packages to be commited: $pack"
|
||||
for packname in $pack
|
||||
do
|
||||
uci commit $packname
|
||||
done
|
||||
apply_usercfg
|
||||
reboot=`uci -q get provisioning.configserver.reboot`
|
||||
if [ "$reboot" != "on" ]; then
|
||||
sync
|
||||
reload $CONFILESLURP
|
||||
fi
|
||||
rm -rf $IUPTEMP
|
||||
|
||||
cp /rom/etc/uci-defaults/* /etc/uci-defaults/
|
||||
sync
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
v "Downloaded file is an encrypted config"
|
||||
if [ $KEY ]; then
|
||||
openssl enc -d -des-ede -nosalt -K $KEY -iv "0000000000000000" -in $IUPCONFFILES -out $IUPCONFFILES.tmp
|
||||
if [ $? -eq 0 ]; then
|
||||
v "Decryption successful"
|
||||
mv $IUPCONFFILES.tmp $IUPCONFFILES
|
||||
handle_Downloaded_file
|
||||
else
|
||||
v "Decryption Failed! Exiting"
|
||||
rm -rf $IUPTEMP
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
v "No Key Defined"
|
||||
rm -rf $IUPTEMP
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
else
|
||||
v "Downloaded file is a firmware, will start reflashing"
|
||||
if [ "$defaultreset" -eq 1 ]; then
|
||||
v "Not saving configuration over reflash"
|
||||
/sbin/sysupgrade -v -n $IUPCONFFILES
|
||||
else
|
||||
v "Saving configuration over reflash"
|
||||
/sbin/sysupgrade -v $IUPCONFFILES
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# function: change_to_vlan
|
||||
# arg 1 = vlan id
|
||||
# arg 2 = vlan priority
|
||||
# arg 3 = $INTERFACE
|
||||
change_to_vlan() {
|
||||
# local variables.
|
||||
local name="vlan$1" # construct name = vlan + vlanid.
|
||||
local base_dev # varible holding device name of wan port.
|
||||
local wan_if # variable holding wan interfaces.
|
||||
local new_wan_if #
|
||||
|
||||
# extract device name.
|
||||
network_get_device base_dev $3
|
||||
|
||||
# bring down old interface/device.
|
||||
ifdown "${base_dev}"
|
||||
v "option 132: bringing down old if: ${base_dev}"
|
||||
|
||||
# extract base name of device.
|
||||
base_dev=$(echo ${base_dev} | cut -d. -f1)
|
||||
|
||||
# add "VLAN interface" to the "end of the file".
|
||||
uci add network device
|
||||
uci rename network.@device[-1]=${name}
|
||||
uci set network.@device[-1].type=8021q
|
||||
uci set network.@device[-1].ifname=${base_dev}
|
||||
uci set network.@device[-1].name="${base_dev}.${1}"
|
||||
uci set network.@device[-1].vid=${1}
|
||||
uci set network.@device[-1].priority=${2}
|
||||
# and commit the change.
|
||||
uci commit network
|
||||
v "option 132: committed update to file network"
|
||||
|
||||
# reload configuration files.
|
||||
ubus call network reload
|
||||
v "option 132: reload network config"
|
||||
|
||||
# replace old interface (like eth0.1 with new eth0.101).
|
||||
wan_if=$(uci get network.$3.ifname)
|
||||
v "option 132: old network.${3}.ifname: $wan_if"
|
||||
|
||||
# loop through the string, remove any word close to "base_dev".
|
||||
for word in ${wan_if}; do
|
||||
#echo $word
|
||||
case $word in
|
||||
${base_dev}*) # don't add if.
|
||||
;;
|
||||
*) new_wan_if=${word}' '${new_wan_if} # add if.
|
||||
#new_wan_if+=" ${word}" # probably not working in ash.
|
||||
;;
|
||||
esac
|
||||
done
|
||||
# append new interface.
|
||||
new_wan_if=${new_wan_if}${base_dev}.${1}
|
||||
uci set network.wan.ifname="${new_wan_if}"
|
||||
# and commit the change.
|
||||
uci commit network
|
||||
v "option 132: committed update to file network: ifname=${new_wan_if}"
|
||||
|
||||
# reboot into new if configuration.
|
||||
vv "Rebooting"
|
||||
export REBOOT_REASON=iup
|
||||
/sbin/reboot
|
||||
}
|
||||
|
||||
handle_option224()
|
||||
{
|
||||
if [ -z "$1" ] ; then
|
||||
echo "No argument"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ $(echo $1|grep -o "," | wc -l) -eq 0 ] ; then
|
||||
url=$1
|
||||
else
|
||||
url=$(echo $1|cut -d',' -f1)
|
||||
a=$(echo $1|cut -d',' -f2)
|
||||
b=$(echo $1|cut -d',' -f3)
|
||||
c=$(echo $1|cut -d',' -f4)
|
||||
fi
|
||||
|
||||
currdate=$(date +"%Y-%m-%d")
|
||||
|
||||
active=0
|
||||
if [ -z $a ] ; then
|
||||
active=1
|
||||
elif [ $a ] && [ $b ] && [ $a -lt 25 ] ; then
|
||||
#Time
|
||||
begin=$(date +%s -d"$currdate $a")
|
||||
now=$(date +%s)
|
||||
end=$((begin+3600*$b))
|
||||
if [ $now -gt $begin ] && [ $now -lt $end ] ; then
|
||||
active=1
|
||||
fi
|
||||
elif [ $a ] && [ $b ] && [ $c ] && [ $a -gt 25 ] ; then
|
||||
#Date
|
||||
y=$(echo $a| cut -c1-4)
|
||||
m=$(echo $a| cut -c5-6)
|
||||
d=$(echo $a| cut -c7-8)
|
||||
begin=$(date +%s -d"$y-$m-$d $b")
|
||||
now=$(date +%s)
|
||||
end=$((begin+3600*$c))
|
||||
if [ $now -gt $begin ] && [ $now -lt $end ] ; then
|
||||
active=1
|
||||
fi
|
||||
else
|
||||
echo "Bad format"
|
||||
return 1
|
||||
fi
|
||||
|
||||
softwareminuspath=${url##*/}
|
||||
|
||||
if [ $url ] && [ $active -eq 1 ]; then
|
||||
v "Software version to download \"$softwareminuspath\""
|
||||
local sysinfo=$(ubus call router.system info)
|
||||
json_load "$sysinfo"
|
||||
json_select system
|
||||
json_get_var firmware firmware
|
||||
local firmware_new=${softwareminuspath%.*} # remove extension (.w, .y or .y2) from filename
|
||||
if [ "$firmware_new" != "$firmware" ] ; then
|
||||
v "Firmware found $url will start flashing"
|
||||
v "Currently running firmware: \"$firmware\""
|
||||
v "Newly received firmware: \"$firmware_new\""
|
||||
wait_for_dns $url
|
||||
v "Start flashing"
|
||||
/sbin/sysupgrade -v $url &
|
||||
return 1
|
||||
else
|
||||
v "Firmware is up to date, nothing to do"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
parse_dhcp_options()
|
||||
{
|
||||
local the_json="$@"
|
||||
|
||||
# process the dhcp_option_relay sections
|
||||
dhcp_option_relay_parse "$the_json"
|
||||
|
||||
# Process IUP related DHCP options #
|
||||
local privopt224 privopt225 privopt226 vendorspecinf httpurl128
|
||||
local tftp bootfile vlanid vlanpriority interface
|
||||
|
||||
json_load "$the_json"
|
||||
json_get_var interface interface
|
||||
json_get_var privopt224 privopt224
|
||||
json_get_var privopt225 privopt225
|
||||
json_get_var privopt226 privopt226
|
||||
json_get_var vendorspecinf vendorspecinf # option 43
|
||||
json_get_var httpurl128 httpurl128
|
||||
json_get_var tftp tftp # option 66
|
||||
json_get_var bootfile bootfile #option 67
|
||||
json_get_var vlanid vlanid # option 132
|
||||
json_get_var vlanpriority vlanpriority # option 133
|
||||
|
||||
if [ $privopt224 ]; then
|
||||
v "dhcp option 224 firmware url $privopt224"
|
||||
handle_option224 $privopt224
|
||||
[ $? -eq 1 ] && exit
|
||||
fi
|
||||
|
||||
if [ $vendorspecinf ]; then
|
||||
v "dhcp option 43 tr69 url $vendorspecinf"
|
||||
url=${vendorspecinf%%,*}; rest=${vendorspecinf#*,}
|
||||
provisioningcode=${rest%%,*};
|
||||
[ -f /etc/config/cwmp ] && uci_set_state cwmp acs dhcp_url "$url"
|
||||
uci_set_state provisioning iup urlcwmp "$url"
|
||||
uci_set_state provisioning iup url "$url"
|
||||
uci_set_state provisioning iup provisioningcode "$provisioningcode"
|
||||
elif [ $httpurl128 ]; then
|
||||
v "dhcp option 128 http config url $httpurl128"
|
||||
uci_set_state provisioning iup urliup "$httpurl128"
|
||||
elif [ $tftp ]; then
|
||||
v "dhcp option 66 tftp config url $tftp"
|
||||
if [ ${bootfile:0:1} == '/' ]; then
|
||||
uci_set_state provisioning iup urliup "tftp://$tftp$bootfile"
|
||||
else
|
||||
uci_set_state provisioning iup urliup "tftp://$tftp/$bootfile"
|
||||
fi
|
||||
fi
|
||||
|
||||
# vlanid (and vlanpriority)
|
||||
if [ -n "$vlanid" -a -n "$vlanpriority" ]; then
|
||||
v "dhcp option 132 vlanid: ${vlanid} vlanpriority: ${vlanpriority}"
|
||||
change_to_vlan ${vlanid} ${vlanpriority} ${interface}
|
||||
elif [ -n "$vlanid" ]; then
|
||||
v "dhcp option 132 vlanid: ${vlanid}"
|
||||
change_to_vlan ${vlanid} 0 ${interface}
|
||||
elif [ -n "$privopt225" ] || [ -n "$privopt226" ]; then
|
||||
# opt225 and opt226 can be used together or separatly
|
||||
if [ -n "$privopt225" ]; then
|
||||
v "dhcp option 225: $privopt225"
|
||||
# option225 is allowd to change only once per CPE
|
||||
if [ "$(uci get -q ice.cloud.frozen)" != "1" ] ; then
|
||||
uci set ice.cloud.frozen="1"
|
||||
uci set ice.cloud.enabled="1"
|
||||
uci set ice.cloud.server="$privopt225"
|
||||
fi
|
||||
fi
|
||||
if [ -n "$privopt226" ]; then
|
||||
v "dhcp option 226: $privopt226"
|
||||
[ -z "$(uci get -q ice.dhcp)" ] && uci set ice.dhcp="dhcp"
|
||||
uci set ice.dhcp.opt226connectionid="$privopt226"
|
||||
ubus send dhcp.opt226connectionid '{"opt226connectionid":"","value":"'$privopt226'"}'
|
||||
fi
|
||||
uci commit
|
||||
fi
|
||||
}
|
||||
|
||||
# wait_for_default_gateway to become reachable
|
||||
# return 0 if the default gateway is reachable
|
||||
# return 1 if the default gateway is not reachable after $wait_time
|
||||
wait_for_default_gateway()
|
||||
{
|
||||
local gateway
|
||||
local device
|
||||
local wait_time=120
|
||||
local wait_interval=10
|
||||
|
||||
while [ true ] ; do
|
||||
|
||||
gateway=""
|
||||
device=""
|
||||
network_flush_cache
|
||||
network_get_gateway gateway wan #true
|
||||
network_get_device device wan
|
||||
device="${device:+-I }$device"
|
||||
if ping -q -w 1 -c 1 $device $gateway >/dev/null 2>&1 ; then
|
||||
[ "$wait_time" -lt "60" ] && v "Default gateway $gateway is reachable"
|
||||
sleep $wait_interval
|
||||
return 0
|
||||
fi
|
||||
|
||||
# try the nameservers too
|
||||
for ns in $(grep nameserver /var/resolv.conf.auto | awk '{print $2}'); do
|
||||
if ping -q -w 1 -c 1 $device $ns >/dev/null 2>&1 ; then
|
||||
[ "$wait_time" -lt "60" ] && v "Name server $ns is reachable"
|
||||
sleep $wait_interval
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
v "Waiting for default gateway or name server. Countdown $wait_time seconds"
|
||||
sleep $wait_interval
|
||||
wait_time=$((wait_time - wait_interval))
|
||||
[ "$wait_time" -le "0" ] && break # timer expired
|
||||
done
|
||||
|
||||
return 1 # default gateway and name server are not reachable
|
||||
}
|
||||
|
||||
|
||||
main()
|
||||
{
|
||||
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
-v) export VERBOSE="$(($VERBOSE + 1))";;
|
||||
-q) export VERBOSE="$(($VERBOSE - 1))";;
|
||||
--dhcp-options)
|
||||
shift
|
||||
parse_dhcp_options "$@"
|
||||
exit 0
|
||||
;;
|
||||
-*)
|
||||
echo "Invalid option: $1"
|
||||
exit 1
|
||||
;;
|
||||
*) break;;
|
||||
esac
|
||||
shift;
|
||||
done
|
||||
|
||||
if ! wait_for_default_gateway ; then
|
||||
v "Neither default gateway nor name server are reachable. Aborting iup."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f $IUPMD5 ]; then
|
||||
v "Creating file $IUPMD5"
|
||||
touch $IUPMD5
|
||||
fi
|
||||
|
||||
|
||||
local iupurl
|
||||
local configurl
|
||||
local software
|
||||
local sofwareminuspath
|
||||
|
||||
config_load provisioning
|
||||
#check if iup should be used or if its overridden by /etc/config
|
||||
config_get configurl configserver url
|
||||
config_get reboot configserver reboot
|
||||
config_get iupurl iup urliup
|
||||
|
||||
if [ $configurl ]; then
|
||||
handle_provisioning configserver "0"
|
||||
elif [ $iupurl ]; then
|
||||
handle_provisioning iup "1"
|
||||
else
|
||||
v "No provisioning server configured"
|
||||
exit
|
||||
fi
|
||||
|
||||
config_load provisioning
|
||||
config_foreach handle_provisioning subconfig "0"
|
||||
config_get software uppgradeserver url
|
||||
sofwareminuspath=${software##*/}
|
||||
|
||||
if [ $software ]; then
|
||||
v "Software version to download \"$sofwareminuspath\""
|
||||
local sysinfo=$(ubus call router.system info)
|
||||
json_load "$sysinfo"
|
||||
json_select system
|
||||
json_get_var firmware firmware
|
||||
json_get_var filesystem filesystem
|
||||
if [ "$filesystem" == "JFFS2" ] ; then
|
||||
firmware=$firmware.w
|
||||
else
|
||||
firmware=$firmware.y3
|
||||
fi
|
||||
if [ "$sofwareminuspath" == "${sofwareminuspath/$firmware/}" ] ; then
|
||||
v "Software \"$software\""
|
||||
handle_provisioning uppgradeserver "0"
|
||||
else
|
||||
v "Will not update software, already up to date"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $CONF -eq 1 ]; then
|
||||
mv "$IUPMD5.temp" $IUPMD5
|
||||
fi
|
||||
|
||||
if [ "$reboot" == "on" ]; then
|
||||
vv "Rebooting"
|
||||
export REBOOT_REASON=iup
|
||||
/sbin/reboot
|
||||
fi
|
||||
|
||||
rm -rf /var/run/iup.pid
|
||||
}
|
||||
|
||||
main $@
|
||||
32
json-editor/Makefile
Normal file
32
json-editor/Makefile
Normal file
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Copyright (C) 2019 IOPSYS
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=json-editor
|
||||
PKG_RELEASE:=1.0.0
|
||||
|
||||
PKG_SOURCE_VERSION:=44b32937a062ec4ffc9f7355841dc94ab6efa50f
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=git@dev.iopsys.eu:iopsys/json-editor.git
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
|
||||
define Package/json-editor
|
||||
SECTION:=base
|
||||
CATEGORY:=Libraries
|
||||
DEPENDS:=+libjson-c +libblobmsg-json
|
||||
TITLE:=JSON-editor
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(CP) $(PKG_BUILD_DIR)/src/json-editor.h $(1)/usr/include/
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libjson-editor.so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,json-editor))
|
||||
@@ -1,105 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2016 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=libcgroup
|
||||
PKG_VERSION:=0.41
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_LICENSE:=LGPL-2.1
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
|
||||
PKG_SOURCE_VERSION:=2186c97f60df7efe86ddadd5e3d9d36dd4923b98
|
||||
|
||||
PKG_SOURCE_URL:=git://git.code.sf.net/p/libcg/libcg
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)+git$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
#PKG_BUILD_PARALLEL:=1
|
||||
PKG_FIXUP:=autoreconf
|
||||
|
||||
# run install target when cross compiling. basically, make install DESTDIR=$(PKG_INSTALL_DIR)
|
||||
# this way we don't need to pick out the resulting files from the build dir.
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/libcgroup
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
DEPENDS:=+libpthread
|
||||
TITLE:=Control group configuration library
|
||||
URL:=https://sourceforge.net/p/libcg/
|
||||
endef
|
||||
|
||||
define Package/libcgroup/description
|
||||
Control groups, a new kernel feature in Linux 2.6.24 provides a file system
|
||||
interface to manipulate and control the details on task grouping including
|
||||
creation of new task groups (control groups), permission handling and task
|
||||
assignment.
|
||||
endef
|
||||
|
||||
define Package/libcgroup-daemon
|
||||
SECTION:=base
|
||||
CATEGORY:=Base system
|
||||
DEPENDS:=+libcgroup +librt
|
||||
TITLE:=Control group management daemon
|
||||
URL:=https://sourceforge.net/p/libcg/
|
||||
endef
|
||||
|
||||
define Package/libcgroup-utils
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
DEPENDS:=+libcgroup
|
||||
TITLE:=Control group configuration utilities
|
||||
URL:=https://sourceforge.net/p/libcg/
|
||||
endef
|
||||
|
||||
#define Package/libcgroup/conffiles
|
||||
# /etc/config/cgroups
|
||||
#endef
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--disable-bindings \
|
||||
--disable-pam \
|
||||
--enable-static \
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include/libcgroup
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/include/libcgroup/*.h $(1)/usr/include/libcgroup/
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/lib $(1)/usr/lib/pkgconfig
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcgroup.* $(1)/usr/lib/
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libcgroup.pc $(1)/usr/lib/pkgconfig/
|
||||
endef
|
||||
|
||||
define Package/libcgroup/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcgroup.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/libcgroup-daemon/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/* $(1)/usr/sbin
|
||||
|
||||
# move to its own package?
|
||||
$(INSTALL_DIR) $(1)/etc/config $(1)/etc/init.d
|
||||
$(INSTALL_CONF) ./files/cgroups.config $(1)/etc/config/cgroups
|
||||
$(INSTALL_BIN) ./files/cgroups.init $(1)/etc/init.d/cgroups
|
||||
endef
|
||||
|
||||
define Package/libcgroup-utils/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libcgroup))
|
||||
$(eval $(call BuildPackage,libcgroup-daemon))
|
||||
$(eval $(call BuildPackage,libcgroup-utils))
|
||||
@@ -1,40 +0,0 @@
|
||||
config cgroups cgroups
|
||||
option enabled 1
|
||||
option defgroup iopsys/normal
|
||||
|
||||
config cgroup _root_
|
||||
list option memory.move_charge_at_immigrate=1
|
||||
|
||||
config cgroup iopsys
|
||||
list option cpu.shares=4096
|
||||
list option memory.limit_in_bytes=-1
|
||||
list option memory.move_charge_at_immigrate=1
|
||||
|
||||
config cgroup iopsys_normal
|
||||
list option cpu.shares=1024
|
||||
list option memory.limit_in_bytes=-1
|
||||
list option memory.move_charge_at_immigrate=1
|
||||
|
||||
config cgroup iopsys_high
|
||||
list option cpu.shares=4096
|
||||
list option memory.limit_in_bytes=-1
|
||||
list option memory.move_charge_at_immigrate=1
|
||||
|
||||
config cgroup 3prt
|
||||
list option cpu.shares=1024
|
||||
list option memory.limit_in_bytes=75M
|
||||
list option memory.move_charge_at_immigrate=1
|
||||
|
||||
config cgroup 3prt_normal
|
||||
list option cpu.shares=1024
|
||||
list option memory.limit_in_bytes=75M
|
||||
list option memory.move_charge_at_immigrate=1
|
||||
|
||||
config cgroup 3prt_high
|
||||
list option cpu.shares=4096
|
||||
list option memory.limit_in_bytes=75M
|
||||
list option memory.move_charge_at_immigrate=1
|
||||
|
||||
config procmap procmap
|
||||
list procmap minidlna=3prt/normal
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=01
|
||||
USE_PROCD=1
|
||||
#PROCD_DEBUG=1
|
||||
NAME=cgrulesengd
|
||||
|
||||
CGBASEDIR=/sys/fs/cgroup
|
||||
CGCONFIG="cgroups"
|
||||
|
||||
CGRULESCONF=/tmp/cgrules.conf
|
||||
CGCONFIGCONF=/tmp/cgconfig.conf
|
||||
|
||||
|
||||
cgroupinit_add_knob_val_to_list () {
|
||||
CG_KNOB_VAL_LIST="$CG_KNOB_VAL_LIST
|
||||
$1"
|
||||
}
|
||||
|
||||
cgroupinit_create_group () {
|
||||
local cgrp=$1
|
||||
local dir curr
|
||||
|
||||
if [ "$cgrp" == "_root_" ]; then
|
||||
dir=.
|
||||
else
|
||||
dir=$(echo $cgrp |tr '_' '/')
|
||||
fi
|
||||
|
||||
echo -e "group $dir {" >> $CGCONFIGCONF
|
||||
|
||||
CG_KNOB_VAL_LIST=
|
||||
config_list_foreach $cgrp option cgroupinit_add_knob_val_to_list
|
||||
CG_KNOB_VAL_LIST=$(echo "$CG_KNOB_VAL_LIST" |sort)
|
||||
curr="_none_"
|
||||
|
||||
for knob_val in $CG_KNOB_VAL_LIST ; do
|
||||
local ctrlr knob val
|
||||
|
||||
knob=$(echo $knob_val |awk -F= '{print $1}')
|
||||
ctrlr=$(echo $knob |awk -F. '{print $1}')
|
||||
val=$(echo $knob_val |awk -F= '{print $2}')
|
||||
|
||||
if [ "$curr" != "$ctrlr" ]; then
|
||||
[ "$curr" == "_none_" ] || echo -e "\t}" >> $CGCONFIGCONF
|
||||
curr=$ctrlr
|
||||
echo -e "\t$curr {" >> $CGCONFIGCONF
|
||||
fi
|
||||
|
||||
echo -e "\t\t$knob = \"$val\";" >> $CGCONFIGCONF
|
||||
done
|
||||
|
||||
[ "$curr" == "_none_" ] || echo -e "\t}" >> $CGCONFIGCONF
|
||||
echo -e "}\n" >> $CGCONFIGCONF
|
||||
}
|
||||
|
||||
cgroupinit_add_to_rules () {
|
||||
local name_grp=$1
|
||||
local name grp
|
||||
|
||||
name=$(echo $name_grp |awk -F= '{print $1}')
|
||||
grp=$(echo $name_grp |awk -F= '{print $2}')
|
||||
|
||||
echo -e "*:$name\t*\t$grp" >> $CGRULESCONF
|
||||
}
|
||||
|
||||
cgroupinit_generate_config () {
|
||||
local enab defgrp
|
||||
|
||||
config_load $CGCONFIG
|
||||
|
||||
config_get enab cgroups enabled "1"
|
||||
[ $enab -eq 0 ] && return 1
|
||||
|
||||
config_get defgrp cgroups defgroup "_undef_"
|
||||
[ "$defgrp" == "_undef_" ] && return 1
|
||||
|
||||
# mount here instead of in cgconfigparser to get all options right
|
||||
# mounting without any controllers listed means mount all available
|
||||
if ! grep -q " $CGBASEDIR cgroup " /proc/mounts; then
|
||||
mount -t cgroup -o nodev,noexec,nosuid cgroup $CGBASEDIR
|
||||
[ $? -eq 0 ] || return 1
|
||||
fi
|
||||
|
||||
echo -n '' > $CGCONFIGCONF
|
||||
config_foreach cgroupinit_create_group cgroup
|
||||
|
||||
echo -n '' > $CGRULESCONF
|
||||
config_list_foreach procmap procmap cgroupinit_add_to_rules
|
||||
echo -e "*\t*\t$defgrp" >> $CGRULESCONF
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# cgrulesengd has hardcoded paths for configuration files
|
||||
# use symlinks to point to generated config files
|
||||
cgroupinit_cgrulesengd_fixup () {
|
||||
[ -r /etc/cgrules.conf ] || ln -s $CGRULESCONF /etc/cgrules.conf
|
||||
[ -r /etc/cgconfig.conf ] || ln -s $CGCONFIGCONF /etc/cgconfig.conf
|
||||
[ -d /etc/cgconfig.d ] || mkdir /etc/cgconfig.d
|
||||
}
|
||||
|
||||
start_service () {
|
||||
cgroupinit_generate_config
|
||||
[ $? -eq 0 ] || return
|
||||
|
||||
cgroupinit_cgrulesengd_fixup
|
||||
/usr/sbin/cgconfigparser -l $CGCONFIGCONF || return
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command /usr/sbin/cgrulesengd --nodaemon --syslog
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop_service () {
|
||||
/usr/sbin/cgclear
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger $CGCONFIG
|
||||
}
|
||||
|
||||
56
libmicroxml/Makefile
Normal file
56
libmicroxml/Makefile
Normal file
@@ -0,0 +1,56 @@
|
||||
#
|
||||
# Copyright (C) 2012-2014 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=libmicroxml
|
||||
PKG_VERSION:=2012-06-11
|
||||
PKG_RELEASE=$(PKG_SOURCE_VERSION)
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/mirror/microxml.git
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_VERSION:=72965423184f24cc0b963d91c2d1863cdb01b6aa
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_LICENSE:=LGPL-2.0
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/libmicroxml
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=XML library
|
||||
MAINTAINER:=Luka Perkov <luka@openwrt.org>
|
||||
endef
|
||||
|
||||
define Package/libmicroxml/description
|
||||
A micro sized XML library
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--disable-threads \
|
||||
--enable-static \
|
||||
--enable-shared
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(CP) $(PKG_BUILD_DIR)/microxml.h $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libmicroxml.so* $(1)/usr/lib
|
||||
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
|
||||
$(CP) $(PKG_BUILD_DIR)/microxml.pc $(1)/usr/lib/pkgconfig
|
||||
endef
|
||||
|
||||
define Package/libmicroxml/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/libmicroxml.so* $(1)/usr/lib
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libmicroxml))
|
||||
130
libmicroxml/patches/100-fix-memleak.patch
Normal file
130
libmicroxml/patches/100-fix-memleak.patch
Normal file
@@ -0,0 +1,130 @@
|
||||
diff --git a/mxml-file.c b/mxml-file.c
|
||||
index 02eca9d..f10d202 100644
|
||||
--- a/mxml-file.c
|
||||
+++ b/mxml-file.c
|
||||
@@ -363,9 +363,12 @@ mxmlSaveFile(mxml_node_t *node, /* I - Node to write */
|
||||
* Write the node...
|
||||
*/
|
||||
|
||||
- if ((col = mxml_write_node(node, fp, cb, 0, mxml_file_putc, global)) < 0)
|
||||
+ if ((col = mxml_write_node(node, fp, cb, 0, mxml_file_putc, global)) < 0){
|
||||
+ global_free(global);
|
||||
return (-1);
|
||||
-
|
||||
+ }
|
||||
+
|
||||
+ global_free(global);
|
||||
if (col > 0)
|
||||
if (putc('\n', fp) < 0)
|
||||
return (-1);
|
||||
@@ -1448,6 +1451,7 @@ mxml_load_data(
|
||||
if ((buffer = malloc(64)) == NULL)
|
||||
{
|
||||
mxml_error("Unable to allocate string buffer!");
|
||||
+ global_free(global);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@@ -2083,11 +2087,12 @@ mxml_load_data(
|
||||
node->parent ? node->parent->value.element.name : "(null)");
|
||||
|
||||
mxmlDelete(first);
|
||||
-
|
||||
+ global_free(global);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
+ global_free(global);
|
||||
if (parent)
|
||||
return (parent);
|
||||
else
|
||||
@@ -2102,7 +2107,7 @@ error:
|
||||
mxmlDelete(first);
|
||||
|
||||
free(buffer);
|
||||
-
|
||||
+ global_free(global);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
diff --git a/mxml-private.c b/mxml-private.c
|
||||
index 4378ca3..ea6e452 100644
|
||||
--- a/mxml-private.c
|
||||
+++ b/mxml-private.c
|
||||
@@ -41,6 +41,32 @@
|
||||
* This code currently supports AIX, HP-UX, Linux, Mac OS X, Solaris, and
|
||||
* Windows. It might work on the BSDs and IRIX, but I haven't tested that.
|
||||
*/
|
||||
+void *global_mem[16] = {0};
|
||||
+
|
||||
+static void *global_calloc(int x, int size)
|
||||
+{
|
||||
+ int i;
|
||||
+ void *m = calloc(x, size);
|
||||
+ for (i = ((sizeof(global_mem)/sizeof(global_mem[0])) - 1); i > 0; i--) {
|
||||
+ global_mem[i] = global_mem[i-1];
|
||||
+ }
|
||||
+ global_mem[0] = m;
|
||||
+ return m;
|
||||
+}
|
||||
+
|
||||
+void global_free(void *m)
|
||||
+{
|
||||
+ int i;
|
||||
+ if (m == NULL)
|
||||
+ return;
|
||||
+ for (i = ((sizeof(global_mem)/sizeof(global_mem[0])) - 1); i >= 0; i--) {
|
||||
+ if (global_mem[i] == m) {
|
||||
+ global_mem[i] = NULL;
|
||||
+ free(m);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
|
||||
#if defined(__sun) || defined(_AIX)
|
||||
# pragma fini(_mxml_fini)
|
||||
@@ -148,7 +174,6 @@ mxml_real_cb(mxml_node_t *node) /* I - Current node */
|
||||
return (MXML_REAL);
|
||||
}
|
||||
|
||||
-
|
||||
#ifdef HAVE_PTHREAD_H /**** POSIX threading ****/
|
||||
# include <pthread.h>
|
||||
|
||||
@@ -190,7 +215,6 @@ _MXML_FINI(void)
|
||||
}
|
||||
}
|
||||
|
||||
-
|
||||
/*
|
||||
* '_mxml_global()' - Get global data.
|
||||
*/
|
||||
@@ -205,7 +229,7 @@ _mxml_global(void)
|
||||
|
||||
if ((global = (_mxml_global_t *)pthread_getspecific(_mxml_key)) == NULL)
|
||||
{
|
||||
- global = (_mxml_global_t *)calloc(1, sizeof(_mxml_global_t));
|
||||
+ global = (_mxml_global_t *)global_calloc(1, sizeof(_mxml_global_t));
|
||||
pthread_setspecific(_mxml_key, global);
|
||||
|
||||
global->num_entity_cbs = 1;
|
||||
@@ -288,7 +312,7 @@ _mxml_global(void)
|
||||
|
||||
if ((global = (_mxml_global_t *)TlsGetValue(_mxml_tls_index)) == NULL)
|
||||
{
|
||||
- global = (_mxml_global_t *)calloc(1, sizeof(_mxml_global_t));
|
||||
+ global = (_mxml_global_t *)global_calloc(1, sizeof(_mxml_global_t));
|
||||
|
||||
global->num_entity_cbs = 1;
|
||||
global->entity_cbs[0] = _mxml_entity_cb;
|
||||
diff --git a/mxml-private.h b/mxml-private.h
|
||||
index c591208..72ed338 100644
|
||||
--- a/mxml-private.h
|
||||
+++ b/mxml-private.h
|
||||
@@ -43,3 +43,4 @@ typedef struct _mxml_global_s
|
||||
extern _mxml_global_t *_mxml_global(void);
|
||||
extern int _mxml_entity_cb(const char *name);
|
||||
|
||||
+extern void global_free(void *m);
|
||||
@@ -8,12 +8,14 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=0.2
|
||||
PKG_VERSION:=0.3
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/libpicoevent.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=7875222706cb6999af0361ef0aebdc85cd75c127
|
||||
PKG_SOURCE_VERSION:=f446f186102539cceedaa15a95a33547ac3c1fd7
|
||||
PKG_NAME:=libpicoevent
|
||||
|
||||
PKG_LICENSE:=LGPL-2.1-only
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
|
||||
|
||||
33
librpc/Makefile
Normal file
33
librpc/Makefile
Normal file
@@ -0,0 +1,33 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=librpc
|
||||
PKG_RELEASE=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL=$(LEDE_GIT)/project/librpc-uclibc.git
|
||||
PKG_SOURCE_DATE:=2015-11-04
|
||||
PKG_SOURCE_VERSION:=a921e3ded051746f9f7cd5e5a312fb6771716aac
|
||||
PKG_MIRROR_HASH:=22c8dc55e1c4e8e31635a37708a3ce622a6ca33ebd918a4321b0be6ffce89b21
|
||||
CMAKE_INSTALL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
|
||||
PKG_LICENSE:=LGPL-2.1
|
||||
PKG_LICENSE_FILES:=
|
||||
|
||||
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
|
||||
define Package/librpc
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=uClibc RPC library
|
||||
endef
|
||||
|
||||
define Package/librpc/install
|
||||
$(INSTALL_DIR) $(1)/lib/
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/librpc.so $(1)/lib/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,librpc))
|
||||
@@ -18,9 +18,10 @@ PKG_LICENSE_FILES:=COPYING
|
||||
PKG_INSTALL:=1
|
||||
PKG_FIXUP:=autoreconf
|
||||
|
||||
include $(INCLUDE_DIR)/uclibc++.mk
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
CXX_DEPENDS:=libstdcpp
|
||||
|
||||
define Package/libtrace/Default
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
@@ -33,7 +34,7 @@ define Package/libtrace
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=Libtrace library for packet trace processing
|
||||
URL:=http://research.wand.net.nz/software/libtrace.php
|
||||
DEPENDS:=+libpcap +libpthread +zlib +libbz2 +liblzo +librt $(CXX_DEPENDS)
|
||||
DEPENDS:=+libpcap +libpthread +zlib +libbz2 +liblzo +librt +liblzma +$(CXX_DEPENDS)
|
||||
endef
|
||||
|
||||
define Package/libtrace/description
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
# $Id$
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=logrotate
|
||||
PKG_VERSION:=3.7.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz
|
||||
PKG_SOURCE_URL:=http://ftp.de.debian.org/debian/pool/main/l/logrotate
|
||||
PKG_MD5SUM:=552639142e163745f6bcd4f1f3816d8a
|
||||
PKG_CAT:=zcat
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_LICENSE:=GPLv2
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/logrotate
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
DEPENDS:=+libpopt
|
||||
TITLE:=rotates, compresses, and mails system logs
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(call Build/Compile/Default, \
|
||||
RPM_OPT_FLAGS="$(TARGET_CFLAGS) $(EXTRA_CPPFLAGS)" \
|
||||
LDFLAGS="$(EXTRA_LDFLAGS)" \
|
||||
logrotate \
|
||||
)
|
||||
endef
|
||||
|
||||
define Package/logrotate/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(CP) ${PKG_BUILD_DIR}/logrotate $(1)/usr/sbin/
|
||||
$(INSTALL_DIR) $(1)/etc
|
||||
$(CP) ./files/logrotate.conf $(1)/etc/
|
||||
$(INSTALL_DIR) $(1)/etc/logrotate.d
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,logrotate))
|
||||
@@ -1,30 +0,0 @@
|
||||
# rotate log files weekly
|
||||
weekly
|
||||
#daily
|
||||
|
||||
# keep 4 weeks worth of backlogs
|
||||
rotate 4
|
||||
|
||||
# create new (empty) log files after rotating old ones
|
||||
create
|
||||
|
||||
notifempty
|
||||
nomail
|
||||
#olddir /var/log/backup/
|
||||
missingok
|
||||
#dateext
|
||||
|
||||
# uncomment this if you want your log files compressed
|
||||
#compress
|
||||
|
||||
# packages can drop log rotation information into this directory
|
||||
include /etc/logrotate.d
|
||||
|
||||
# no packages own lastlog or wtmp -- we'll rotate them here
|
||||
#/var/log/wtmp {
|
||||
# monthly
|
||||
# create 0664 root utmp
|
||||
# rotate 1
|
||||
#}
|
||||
|
||||
# system-specific logs may be also be configured here.
|
||||
@@ -1,433 +0,0 @@
|
||||
diff -u -ruN logrotate-3.7.1.orig/config.c logrotate-3.7.1/config.c
|
||||
--- logrotate-3.7.1.orig/config.c 2003-08-07 07:13:14.000000000 -0400
|
||||
+++ logrotate-3.7.1/config.c 2005-05-24 12:21:09.000000000 -0400
|
||||
@@ -511,6 +511,14 @@
|
||||
newlog->flags &= ~LOG_FLAG_IFEMPTY;
|
||||
|
||||
*endtag = oldchar, start = endtag;
|
||||
+ } else if (!strcmp(start, "dateext")) {
|
||||
+ newlog->flags |= LOG_FLAG_DATEEXT;
|
||||
+
|
||||
+ *endtag = oldchar, start = endtag;
|
||||
+ } else if (!strcmp(start, "nodateext")) {
|
||||
+ newlog->flags &= ~LOG_FLAG_DATEEXT;
|
||||
+
|
||||
+ *endtag = oldchar, start = endtag;
|
||||
} else if (!strcmp(start, "noolddir")) {
|
||||
newlog->oldDir = NULL;
|
||||
|
||||
@@ -670,6 +678,21 @@
|
||||
}
|
||||
*endtag = oldchar, start = endtag;
|
||||
}
|
||||
+ } else if (!strcmp(start, "maxage")) {
|
||||
+ *endtag = oldchar, start = endtag;
|
||||
+
|
||||
+ if (!isolateValue(configFile, lineNum, "maxage count", &start,
|
||||
+ &endtag)) {
|
||||
+ oldchar = *endtag, *endtag = '\0';
|
||||
+
|
||||
+ newlog->rotateAge = strtoul(start, &chptr, 0);
|
||||
+ if (*chptr || newlog->rotateAge < 0) {
|
||||
+ message(MESS_ERROR, "%s:%d bad maximum age '%s'\n",
|
||||
+ configFile, lineNum, start);
|
||||
+ return 1;
|
||||
+ }
|
||||
+ *endtag = oldchar, start = endtag;
|
||||
+ }
|
||||
} else if (!strcmp(start, "errors")) {
|
||||
message(MESS_DEBUG, "%s: %d: the errors directive is deprecated and no longer used.\n",
|
||||
configFile, lineNum);
|
||||
diff -u -ruN logrotate-3.7.1.orig/logrotate.8 logrotate-3.7.1/logrotate.8
|
||||
--- logrotate-3.7.1.orig/logrotate.8 2003-08-07 07:13:14.000000000 -0400
|
||||
+++ logrotate-3.7.1/logrotate.8 2005-05-24 12:21:09.000000000 -0400
|
||||
@@ -200,6 +200,11 @@
|
||||
Log files are rotated every day.
|
||||
|
||||
.TP
|
||||
+\fBdateext\fR
|
||||
+Archive old versions of log files adding a daily extension like YYYYMMDD
|
||||
+instead of simply adding a number.
|
||||
+
|
||||
+.TP
|
||||
\fBdelaycompress\fR
|
||||
Postpone compression of the previous log file to the next rotation cycle.
|
||||
This has only effect when used in combination with \fBcompress\fR.
|
||||
@@ -246,6 +251,12 @@
|
||||
instead of the just-rotated file (this is the default).
|
||||
|
||||
.TP
|
||||
+\fBmaxage\fR \fIcount\fR
|
||||
+Remove rotated logs older than <count> days. The age is only checked
|
||||
+if the logfile is to be rotated. The files are mailed to the
|
||||
+configured address if \fBmaillast\fR and \fBmail\fR are configured.
|
||||
+
|
||||
+.TP
|
||||
\fBmissingok\fR
|
||||
If the log file is missing, go on to the next one without issuing an error
|
||||
message. See also \fBnomissingok\fR.
|
||||
diff -u -ruN logrotate-3.7.1.orig/logrotate.c logrotate-3.7.1/logrotate.c
|
||||
--- logrotate-3.7.1.orig/logrotate.c 2004-10-19 17:41:24.000000000 -0400
|
||||
+++ logrotate-3.7.1/logrotate.c 2005-05-24 12:21:09.000000000 -0400
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <sys/wait.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
+#include <glob.h>
|
||||
|
||||
#ifdef WITH_SELINUX
|
||||
#include <selinux/selinux.h>
|
||||
@@ -22,6 +23,10 @@
|
||||
#include "log.h"
|
||||
#include "logrotate.h"
|
||||
|
||||
+#if !defined(GLOB_ABORTED) && defined(GLOB_ABEND)
|
||||
+#define GLOB_ABORTED GLOB_ABEND
|
||||
+#endif
|
||||
+
|
||||
typedef struct {
|
||||
char * fn;
|
||||
struct tm lastRotated; /* only tm.mon, tm_mday, tm_year are good! */
|
||||
@@ -42,6 +47,14 @@
|
||||
char * mailCommand = DEFAULT_MAIL_COMMAND;
|
||||
time_t nowSecs = 0;
|
||||
|
||||
+static int globerr(const char * pathname, int theerr) {
|
||||
+ message(MESS_ERROR, "error accessing %s: %s\n", pathname,
|
||||
+ strerror(theerr));
|
||||
+
|
||||
+ /* We want the glob operation to continue, so return 0 */
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
static logState * findState(const char * fn, struct stateSet * sip) {
|
||||
int i;
|
||||
logState * states = sip->states;
|
||||
@@ -49,9 +62,11 @@
|
||||
struct tm now = *localtime(&nowSecs);
|
||||
time_t lr_time;
|
||||
|
||||
+ /* find the filename fn in the statesPtr list */
|
||||
for (i = 0; i < numStates; i++)
|
||||
if (!strcmp(fn, states[i].fn)) break;
|
||||
|
||||
+ /* not in statesPtr list, so add new entry */
|
||||
if (i == numStates) {
|
||||
i = numStates++;
|
||||
states = realloc(states, sizeof(*states) * numStates);
|
||||
@@ -121,6 +136,17 @@
|
||||
return rc;
|
||||
}
|
||||
|
||||
+static int removeLogFile(char * name) {
|
||||
+ message(MESS_DEBUG, "removing old log %s\n", name);
|
||||
+
|
||||
+ if (!debug && unlink(name)) {
|
||||
+ message(MESS_ERROR, "Failed to remove old log %s: %s\n",
|
||||
+ name, strerror(errno));
|
||||
+ return 1;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int compressLogFile(char * name, logInfo * log, struct stat *sb) {
|
||||
char * compressedName;
|
||||
const char ** fullCommand;
|
||||
@@ -265,6 +291,25 @@
|
||||
return rc;
|
||||
}
|
||||
|
||||
+static int mailLogWrapper (char * mailFilename, char * mailCommand, int logNum, logInfo * log) {
|
||||
+ /* if the log is compressed (and we're not mailing a
|
||||
+ * file whose compression has been delayed), we need
|
||||
+ * to uncompress it */
|
||||
+ if ((log->flags & LOG_FLAG_COMPRESS) &&
|
||||
+ !((log->flags & LOG_FLAG_DELAYCOMPRESS) &&
|
||||
+ (log->flags & LOG_FLAG_MAILFIRST))) {
|
||||
+ if (mailLog(mailFilename, mailCommand,
|
||||
+ log->uncompress_prog, log->logAddress,
|
||||
+ log->files[logNum]))
|
||||
+ return 1;
|
||||
+ } else {
|
||||
+ if (mailLog(mailFilename, mailCommand, NULL,
|
||||
+ log->logAddress, mailFilename))
|
||||
+ return 1;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int copyTruncate(char * currLog, char * saveLog, struct stat * sb, int flags) {
|
||||
char buf[BUFSIZ];
|
||||
int fdcurr = -1, fdsave = -1;
|
||||
@@ -479,6 +524,9 @@
|
||||
char * baseName;
|
||||
char * dirName;
|
||||
char * firstRotated;
|
||||
+ char * glob_pattern;
|
||||
+ glob_t globResult;
|
||||
+ int rc;
|
||||
size_t alloc_size;
|
||||
int rotateCount = log->rotateCount ? log->rotateCount : 1;
|
||||
int logStart = (log->logStart == -1) ? 1 : log->logStart;
|
||||
@@ -509,7 +557,7 @@
|
||||
|
||||
alloc_size = strlen(dirName) + strlen(baseName) +
|
||||
strlen(log->files[logNum]) + strlen(fileext) +
|
||||
- strlen(compext) + 10;
|
||||
+ strlen(compext) + 18;
|
||||
|
||||
oldName = alloca(alloc_size);
|
||||
newName = alloca(alloc_size);
|
||||
@@ -531,16 +579,116 @@
|
||||
/* First compress the previous log when necessary */
|
||||
if (log->flags & LOG_FLAG_COMPRESS &&
|
||||
log->flags & LOG_FLAG_DELAYCOMPRESS) {
|
||||
- struct stat sbprev;
|
||||
-
|
||||
- sprintf(oldName, "%s/%s.%d%s", dirName, baseName, logStart, fileext);
|
||||
- if (stat(oldName, &sbprev)) {
|
||||
- message(MESS_DEBUG, "previous log %s does not exist\n",
|
||||
- oldName);
|
||||
- } else {
|
||||
- hasErrors = compressLogFile(oldName, log, &sbprev);
|
||||
+ if (log->flags & LOG_FLAG_DATEEXT) {
|
||||
+ /* glob for uncompressed files with our pattern */
|
||||
+ glob_pattern = malloc(strlen(dirName) + strlen(baseName)
|
||||
+ + strlen(fileext) + 44 );
|
||||
+ sprintf(glob_pattern,
|
||||
+ "%s/%s-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]%s",
|
||||
+ dirName, baseName, fileext);
|
||||
+ rc = glob(glob_pattern, 0, globerr, &globResult);
|
||||
+ if (!rc && globResult.gl_pathc > 0) {
|
||||
+ for (i = 0; i < globResult.gl_pathc && !hasErrors; i++) {
|
||||
+ struct stat sbprev;
|
||||
+ sprintf(oldName,"%s",(globResult.gl_pathv)[i]);
|
||||
+ if (stat(oldName, &sbprev)) {
|
||||
+ message(MESS_DEBUG, "previous log %s does not exist\n", oldName);
|
||||
+ } else {
|
||||
+ hasErrors = compressLogFile(oldName, log, &sbprev);
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ message (MESS_DEBUG, "glob finding logs to compress failed\n");
|
||||
+ /* fallback to old behaviour */
|
||||
+ sprintf(oldName, "%s/%s.%d%s", dirName, baseName, logStart, fileext);
|
||||
+ }
|
||||
+ globfree(&globResult);
|
||||
+ free(glob_pattern);
|
||||
+ } else {
|
||||
+ struct stat sbprev;
|
||||
+
|
||||
+ sprintf(oldName, "%s/%s.%d%s", dirName, baseName, logStart, fileext);
|
||||
+ if (stat(oldName, &sbprev)) {
|
||||
+ message(MESS_DEBUG, "previous log %s does not exist\n",
|
||||
+ oldName);
|
||||
+ } else {
|
||||
+ hasErrors = compressLogFile(oldName, log, &sbprev);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
+
|
||||
+ firstRotated = alloca(strlen(dirName) + strlen(baseName) +
|
||||
+ strlen(fileext) + strlen(compext) + 30);
|
||||
+
|
||||
+ if(log->flags & LOG_FLAG_DATEEXT) {
|
||||
+ /* glob for compressed files with our pattern
|
||||
+ * and compress ext */
|
||||
+ glob_pattern = malloc(strlen(dirName)+strlen(baseName)
|
||||
+ +strlen(fileext)+strlen(compext)+44);
|
||||
+ sprintf(glob_pattern,
|
||||
+ "%s/%s-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]%s%s",
|
||||
+ dirName, baseName, fileext, compext);
|
||||
+ rc = glob(glob_pattern, 0, globerr, &globResult);
|
||||
+ if (!rc) {
|
||||
+ /* search for files to drop, if we find one remember it,
|
||||
+ * if we find another one mail and remove the first and
|
||||
+ * remember the second and so on */
|
||||
+ struct stat fst_buf;
|
||||
+ int mail_out = -1;
|
||||
+ /* remove the first (n - rotateCount) matches
|
||||
+ * no real rotation needed, since the files have
|
||||
+ * the date in their name */
|
||||
+ for (i = 0; i < globResult.gl_pathc; i++) {
|
||||
+ if( !stat((globResult.gl_pathv)[i],&fst_buf) ) {
|
||||
+ if ((i <= ((int)globResult.gl_pathc - rotateCount))
|
||||
+ || ((log->rotateAge > 0)
|
||||
+ && (((nowSecs - fst_buf.st_mtime)/60/60/24)
|
||||
+ > log->rotateAge))) {
|
||||
+ if ( mail_out != -1 ) {
|
||||
+ if (!hasErrors && log->logAddress) {
|
||||
+ char * mailFilename = (globResult.gl_pathv)[mail_out];
|
||||
+ hasErrors = mailLogWrapper(mailFilename, mailCommand, logNum, log);
|
||||
+ if (!hasErrors)
|
||||
+ hasErrors = removeLogFile(mailFilename);
|
||||
+ }
|
||||
+ }
|
||||
+ mail_out = i;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if ( mail_out != -1 ) {
|
||||
+ /* oldName is oldest Backup found (for unlink later) */
|
||||
+ sprintf(oldName, "%s", (globResult.gl_pathv)[mail_out]);
|
||||
+ strcpy(disposeName, oldName);
|
||||
+ } else
|
||||
+ disposeName = NULL;
|
||||
+ } else {
|
||||
+ message (MESS_DEBUG, "glob finding old rotated logs failed\n");
|
||||
+ disposeName = NULL;
|
||||
+ }
|
||||
+ /* firstRotated is most recently created/compressed rotated log */
|
||||
+ sprintf(firstRotated, "%s/%s-%04d%02d%02d%s%s",
|
||||
+ dirName, baseName, now.tm_year+1900,
|
||||
+ now.tm_mon+1, now.tm_mday, fileext, compext);
|
||||
+ globfree(&globResult);
|
||||
+ free(glob_pattern);
|
||||
+ } else {
|
||||
+ if ( log->rotateAge ) {
|
||||
+ struct stat fst_buf;
|
||||
+ for (i=1; i <= rotateCount; i++) {
|
||||
+ sprintf(oldName, "%s/%s.%d%s%s", dirName, baseName,
|
||||
+ rotateCount + 1, fileext, compext);
|
||||
+ if(!stat(oldName,&fst_buf)
|
||||
+ && (((nowSecs - fst_buf.st_mtime)/60/60/24)
|
||||
+ > log->rotateAge)) {
|
||||
+ char * mailFilename = (globResult.gl_pathv)[i];
|
||||
+ if (!hasErrors && log->logAddress)
|
||||
+ hasErrors = mailLogWrapper(mailFilename, mailCommand, logNum, log);
|
||||
+ if (!hasErrors)
|
||||
+ hasErrors = removeLogFile(mailFilename);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
sprintf(oldName, "%s/%s.%d%s%s", dirName, baseName,
|
||||
logStart + rotateCount, fileext, compext);
|
||||
@@ -548,8 +696,6 @@
|
||||
|
||||
strcpy(disposeName, oldName);
|
||||
|
||||
- firstRotated = alloca(strlen(dirName) + strlen(baseName) +
|
||||
- strlen(fileext) + strlen(compext) + 30);
|
||||
sprintf(firstRotated, "%s/%s.%d%s%s", dirName, baseName,
|
||||
logStart, fileext,
|
||||
(log->flags & LOG_FLAG_DELAYCOMPRESS) ? "" : compext);
|
||||
@@ -600,12 +746,27 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
-
|
||||
+ } /* !LOG_FLAG_DATEEXT */
|
||||
+
|
||||
finalName = oldName;
|
||||
-
|
||||
- /* note: the gzip extension is *not* used here! */
|
||||
- sprintf(finalName, "%s/%s.%d%s", dirName, baseName, logStart, fileext);
|
||||
-
|
||||
+
|
||||
+ if(log->flags & LOG_FLAG_DATEEXT) {
|
||||
+ char * destFile = alloca(strlen(dirName) + strlen(baseName) +
|
||||
+ strlen(fileext) + strlen(compext) + 30);
|
||||
+ struct stat fst_buf;
|
||||
+ sprintf(finalName, "%s/%s-%04d%02d%02d%s",
|
||||
+ dirName, baseName, now.tm_year+1900,
|
||||
+ now.tm_mon+1, now.tm_mday, fileext);
|
||||
+ sprintf(destFile, "%s%s", finalName, compext);
|
||||
+ if(!stat(destFile,&fst_buf)) {
|
||||
+ message (MESS_DEBUG, "destination %s already exists, skipping rotation\n", firstRotated);
|
||||
+ hasErrors = 1;
|
||||
+ }
|
||||
+ } else {
|
||||
+ /* note: the gzip extension is *not* used here! */
|
||||
+ sprintf(finalName, "%s/%s.%d%s", dirName, baseName, logStart, fileext);
|
||||
+ }
|
||||
+
|
||||
/* if the last rotation doesn't exist, that's okay */
|
||||
if (!debug && access(disposeName, F_OK)) {
|
||||
message(MESS_DEBUG, "log %s doesn't exist -- won't try to "
|
||||
@@ -613,9 +774,6 @@
|
||||
disposeName = NULL;
|
||||
}
|
||||
|
||||
- free(dirName);
|
||||
- free(baseName);
|
||||
-
|
||||
if (!hasErrors) {
|
||||
if (log->pre && !(log->flags & LOG_FLAG_SHAREDSCRIPTS)) {
|
||||
message(MESS_DEBUG, "running prerotate script\n");
|
||||
@@ -722,33 +880,12 @@
|
||||
else
|
||||
mailFilename = disposeName;
|
||||
|
||||
- if (mailFilename) {
|
||||
- /* if the log is compressed (and we're not mailing a
|
||||
- file whose compression has been delayed), we need
|
||||
- to uncompress it */
|
||||
- if ((log->flags & LOG_FLAG_COMPRESS) &&
|
||||
- !((log->flags & LOG_FLAG_DELAYCOMPRESS) &&
|
||||
- (log->flags & LOG_FLAG_MAILFIRST))) {
|
||||
- if (mailLog(mailFilename, mailCommand,
|
||||
- log->uncompress_prog, log->logAddress,
|
||||
- log->files[logNum]))
|
||||
- hasErrors = 1;
|
||||
- } else {
|
||||
- if (mailLog(mailFilename, mailCommand, NULL,
|
||||
- log->logAddress, mailFilename))
|
||||
- hasErrors = 1;
|
||||
- }
|
||||
- }
|
||||
+ if (mailFilename)
|
||||
+ hasErrors = mailLogWrapper(mailFilename, mailCommand, logNum, log);
|
||||
}
|
||||
|
||||
if (!hasErrors && disposeName) {
|
||||
- message(MESS_DEBUG, "removing old log %s\n", disposeName);
|
||||
-
|
||||
- if (!debug && unlink(disposeName)) {
|
||||
- message(MESS_ERROR, "Failed to remove old log %s: %s\n",
|
||||
- disposeName, strerror(errno));
|
||||
- hasErrors = 1;
|
||||
- }
|
||||
+ hasErrors = removeLogFile(disposeName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -761,6 +898,8 @@
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+ free(dirName);
|
||||
+ free(baseName);
|
||||
return hasErrors;
|
||||
}
|
||||
|
||||
@@ -1047,7 +1186,9 @@
|
||||
|
||||
int main(int argc, const char ** argv) {
|
||||
logInfo defConfig = { NULL, NULL, 0, NULL, ROT_SIZE,
|
||||
- /* threshHold */ 1024 * 1024, 0,
|
||||
+ /* threshHold */ 1024 * 1024,
|
||||
+ /* rotateCount */ 0,
|
||||
+ /* rotateAge */ 0,
|
||||
/* log start */ -1,
|
||||
/* pre, post */ NULL, NULL,
|
||||
/* first, last */ NULL, NULL,
|
||||
diff -u -ruN logrotate-3.7.1.orig/logrotate.h logrotate-3.7.1/logrotate.h
|
||||
--- logrotate-3.7.1.orig/logrotate.h 2003-08-07 07:13:14.000000000 -0400
|
||||
+++ logrotate-3.7.1/logrotate.h 2005-05-24 12:21:09.000000000 -0400
|
||||
@@ -15,6 +15,7 @@
|
||||
#define LOG_FLAG_MAILFIRST (1 << 6)
|
||||
#define LOG_FLAG_SHAREDSCRIPTS (1 << 7)
|
||||
#define LOG_FLAG_COPY (1 << 8)
|
||||
+#define LOG_FLAG_DATEEXT (1 << 9)
|
||||
|
||||
#define NO_FORCE_ROTATE 0
|
||||
#define FORCE_ROTATE 1
|
||||
@@ -34,6 +35,7 @@
|
||||
enum { ROT_DAYS, ROT_WEEKLY, ROT_MONTHLY, ROT_SIZE, ROT_FORCE } criterium;
|
||||
unsigned int threshhold;
|
||||
int rotateCount;
|
||||
+ int rotateAge;
|
||||
int logStart;
|
||||
char * pre, * post, * first, * last;
|
||||
char * logAddress;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user