blob: dce1a569a8f9fb6454d562349ef7423607e5820c [file] [log] [blame]
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +00001/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19#include <rfb/VNCSConnectionST.h>
20#include <rfb/LogWriter.h>
21#include <rfb/secTypes.h>
22#include <rfb/ServerCore.h>
23#include <rfb/ComparingUpdateTracker.h>
24#define XK_MISCELLANY
25#define XK_XKB_KEYS
26#include <rfb/keysymdef.h>
27
28using namespace rfb;
29
30static LogWriter vlog("VNCSConnST");
31
32VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
33 bool reverse)
34 : sock(s), reverseConnection(reverse), server(server_),
35 image_getter(server->useEconomicTranslate),
36 drawRenderedCursor(false), removeRenderedCursor(false),
37 pointerEventTime(0), accessRights(AccessDefault)
38{
39 setStreams(&sock->inStream(), &sock->outStream());
40 peerEndpoint.buf = sock->getPeerEndpoint();
41 VNCServerST::connectionsLog.write(1,"accepted: %s", peerEndpoint.buf);
42
43 setSocketTimeouts();
44 lastEventTime = time(0);
45
46 // Initialise security
47 CharArray sec_types_str;
48 if (reverseConnection)
49 sec_types_str.buf = rfb::Server::rev_sec_types.getData();
50 else
51 sec_types_str.buf = rfb::Server::sec_types.getData();
52 std::list<int> sec_types = parseSecTypes(sec_types_str.buf);
53 std::list<int>::iterator i;
54 for (i=sec_types.begin(); i!=sec_types.end(); i++) {
55 addSecType(*i);
56 }
57
58 server->clients.push_front(this);
Oleg Sheikin641f7e52005-11-22 18:04:10 +000059 startTime = time(0);
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000060}
61
62
63VNCSConnectionST::~VNCSConnectionST()
64{
65 // If we reach here then VNCServerST is deleting us!
66 VNCServerST::connectionsLog.write(1,"closed: %s (%s)",
67 peerEndpoint.buf, closeReason.buf);
68
69 // Release any keys the client still had pressed
70 std::set<rdr::U32>::iterator i;
71 for (i=pressedKeys.begin(); i!=pressedKeys.end(); i++)
72 server->desktop->keyEvent(*i, false);
73 if (server->pointerClient == this)
74 server->pointerClient = 0;
75
76 // Remove this client from the server
77 server->clients.remove(this);
78}
79
80
81// Methods called from VNCServerST
82
83bool VNCSConnectionST::init()
84{
85 try {
86 initialiseProtocol();
87 } catch (rdr::Exception& e) {
88 close(e.str());
89 return false;
90 }
91 return true;
92}
93
94void VNCSConnectionST::close(const char* reason)
95{
96 // Log the reason for the close
97 if (!closeReason.buf)
98 closeReason.buf = strDup(reason);
99 else
100 vlog.debug("second close: %s (%s)", peerEndpoint.buf, reason);
101
Peter Åstrand43aa1a12005-02-21 09:58:31 +0000102 if (authenticated()) {
103 server->lastDisconnectTime = time(0);
104 }
105
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +0000106 // Just shutdown the socket. This will cause processMessages to
107 // eventually fail, causing us and our socket to be deleted.
108 sock->shutdown();
109 setState(RFBSTATE_CLOSING);
110}
111
112
113bool VNCSConnectionST::processMessages()
114{
115 if (state() == RFBSTATE_CLOSING) return false;
116 try {
117 // - Now set appropriate socket timeouts and process data
118 setSocketTimeouts();
119 bool clientsReadyBefore = server->clientsReadyForUpdate();
120
121 while (getInStream()->checkNoWait(1)) {
122 processMsg();
123 }
124
125 if (!clientsReadyBefore && !requested.is_empty())
126 server->desktop->framebufferUpdateRequest();
127
128 return true;
129
130 } catch (rdr::EndOfStream&) {
131 close("Clean disconnection");
132 } catch (rdr::Exception &e) {
133 close(e.str());
134 }
135 return false;
136}
137
138void VNCSConnectionST::writeFramebufferUpdateOrClose()
139{
140 try {
141 writeFramebufferUpdate();
142 } catch(rdr::Exception &e) {
143 close(e.str());
144 }
145}
146
147void VNCSConnectionST::pixelBufferChange()
148{
149 try {
150 if (!authenticated()) return;
151 if (cp.width && cp.height && (server->pb->width() != cp.width ||
152 server->pb->height() != cp.height))
153 {
154 // We need to clip the next update to the new size, but also add any
155 // extra bits if it's bigger. If we wanted to do this exactly, something
156 // like the code below would do it, but at the moment we just update the
157 // entire new size. However, we do need to clip the renderedCursorRect
158 // because that might be added to updates in writeFramebufferUpdate().
159
160 //updates.intersect(server->pb->getRect());
161 //
162 //if (server->pb->width() > cp.width)
163 // updates.add_changed(Rect(cp.width, 0, server->pb->width(),
164 // server->pb->height()));
165 //if (server->pb->height() > cp.height)
166 // updates.add_changed(Rect(0, cp.height, cp.width,
167 // server->pb->height()));
168
169 renderedCursorRect = renderedCursorRect.intersect(server->pb->getRect());
170
171 cp.width = server->pb->width();
172 cp.height = server->pb->height();
173 if (!writer()->writeSetDesktopSize()) {
174 close("Client does not support desktop resize");
175 return;
176 }
177 }
178 // Just update the whole screen at the moment because we're too lazy to
179 // work out what's actually changed.
180 updates.clear();
181 updates.add_changed(server->pb->getRect());
182 vlog.debug("pixel buffer changed - re-initialising image getter");
183 image_getter.init(server->pb, cp.pf(), writer());
184 if (writer()->needFakeUpdate())
185 writeFramebufferUpdate();
186 } catch(rdr::Exception &e) {
187 close(e.str());
188 }
189}
190
191void VNCSConnectionST::setColourMapEntriesOrClose(int firstColour,int nColours)
192{
193 try {
194 setColourMapEntries(firstColour, nColours);
195 } catch(rdr::Exception& e) {
196 close(e.str());
197 }
198}
199
200void VNCSConnectionST::bell()
201{
202 try {
203 if (state() == RFBSTATE_NORMAL) writer()->writeBell();
204 } catch(rdr::Exception& e) {
205 close(e.str());
206 }
207}
208
209void VNCSConnectionST::serverCutText(const char *str, int len)
210{
211 try {
212 if (!(accessRights & AccessCutText)) return;
213 if (!rfb::Server::sendCutText) return;
214 if (state() == RFBSTATE_NORMAL)
215 writer()->writeServerCutText(str, len);
216 } catch(rdr::Exception& e) {
217 close(e.str());
218 }
219}
220
221void VNCSConnectionST::setCursorOrClose()
222{
223 try {
224 setCursor();
225 } catch(rdr::Exception& e) {
226 close(e.str());
227 }
228}
229
230
231int VNCSConnectionST::checkIdleTimeout()
232{
233 int idleTimeout = rfb::Server::idleTimeout;
234 if (idleTimeout == 0) return 0;
235 if (state() != RFBSTATE_NORMAL && idleTimeout < 15)
236 idleTimeout = 15; // minimum of 15 seconds while authenticating
237 time_t now = time(0);
238 if (now < lastEventTime) {
239 // Someone must have set the time backwards. Set lastEventTime so that the
240 // idleTimeout will count from now.
241 vlog.info("Time has gone backwards - resetting idle timeout");
242 lastEventTime = now;
243 }
244 int timeLeft = lastEventTime + idleTimeout - now;
245 if (timeLeft < -60) {
246 // Our callback is over a minute late - someone must have set the time
247 // forwards. Set lastEventTime so that the idleTimeout will count from
248 // now.
249 vlog.info("Time has gone forwards - resetting idle timeout");
250 lastEventTime = now;
251 return idleTimeout;
252 }
253 if (timeLeft <= 0) {
254 close("Idle timeout");
255 return 0;
256 }
257 return timeLeft * 1000;
258}
259
260// renderedCursorChange() is called whenever the server-side rendered cursor
261// changes shape or position. It ensures that the next update will clean up
262// the old rendered cursor and if necessary draw the new rendered cursor.
263
264void VNCSConnectionST::renderedCursorChange()
265{
266 if (state() != RFBSTATE_NORMAL) return;
267 removeRenderedCursor = true;
268 if (needRenderedCursor())
269 drawRenderedCursor = true;
270}
271
272// needRenderedCursor() returns true if this client needs the server-side
273// rendered cursor. This may be because it does not support local cursor or
274// because the current cursor position has not been set by this client.
275// Unfortunately we can't know for sure when the current cursor position has
276// been set by this client. We guess that this is the case when the current
277// cursor position is the same as the last pointer event from this client, or
278// if it is a very short time since this client's last pointer event (up to a
279// second). [ Ideally we should do finer-grained timing here and make the time
280// configurable, but I don't think it's that important. ]
281
282bool VNCSConnectionST::needRenderedCursor()
283{
284 return (state() == RFBSTATE_NORMAL
Peter Åstrand1e9d32f2005-02-16 13:00:38 +0000285 && (!cp.supportsLocalCursor && !cp.supportsLocalXCursor
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +0000286 || (!server->cursorPos.equals(pointerEventPos) &&
287 (time(0) - pointerEventTime) > 0)));
288}
289
290
291void VNCSConnectionST::approveConnectionOrClose(bool accept,
292 const char* reason)
293{
294 try {
295 approveConnection(accept, reason);
296 } catch (rdr::Exception& e) {
297 close(e.str());
298 }
299}
300
301
302
303// -=- Callbacks from SConnection
304
305void VNCSConnectionST::versionReceived() {
306 CharArray address(sock->getPeerAddress());
307 if ((rfb::Server::blacklistLevel == 1) &&
308 server->blHosts->isBlackmarked(address.buf)) {
309 server->connectionsLog.error("blacklisted: %s", address.buf);
310 throwConnFailedException("Too many security failures");
311 }
312}
313
314SSecurity* VNCSConnectionST::getSSecurity(int secType) {
315 if (!server->securityFactory)
316 throw rdr::Exception("no SSecurityFactory registered!");
317 return server->securityFactory->getSSecurity(secType, reverseConnection);
318}
319
320void VNCSConnectionST::authSuccess()
321{
322 lastEventTime = time(0);
323
324 // - Authentication succeeded - clear from blacklist
325 CharArray name; name.buf = sock->getPeerAddress();
326 server->blHosts->clearBlackmark(name.buf);
327
328 server->startDesktop();
329
330 // - Set the connection parameters appropriately
331 cp.width = server->pb->width();
332 cp.height = server->pb->height();
333 cp.setName(server->getName());
334
335 // - Set the default pixel format
336 cp.setPF(server->pb->getPF());
337 char buffer[256];
338 cp.pf().print(buffer, 256);
339 vlog.info("Server default pixel format %s", buffer);
340 image_getter.init(server->pb, cp.pf(), 0);
341
342 // - Mark the entire display as "dirty"
343 updates.add_changed(server->pb->getRect());
344}
345
346void VNCSConnectionST::queryConnection(const char* userName)
347{
348 // - Does the client have the right to bypass the query?
349 if (reverseConnection || !rfb::Server::queryConnect ||
350 (accessRights & AccessNoQuery))
351 {
352 approveConnection(true);
353 return;
354 }
355
356 CharArray reason;
357 VNCServerST::queryResult qr = server->queryConnection(sock, userName,
358 &reason.buf);
359 if (qr == VNCServerST::PENDING) return;
360 approveConnection(qr == VNCServerST::ACCEPT, reason.buf);
361}
362
363void VNCSConnectionST::clientInit(bool shared)
364{
365 lastEventTime = time(0);
366 if (rfb::Server::alwaysShared || reverseConnection) shared = true;
367 if (rfb::Server::neverShared) shared = false;
368 if (!shared) {
369 if (rfb::Server::disconnectClients) {
370 // - Close all the other connected clients
371 vlog.debug("non-shared connection - closing clients");
372 server->closeClients("Non-shared connection requested", getSock());
373 } else {
374 // - Refuse this connection if there are existing clients, in addition to this one
375 if (server->authClientCount() > 1) {
376 close("Server is already in use");
377 return;
378 }
379 }
380 }
381 SConnection::clientInit(shared);
382}
383
384void VNCSConnectionST::setPixelFormat(const PixelFormat& pf)
385{
386 SConnection::setPixelFormat(pf);
387 char buffer[256];
388 pf.print(buffer, 256);
389 vlog.info("Client pixel format %s", buffer);
390 image_getter.init(server->pb, pf, writer());
391 setCursor();
392}
393
394void VNCSConnectionST::pointerEvent(int x, int y, int buttonMask)
395{
396 pointerEventTime = lastEventTime = time(0);
Peter Åstrand43aa1a12005-02-21 09:58:31 +0000397 server->lastUserInputTime = lastEventTime;
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +0000398 if (!(accessRights & AccessPtrEvents)) return;
399 if (!rfb::Server::acceptPointerEvents) return;
400 if (!server->pointerClient || server->pointerClient == this) {
401 pointerEventPos = Point(x, y);
402 if (buttonMask)
403 server->pointerClient = this;
404 else
405 server->pointerClient = 0;
406 server->desktop->pointerEvent(pointerEventPos, buttonMask);
407 }
408}
409
410
411class VNCSConnectionSTShiftPresser {
412public:
413 VNCSConnectionSTShiftPresser(SDesktop* desktop_)
414 : desktop(desktop_), pressed(false) {}
415 ~VNCSConnectionSTShiftPresser() {
416 if (pressed) { desktop->keyEvent(XK_Shift_L, false); }
417 }
418 void press() {
419 desktop->keyEvent(XK_Shift_L, true);
420 pressed = true;
421 }
422 SDesktop* desktop;
423 bool pressed;
424};
425
426// keyEvent() - record in the pressedKeys which keys were pressed. Allow
427// multiple down events (for autorepeat), but only allow a single up event.
428void VNCSConnectionST::keyEvent(rdr::U32 key, bool down) {
429 lastEventTime = time(0);
Peter Åstrand43aa1a12005-02-21 09:58:31 +0000430 server->lastUserInputTime = lastEventTime;
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +0000431 if (!(accessRights & AccessKeyEvents)) return;
432 if (!rfb::Server::acceptKeyEvents) return;
433
434 // Turn ISO_Left_Tab into shifted Tab.
435 VNCSConnectionSTShiftPresser shiftPresser(server->desktop);
436 if (key == XK_ISO_Left_Tab) {
437 if (pressedKeys.find(XK_Shift_L) == pressedKeys.end() &&
438 pressedKeys.find(XK_Shift_R) == pressedKeys.end())
439 shiftPresser.press();
440 key = XK_Tab;
441 }
442
443 if (down) {
444 pressedKeys.insert(key);
445 } else {
446 if (!pressedKeys.erase(key)) return;
447 }
448 server->desktop->keyEvent(key, down);
449}
450
451void VNCSConnectionST::clientCutText(const char* str, int len)
452{
453 if (!(accessRights & AccessCutText)) return;
454 if (!rfb::Server::acceptCutText) return;
455 server->desktop->clientCutText(str, len);
456}
457
458void VNCSConnectionST::framebufferUpdateRequest(const Rect& r,bool incremental)
459{
460 if (!(accessRights & AccessView)) return;
461
462 SConnection::framebufferUpdateRequest(r, incremental);
463
464 Region reqRgn(r);
465 requested.assign_union(reqRgn);
466
467 if (!incremental) {
468 // Non-incremental update - treat as if area requested has changed
469 updates.add_changed(reqRgn);
470 server->comparer->add_changed(reqRgn);
471 }
472
473 writeFramebufferUpdate();
474}
475
476void VNCSConnectionST::setInitialColourMap()
477{
478 setColourMapEntries(0, 0);
479}
480
481// supportsLocalCursor() is called whenever the status of
482// cp.supportsLocalCursor has changed. If the client does now support local
483// cursor, we make sure that the old server-side rendered cursor is cleaned up
484// and the cursor is sent to the client.
485
486void VNCSConnectionST::supportsLocalCursor()
487{
Peter Åstrand1e9d32f2005-02-16 13:00:38 +0000488 if (cp.supportsLocalCursor || cp.supportsLocalXCursor) {
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +0000489 removeRenderedCursor = true;
490 drawRenderedCursor = false;
491 setCursor();
492 }
493}
494
495void VNCSConnectionST::writeSetCursorCallback()
496{
Peter Åstrand1e9d32f2005-02-16 13:00:38 +0000497 if (cp.supportsLocalXCursor) {
498 Pixel pix0, pix1;
499 rdr::U8Array bitmap(server->cursor.getBitmap(&pix0, &pix1));
500 if (bitmap.buf) {
501 // The client supports XCursor and the cursor only has two
502 // colors. Use the XCursor encoding.
503 writer()->writeSetXCursor(server->cursor.width(),
504 server->cursor.height(),
505 server->cursor.hotspot.x,
506 server->cursor.hotspot.y,
507 bitmap.buf, server->cursor.mask.buf);
508 return;
509 } else {
510 // More than two colors
511 if (!cp.supportsLocalCursor) {
512 // FIXME: We could reduce to two colors.
513 vlog.info("Unable to send multicolor cursor: RichCursor not supported by client");
514 return;
515 }
516 }
517 }
518
519 // Use RichCursor
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +0000520 rdr::U8* transData = writer()->getImageBuf(server->cursor.area());
521 image_getter.translatePixels(server->cursor.data, transData,
Peter Åstrand1e9d32f2005-02-16 13:00:38 +0000522 server->cursor.area());
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +0000523 writer()->writeSetCursor(server->cursor.width(),
Peter Åstrand1e9d32f2005-02-16 13:00:38 +0000524 server->cursor.height(),
525 server->cursor.hotspot.x,
526 server->cursor.hotspot.y,
527 transData, server->cursor.mask.buf);
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +0000528}
529
530
531void VNCSConnectionST::writeFramebufferUpdate()
532{
533 if (state() != RFBSTATE_NORMAL || requested.is_empty()) return;
534
535 server->checkUpdate();
536
537 // If the previous position of the rendered cursor overlaps the source of the
538 // copy, then when the copy happens the corresponding rectangle in the
539 // destination will be wrong, so add it to the changed region.
540
541 if (!updates.get_copied().is_empty() && !renderedCursorRect.is_empty()) {
542 Rect bogusCopiedCursor = (renderedCursorRect.translate(updates.get_delta())
543 .intersect(server->pb->getRect()));
544 if (!updates.get_copied().intersect(bogusCopiedCursor).is_empty()) {
545 updates.add_changed(bogusCopiedCursor);
546 }
547 }
548
549 // If we need to remove the old rendered cursor, just add the rectangle to
550 // the changed region.
551
552 if (removeRenderedCursor) {
553 updates.add_changed(renderedCursorRect);
554 renderedCursorRect.clear();
555 removeRenderedCursor = false;
556 }
557
558 // Return if there is nothing to send the client.
559
560 if (updates.is_empty() && !writer()->needFakeUpdate() && !drawRenderedCursor)
561 return;
562
563 // If the client needs a server-side rendered cursor, work out the cursor
564 // rectangle. If it's empty then don't bother drawing it, but if it overlaps
565 // with the update region, we need to draw the rendered cursor regardless of
566 // whether it has changed.
567
568 if (needRenderedCursor()) {
569 renderedCursorRect
570 = (server->renderedCursor.getRect(server->renderedCursorTL)
571 .intersect(requested.get_bounding_rect()));
572
573 if (renderedCursorRect.is_empty()) {
574 drawRenderedCursor = false;
575 } else if (!updates.get_changed().union_(updates.get_copied())
576 .intersect(renderedCursorRect).is_empty()) {
577 drawRenderedCursor = true;
578 }
579
580 // We could remove the new cursor rect from updates here. It's not clear
581 // whether this is worth it. If we do remove it, then we won't draw over
582 // the same bit of screen twice, but we have the overhead of a more complex
583 // region.
584
585 //if (drawRenderedCursor)
586 // updates.subtract(renderedCursorRect);
587 }
588
589 UpdateInfo update;
590 updates.enable_copyrect(cp.useCopyRect);
591 updates.get_update(&update, requested);
592 if (!update.is_empty() || writer()->needFakeUpdate() || drawRenderedCursor) {
Peter Åstrand016dc192005-02-10 16:41:06 +0000593 // Compute the number of rectangles. Tight encoder makes the things more
594 // complicated as compared to the original RealVNC.
595 writer()->setupCurrentEncoder();
596 int nRects = update.copied.numRects() + (drawRenderedCursor ? 1 : 0);
597 std::vector<Rect> rects;
598 std::vector<Rect>::const_iterator i;
599 update.changed.get_rects(&rects);
600 for (i = rects.begin(); i != rects.end(); i++) {
601 if (i->width() && i->height())
602 nRects += writer()->getNumRects(*i);
603 }
604
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +0000605 writer()->writeFramebufferUpdateStart(nRects);
606 Region updatedRegion;
607 writer()->writeRects(update, &image_getter, &updatedRegion);
608 updates.subtract(updatedRegion);
609 if (drawRenderedCursor)
610 writeRenderedCursorRect();
611 writer()->writeFramebufferUpdateEnd();
612 requested.clear();
613 }
614}
615
616
617// writeRenderedCursorRect() writes a single rectangle drawing the rendered
618// cursor on the client.
619
620void VNCSConnectionST::writeRenderedCursorRect()
621{
622 image_getter.setPixelBuffer(&server->renderedCursor);
623 image_getter.setOffset(server->renderedCursorTL);
624
625 Rect actual;
626 writer()->writeRect(renderedCursorRect, &image_getter, &actual);
627
628 image_getter.setPixelBuffer(server->pb);
629 image_getter.setOffset(Point(0,0));
630
631 drawRenderedCursor = false;
632}
633
634void VNCSConnectionST::setColourMapEntries(int firstColour, int nColours)
635{
636 if (!readyForSetColourMapEntries) return;
637 if (server->pb->getPF().trueColour) return;
638
639 image_getter.setColourMapEntries(firstColour, nColours, writer());
640
641 if (cp.pf().trueColour) {
642 updates.add_changed(server->pb->getRect());
643 }
644}
645
646
647// setCursor() is called whenever the cursor has changed shape or pixel format.
648// If the client supports local cursor then it will arrange for the cursor to
649// be sent to the client.
650
651void VNCSConnectionST::setCursor()
652{
653 if (state() != RFBSTATE_NORMAL || !cp.supportsLocalCursor) return;
654 writer()->cursorChange(this);
655 if (writer()->needFakeUpdate())
656 writeFramebufferUpdate();
657}
658
659void VNCSConnectionST::setSocketTimeouts()
660{
661 int timeoutms = rfb::Server::clientWaitTimeMillis;
662 if (timeoutms == 0 || timeoutms > rfb::Server::idleTimeout * 1000) {
663 timeoutms = rfb::Server::idleTimeout * 1000;
664 if (timeoutms == 0)
665 timeoutms = -1;
666 }
667 sock->inStream().setTimeout(timeoutms);
668 sock->outStream().setTimeout(timeoutms);
669}
Oleg Sheikinff43bfd2005-12-07 08:02:52 +0000670
671char* VNCSConnectionST::getStartTime()
672{
673 char* result = ctime(&startTime);
674 result[24] = '\0';
675 return result;
676}