]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/other/rscript/rscript.cpp
Do not use pthread_kill to stop a thread
[stg.git] / projects / stargazer / plugins / other / rscript / rscript.cpp
1 /*
2  *    This program is free software; you can redistribute it and/or modify
3  *    it under the terms of the GNU General Public License as published by
4  *    the Free Software Foundation; either version 2 of the License, or
5  *    (at your option) any later version.
6  *
7  *    This program is distributed in the hope that it will be useful,
8  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  *    GNU General Public License for more details.
11  *
12  *    You should have received a copy of the GNU General Public License
13  *    along with this program; if not, write to the Free Software
14  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15  */
16
17 /*
18  *    Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
19  *    Author : Maxim Mamontov <faust@stargazer.dp.ua>
20  */
21
22 /*
23  $Revision: 1.33 $
24  $Date: 2010/04/16 12:30:37 $
25  $Author: faust $
26 */
27
28 #include <sys/time.h>
29
30 #include <csignal>
31 #include <cassert>
32 #include <cstdlib>
33 #include <algorithm>
34
35 #include "stg/common.h"
36 #include "stg/locker.h"
37 #include "stg/user_property.h"
38 #include "stg/plugin_creator.h"
39 #include "rscript.h"
40 #include "ur_functor.h"
41 #include "send_functor.h"
42
43 extern volatile const time_t stgTime;
44
45 #define RS_MAX_ROUTERS  (100)
46
47 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
49 //-----------------------------------------------------------------------------
50 PLUGIN_CREATOR<REMOTE_SCRIPT> rsc;
51 //-----------------------------------------------------------------------------
52 //-----------------------------------------------------------------------------
53 //-----------------------------------------------------------------------------
54 PLUGIN * GetPlugin()
55 {
56 return rsc.GetPlugin();
57 }
58 //-----------------------------------------------------------------------------
59 //-----------------------------------------------------------------------------
60 //-----------------------------------------------------------------------------
61 RS_USER & RS_USER::operator=(const RS_USER & rvalue)
62 {
63 lastSentTime = rvalue.lastSentTime;
64 user = rvalue.user;
65 routers = rvalue.routers;
66 shortPacketsCount = rvalue.shortPacketsCount;
67 return *this;
68 }
69 //-----------------------------------------------------------------------------
70 RS_SETTINGS::RS_SETTINGS()
71     : sendPeriod(0),
72       port(0),
73       errorStr(),
74       netRouters(),
75       userParams(),
76       password(),
77       subnetFile()
78 {
79 }
80 //-----------------------------------------------------------------------------
81 int RS_SETTINGS::ParseSettings(const MODULE_SETTINGS & s)
82 {
83 int p;
84 PARAM_VALUE pv;
85 vector<PARAM_VALUE>::const_iterator pvi;
86 netRouters.clear();
87 ///////////////////////////
88 pv.param = "Port";
89 pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
90 if (pvi == s.moduleParams.end())
91     {
92     errorStr = "Parameter \'Port\' not found.";
93     printfd(__FILE__, "Parameter 'Port' not found\n");
94     return -1;
95     }
96 if (ParseIntInRange(pvi->value[0], 2, 65535, &p))
97     {
98     errorStr = "Cannot parse parameter \'Port\': " + errorStr;
99     printfd(__FILE__, "Cannot parse parameter 'Port'\n");
100     return -1;
101     }
102 port = p;
103 ///////////////////////////
104 pv.param = "SendPeriod";
105 pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
106 if (pvi == s.moduleParams.end())
107     {
108     errorStr = "Parameter \'SendPeriod\' not found.";
109     printfd(__FILE__, "Parameter 'SendPeriod' not found\n");
110     return -1;
111     }
112
113 if (ParseIntInRange(pvi->value[0], 5, 600, &sendPeriod))
114     {
115     errorStr = "Cannot parse parameter \'SendPeriod\': " + errorStr;
116     printfd(__FILE__, "Cannot parse parameter 'SendPeriod'\n");
117     return -1;
118     }
119 ///////////////////////////
120 pv.param = "UserParams";
121 pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
122 if (pvi == s.moduleParams.end())
123     {
124     errorStr = "Parameter \'UserParams\' not found.";
125     printfd(__FILE__, "Parameter 'UserParams' not found\n");
126     return -1;
127     }
128 userParams = pvi->value;
129 ///////////////////////////
130 pv.param = "Password";
131 pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
132 if (pvi == s.moduleParams.end())
133     {
134     errorStr = "Parameter \'Password\' not found.";
135     printfd(__FILE__, "Parameter 'Password' not found\n");
136     return -1;
137     }
138 password = pvi->value[0];
139 ///////////////////////////
140 pv.param = "SubnetFile";
141 pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
142 if (pvi == s.moduleParams.end())
143     {
144     errorStr = "Parameter \'SubnetFile\' not found.";
145     printfd(__FILE__, "Parameter 'SubnetFile' not found\n");
146     return -1;
147     }
148 subnetFile = pvi->value[0];
149
150 NRMapParser nrMapParser;
151
152 if (nrMapParser.ReadFile(subnetFile))
153     {
154     errorStr = nrMapParser.GetErrorStr();
155     return -1;
156     }
157
158 netRouters = nrMapParser.GetMap();
159
160 if (netRouters.empty())
161     {
162     errorStr = "Parameter(s) \'Subnet*\' not found.";
163     printfd(__FILE__, "Parameter(s) 'Subnet*' not found\n");
164     return -1;
165     }
166
167 return 0;
168 }
169 //-----------------------------------------------------------------------------
170 //-----------------------------------------------------------------------------
171 //-----------------------------------------------------------------------------
172 REMOTE_SCRIPT::REMOTE_SCRIPT()
173     : ctx(),
174       afterChgIPNotifierList(),
175       authorizedUsers(),
176       errorStr(),
177       rsSettings(),
178       settings(),
179       sendPeriod(15),
180       halfPeriod(8),
181       nonstop(false),
182       isRunning(false),
183       users(NULL),
184       netRouters(),
185       thread(),
186       mutex(),
187       sock(0),
188       onAddUserNotifier(*this),
189       onDelUserNotifier(*this)
190 {
191 pthread_mutex_init(&mutex, NULL);
192 }
193 //-----------------------------------------------------------------------------
194 REMOTE_SCRIPT::~REMOTE_SCRIPT()
195 {
196 pthread_mutex_destroy(&mutex);
197 }
198 //-----------------------------------------------------------------------------
199 void * REMOTE_SCRIPT::Run(void * d)
200 {
201 sigset_t signalSet;
202 sigfillset(&signalSet);
203 pthread_sigmask(SIG_BLOCK, &signalSet, NULL);
204
205 REMOTE_SCRIPT * rs = static_cast<REMOTE_SCRIPT *>(d);
206
207 rs->isRunning = true;
208
209 while (rs->nonstop)
210     {
211     rs->PeriodicSend();
212     sleep(2);
213     }
214
215 rs->isRunning = false;
216 return NULL;
217 }
218 //-----------------------------------------------------------------------------
219 int REMOTE_SCRIPT::ParseSettings()
220 {
221 int ret = rsSettings.ParseSettings(settings);
222 if (ret)
223     errorStr = rsSettings.GetStrError();
224
225 sendPeriod = rsSettings.GetSendPeriod();
226 halfPeriod = sendPeriod / 2;
227
228 return ret;
229 }
230 //-----------------------------------------------------------------------------
231 int REMOTE_SCRIPT::Start()
232 {
233 netRouters = rsSettings.GetSubnetsMap();
234
235 InitEncrypt(&ctx, rsSettings.GetPassword());
236
237 //onAddUserNotifier.SetRemoteScript(this);
238 //onDelUserNotifier.SetRemoteScript(this);
239
240 users->AddNotifierUserAdd(&onAddUserNotifier);
241 users->AddNotifierUserDel(&onDelUserNotifier);
242
243 nonstop = true;
244
245 if (GetUsers())
246     {
247     return -1;
248     }
249
250 if (PrepareNet())
251     {
252     return -1;
253     }
254
255 if (!isRunning)
256     {
257     if (pthread_create(&thread, NULL, Run, this))
258         {
259         errorStr = "Cannot create thread.";
260         printfd(__FILE__, "Cannot create thread\n");
261         return -1;
262         }
263     }
264
265 errorStr = "";
266 return 0;
267 }
268 //-----------------------------------------------------------------------------
269 int REMOTE_SCRIPT::Stop()
270 {
271 if (!IsRunning())
272     return 0;
273
274 nonstop = false;
275
276 std::for_each(
277         authorizedUsers.begin(),
278         authorizedUsers.end(),
279         DisconnectUser(*this)
280         );
281
282 FinalizeNet();
283
284 if (isRunning)
285     {
286     //5 seconds to thread stops itself
287     for (int i = 0; i < 25 && isRunning; i++)
288         {
289         struct timespec ts = {0, 200000000};
290         nanosleep(&ts, NULL);
291         }
292     }
293
294 users->DelNotifierUserDel(&onDelUserNotifier);
295 users->DelNotifierUserAdd(&onAddUserNotifier);
296
297 if (isRunning)
298     return -1;
299
300 return 0;
301 }
302 //-----------------------------------------------------------------------------
303 int REMOTE_SCRIPT::Reload()
304 {
305 NRMapParser nrMapParser;
306
307 if (nrMapParser.ReadFile(rsSettings.GetMapFileName()))
308     {
309     errorStr = nrMapParser.GetErrorStr();
310     return -1;
311     }
312
313     {
314     STG_LOCKER lock(&mutex, __FILE__, __LINE__);
315
316     printfd(__FILE__, "REMOTE_SCRIPT::Reload()\n");
317
318     netRouters = nrMapParser.GetMap();
319     }
320
321 std::for_each(authorizedUsers.begin(),
322               authorizedUsers.end(),
323               UpdateRouter(*this));
324
325 return 0;
326 }
327 //-----------------------------------------------------------------------------
328 bool REMOTE_SCRIPT::PrepareNet()
329 {
330 sock = socket(AF_INET, SOCK_DGRAM, 0);
331
332 if (sock < 0)
333     {
334     errorStr = "Cannot create socket.";
335     printfd(__FILE__, "Cannot create socket\n");
336     return true;
337     }
338
339 return false;
340 }
341 //-----------------------------------------------------------------------------
342 bool REMOTE_SCRIPT::FinalizeNet()
343 {
344 close(sock);
345 return false;
346 }
347 //-----------------------------------------------------------------------------
348 void REMOTE_SCRIPT::PeriodicSend()
349 {
350 STG_LOCKER lock(&mutex, __FILE__, __LINE__);
351
352 map<uint32_t, RS_USER>::iterator it(authorizedUsers.begin());
353 while (it != authorizedUsers.end())
354     {
355     if (difftime(stgTime, it->second.lastSentTime) - (rand() % halfPeriod) > sendPeriod)
356     //if (stgTime - it->second.lastSentTime > sendPeriod)
357         {
358         Send(it->first, it->second);
359         }
360     ++it;
361     }
362 }
363 //-----------------------------------------------------------------------------
364 #ifdef NDEBUG
365 bool REMOTE_SCRIPT::PreparePacket(char * buf, size_t, uint32_t ip, RS_USER & rsu, bool forceDisconnect) const
366 #else
367 bool REMOTE_SCRIPT::PreparePacket(char * buf, size_t bufSize, uint32_t ip, RS_USER & rsu, bool forceDisconnect) const
368 #endif
369 {
370 RS_PACKET_HEADER packetHead;
371
372 memset(packetHead.padding, 0, sizeof(packetHead.padding));
373 strcpy((char*)packetHead.magic, RS_ID);
374 packetHead.protoVer[0] = '0';
375 packetHead.protoVer[1] = '2';
376 if (forceDisconnect)
377     {
378     packetHead.packetType = RS_DISCONNECT_PACKET;
379     }
380 else
381     {
382     if (rsu.shortPacketsCount % MAX_SHORT_PCKT == 0)
383         {
384         //SendLong
385         packetHead.packetType = rsu.user->IsInetable() ? RS_CONNECT_PACKET : RS_DISCONNECT_PACKET;
386         }
387     else
388         {
389         //SendShort
390         packetHead.packetType = rsu.user->IsInetable() ? RS_ALIVE_PACKET : RS_DISCONNECT_PACKET;
391         }
392     }
393 rsu.shortPacketsCount++;
394 rsu.lastSentTime = stgTime;
395
396 packetHead.ip = htonl(ip);
397 packetHead.id = htonl(rsu.user->GetID());
398 strncpy((char*)packetHead.login, rsu.user->GetLogin().c_str(), RS_LOGIN_LEN);
399 packetHead.login[RS_LOGIN_LEN - 1] = 0;
400
401 memcpy(buf, &packetHead, sizeof(packetHead));
402
403 if (packetHead.packetType == RS_ALIVE_PACKET)
404     {
405     return false;
406     }
407
408 RS_PACKET_TAIL packetTail;
409
410 memset(packetTail.padding, 0, sizeof(packetTail.padding));
411 strcpy((char*)packetTail.magic, RS_ID);
412 vector<string>::const_iterator it;
413 std::string params;
414 for(it = rsSettings.GetUserParams().begin();
415     it != rsSettings.GetUserParams().end();
416     ++it)
417     {
418     std::string parameter(GetUserParam(rsu.user, *it));
419     if (params.length() + parameter.length() > RS_PARAMS_LEN - 1)
420         break;
421     params += parameter + " ";
422     }
423 strncpy((char *)packetTail.params, params.c_str(), RS_PARAMS_LEN);
424 packetTail.params[RS_PARAMS_LEN - 1] = 0;
425
426 assert(sizeof(packetHead) + sizeof(packetTail) <= bufSize && "Insufficient buffer space");
427
428 Encrypt(&ctx, buf + sizeof(packetHead), (char *)&packetTail, sizeof(packetTail) / 8);
429
430 return false;
431 }
432 //-----------------------------------------------------------------------------
433 bool REMOTE_SCRIPT::Send(uint32_t ip, RS_USER & rsu, bool forceDisconnect) const
434 {
435 char buffer[RS_MAX_PACKET_LEN];
436
437 memset(buffer, 0, sizeof(buffer));
438
439 if (PreparePacket(buffer, sizeof(buffer), ip, rsu, forceDisconnect))
440     {
441     printfd(__FILE__, "REMOTE_SCRIPT::Send() - Invalid packet length!\n");
442     return true;
443     }
444
445 std::for_each(
446         rsu.routers.begin(),
447         rsu.routers.end(),
448         PacketSender(sock, buffer, sizeof(buffer), htons(rsSettings.GetPort()))
449         );
450
451 return false;
452 }
453 //-----------------------------------------------------------------------------
454 bool REMOTE_SCRIPT::SendDirect(uint32_t ip, RS_USER & rsu, uint32_t routerIP, bool forceDisconnect) const
455 {
456 char buffer[RS_MAX_PACKET_LEN];
457
458 if (PreparePacket(buffer, sizeof(buffer), ip, rsu, forceDisconnect))
459     {
460     printfd(__FILE__, "REMOTE_SCRIPT::SendDirect() - Invalid packet length!\n");
461     return true;
462     }
463
464 struct sockaddr_in sendAddr;
465
466 sendAddr.sin_family = AF_INET;
467 sendAddr.sin_port = htons(rsSettings.GetPort());
468 sendAddr.sin_addr.s_addr = routerIP;
469
470 int res = sendto(sock, buffer, sizeof(buffer), 0, (struct sockaddr *)&sendAddr, sizeof(sendAddr));
471
472 return (res != sizeof(buffer));
473 }
474 //-----------------------------------------------------------------------------
475 bool REMOTE_SCRIPT::GetUsers()
476 {
477 USER_PTR u;
478
479 int h = users->OpenSearch();
480 if (!h)
481     {
482     errorStr = "users->OpenSearch() error.";
483     printfd(__FILE__, "OpenSearch() error\n");
484     return true;
485     }
486
487 while (!users->SearchNext(h, &u))
488     {
489     SetUserNotifier(u);
490     }
491
492 users->CloseSearch(h);
493 return false;
494 }
495 //-----------------------------------------------------------------------------
496 void REMOTE_SCRIPT::ChangedIP(USER_PTR u, uint32_t oldIP, uint32_t newIP)
497 {
498 /*
499  * When ip changes process looks like:
500  * old => 0, 0 => new
501  *
502  */
503 if (newIP)
504     {
505     RS_USER rsu(IP2Routers(newIP), u);
506     Send(newIP, rsu);
507
508     STG_LOCKER lock(&mutex, __FILE__, __LINE__);
509     authorizedUsers[newIP] = rsu;
510     }
511 else
512     {
513     STG_LOCKER lock(&mutex, __FILE__, __LINE__);
514     const map<uint32_t, RS_USER>::iterator it(
515             authorizedUsers.find(oldIP)
516             );
517     if (it != authorizedUsers.end())
518         {
519         Send(oldIP, it->second, true);
520         authorizedUsers.erase(it);
521         }
522     }
523 }
524 //-----------------------------------------------------------------------------
525 std::vector<uint32_t> REMOTE_SCRIPT::IP2Routers(uint32_t ip)
526 {
527 STG_LOCKER lock(&mutex, __FILE__, __LINE__);
528 for (size_t i = 0; i < netRouters.size(); ++i)
529     {
530     if ((ip & netRouters[i].subnetMask) == (netRouters[i].subnetIP & netRouters[i].subnetMask))
531         {
532         return netRouters[i].routers;
533         }
534     }
535 return std::vector<uint32_t>();
536 }
537 //-----------------------------------------------------------------------------
538 string REMOTE_SCRIPT::GetUserParam(USER_PTR u, const string & paramName) const
539 {
540 string value = "";
541 if (strcasecmp(paramName.c_str(), "cash") == 0)
542     strprintf(&value, "%f", u->GetProperty().cash.Get());
543 else
544 if (strcasecmp(paramName.c_str(), "freeMb") == 0)
545     strprintf(&value, "%f", u->GetProperty().freeMb.Get());
546 else
547 if (strcasecmp(paramName.c_str(), "passive") == 0)
548     strprintf(&value, "%d", u->GetProperty().passive.Get());
549 else
550 if (strcasecmp(paramName.c_str(), "disabled") == 0)
551     strprintf(&value, "%d", u->GetProperty().disabled.Get());
552 else
553 if (strcasecmp(paramName.c_str(), "alwaysOnline") == 0)
554     strprintf(&value, "%d", u->GetProperty().alwaysOnline.Get());
555 else
556 if (strcasecmp(paramName.c_str(), "tariffName") == 0 ||
557     strcasecmp(paramName.c_str(), "tariff") == 0)
558     value = "\"" + u->GetProperty().tariffName.Get() + "\"";
559 else
560 if (strcasecmp(paramName.c_str(), "nextTariff") == 0)
561     value = "\"" + u->GetProperty().nextTariff.Get() + "\"";
562 else
563 if (strcasecmp(paramName.c_str(), "address") == 0)
564     value = "\"" + u->GetProperty().address.Get() + "\"";
565 else
566 if (strcasecmp(paramName.c_str(), "note") == 0)
567     value = "\"" + u->GetProperty().note.Get() + "\"";
568 else
569 if (strcasecmp(paramName.c_str(), "group") == 0)
570     value = "\"" + u->GetProperty().group.Get() + "\"";
571 else
572 if (strcasecmp(paramName.c_str(), "email") == 0)
573     value = "\"" + u->GetProperty().email.Get() + "\"";
574 else
575 if (strcasecmp(paramName.c_str(), "realName") == 0)
576     value = "\"" + u->GetProperty().realName.Get() + "\"";
577 else
578 if (strcasecmp(paramName.c_str(), "credit") == 0)
579     strprintf(&value, "%f", u->GetProperty().credit.Get());
580 else
581 if (strcasecmp(paramName.c_str(), "userdata0") == 0)
582     value = "\"" + u->GetProperty().userdata0.Get() + "\"";
583 else
584 if (strcasecmp(paramName.c_str(), "userdata1") == 0)
585     value = "\"" + u->GetProperty().userdata1.Get() + "\"";
586 else
587 if (strcasecmp(paramName.c_str(), "userdata2") == 0)
588     value = "\"" + u->GetProperty().userdata2.Get() + "\"";
589 else
590 if (strcasecmp(paramName.c_str(), "userdata3") == 0)
591     value = "\"" + u->GetProperty().userdata3.Get() + "\"";
592 else
593 if (strcasecmp(paramName.c_str(), "userdata4") == 0)
594     value = "\"" + u->GetProperty().userdata4.Get() + "\"";
595 else
596 if (strcasecmp(paramName.c_str(), "userdata5") == 0)
597     value = "\"" + u->GetProperty().userdata5.Get() + "\"";
598 else
599 if (strcasecmp(paramName.c_str(), "userdata6") == 0)
600     value = "\"" + u->GetProperty().userdata6.Get() + "\"";
601 else
602 if (strcasecmp(paramName.c_str(), "userdata7") == 0)
603     value = "\"" + u->GetProperty().userdata7.Get() + "\"";
604 else
605 if (strcasecmp(paramName.c_str(), "userdata8") == 0)
606     value = "\"" + u->GetProperty().userdata8.Get() + "\"";
607 else
608 if (strcasecmp(paramName.c_str(), "userdata9") == 0)
609     value = "\"" + u->GetProperty().userdata9.Get() + "\"";
610 else
611 if (strcasecmp(paramName.c_str(), "enabledDirs") == 0)
612     value = u->GetEnabledDirs();
613 else
614     printfd(__FILE__, "Unknown value name: %s\n", paramName.c_str());
615 return value;
616 }
617 //-----------------------------------------------------------------------------
618 void REMOTE_SCRIPT::SetUserNotifier(USER_PTR u)
619 {
620 RS_CHG_AFTER_NOTIFIER<uint32_t> afterChgIPNotifier(*this, u);
621
622 afterChgIPNotifierList.push_front(afterChgIPNotifier);
623
624 u->AddCurrIPAfterNotifier(&(*afterChgIPNotifierList.begin()));
625 }
626 //-----------------------------------------------------------------------------
627 void REMOTE_SCRIPT::UnSetUserNotifier(USER_PTR u)
628 {
629 list<RS_CHG_AFTER_NOTIFIER<uint32_t> >::iterator  ipAIter;
630 std::list<list<RS_CHG_AFTER_NOTIFIER<uint32_t> >::iterator> toErase;
631
632 for (ipAIter = afterChgIPNotifierList.begin(); ipAIter != afterChgIPNotifierList.end(); ++ipAIter)
633     {
634     if (ipAIter->GetUser() == u)
635         {
636         u->DelCurrIPAfterNotifier(&(*ipAIter));
637         toErase.push_back(ipAIter);
638         }
639     }
640
641 std::list<list<RS_CHG_AFTER_NOTIFIER<uint32_t> >::iterator>::iterator eIter;
642
643 for (eIter = toErase.begin(); eIter != toErase.end(); ++eIter)
644     {
645     afterChgIPNotifierList.erase(*eIter);
646     }
647 }
648 //-----------------------------------------------------------------------------
649 template <typename varParamType>
650 void RS_CHG_AFTER_NOTIFIER<varParamType>::Notify(const varParamType & oldValue, const varParamType & newValue)
651 {
652 rs.ChangedIP(user, oldValue, newValue);
653 }
654 //-----------------------------------------------------------------------------
655 void REMOTE_SCRIPT::InitEncrypt(BLOWFISH_CTX * ctx, const string & password) const
656 {
657 unsigned char keyL[PASSWD_LEN];  // Пароль для шифровки
658 memset(keyL, 0, PASSWD_LEN);
659 strncpy((char *)keyL, password.c_str(), PASSWD_LEN);
660 Blowfish_Init(ctx, keyL, PASSWD_LEN);
661 }
662 //-----------------------------------------------------------------------------
663 void REMOTE_SCRIPT::Encrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, size_t len8) const
664 {
665 if (dst != src)
666     memcpy(dst, src, len8 * 8);
667 for (size_t i = 0; i < len8; ++i)
668     Blowfish_Encrypt(ctx, (uint32_t *)(dst + i * 8), (uint32_t *)(dst + i * 8 + 4));
669 }
670 //-----------------------------------------------------------------------------