| 273 | | *needmoredata = true; |
|---|
| 274 | | return CL_ASSIGN; |
|---|
| 275 | | } |
|---|
| 276 | | |
|---|
| 277 | | GotekPacket *gp = GotekPacket::createReadPacket(m_Buffer); |
|---|
| 278 | | |
|---|
| 279 | | uint8_t command = gp->readUInt8(); |
|---|
| 280 | | if ( command != (uint8_t)CCMD_LOGIN ) |
|---|
| 281 | | { |
|---|
| 282 | | logInfo("Invalid CCMD_LOGIN %x\n",command); |
|---|
| 283 | | return CL_DROP; |
|---|
| 284 | | } |
|---|
| 285 | | |
|---|
| 286 | | uint32_t gotekpacketsize = gp->readUInt32(); |
|---|
| 287 | | if (m_Buffer.size() < gotekpacketsize + 5 ) |
|---|
| 288 | | { |
|---|
| 289 | | *needmoredata = true; |
|---|
| 290 | | return CL_ASSIGN; |
|---|
| 291 | | } |
|---|
| 292 | | |
|---|
| 293 | | |
|---|
| 294 | | // parse the data |
|---|
| 295 | | string hash; |
|---|
| 296 | | |
|---|
| 297 | | try |
|---|
| 298 | | { |
|---|
| 299 | | gp->readString(); |
|---|
| 300 | | gp->readString(); |
|---|
| 301 | | m_Username = gp->readString(); |
|---|
| 302 | | hash = gp->readRaw(64); |
|---|
| 303 | | command = gp->readUInt8(); |
|---|
| 304 | | } |
|---|
| 305 | | catch ( GotekException e ) |
|---|
| 306 | | { |
|---|
| 307 | | delete gp; |
|---|
| 308 | | return CL_DROP; |
|---|
| 309 | | } |
|---|
| 310 | | delete gp; |
|---|
| 311 | | |
|---|
| 312 | | // verfiy the data is sane |
|---|
| 313 | | if ( command != CTYPE_CTRL && command != CTYPE_DATA ) |
|---|
| 314 | | { |
|---|
| 315 | | return CL_DROP; |
|---|
| 316 | | } |
|---|
| 317 | | |
|---|
| 318 | | for ( char * c = (char *)m_Username.c_str(); * c; ++c ) |
|---|
| 319 | | if ( !isalpha(* c) && * c != '.' && * c != '-' ) |
|---|
| 320 | | return CL_DROP; |
|---|
| 321 | | |
|---|
| 322 | | // create the query context so we know which query returns, so we can answer appropriate |
|---|
| 323 | | |
|---|
| 324 | | SQLContext *sqlctx = new SQLContext(command,time(NULL),&hash); |
|---|
| 325 | | |
|---|
| 326 | | // query |
|---|
| 327 | | string query = "SELECT \"authkey\" FROM \"users-dp\".\"users\" WHERE username = '"; |
|---|
| 328 | | query += m_Username.c_str(); |
|---|
| 329 | | query += "';"; |
|---|
| 330 | | |
|---|
| 331 | | SQLQuery *sqlquery = g_Library->getSQLMgr()->addQuery(&query,this,(void *)sqlctx); |
|---|
| 332 | | m_QueryQueue.push_back(sqlquery); |
|---|
| 333 | | |
|---|
| 334 | | m_Buffer.erase(0,gotekpacketsize+5); |
|---|
| 335 | | return CL_ASSIGN; |
|---|
| 336 | | } |
|---|
| 337 | | |
|---|
| 338 | | |
|---|
| 339 | | |
|---|
| 340 | | |
|---|
| 341 | | |
|---|
| 342 | | ConsumeLevel ServiceGotek2Dialogue::processCTRL(bool *needmoredata) |
|---|
| 343 | | { |
|---|
| 344 | | logPF(); |
|---|
| 345 | | |
|---|
| 346 | | if (m_Buffer.size() < 1 ) |
|---|
| 347 | | { |
|---|
| 348 | | *needmoredata = true; |
|---|
| 349 | | return CL_ASSIGN; |
|---|
| 350 | | } |
|---|
| 351 | | |
|---|
| 352 | | if (m_Buffer[0] == CCMD_NOOP) |
|---|
| 353 | | { |
|---|
| 354 | | m_Buffer.erase(0,1); |
|---|
| 355 | | return CL_ASSIGN; |
|---|
| 356 | | } |
|---|
| 357 | | |
|---|
| 358 | | if (m_Buffer.size() < 5) |
|---|
| 359 | | { |
|---|
| 360 | | *needmoredata = true; |
|---|
| 361 | | return CL_ASSIGN; |
|---|
| 362 | | } |
|---|
| 363 | | |
|---|
| 364 | | ConsumeLevel cl = CL_ASSIGN; |
|---|
| 365 | | |
|---|
| 366 | | GotekPacket *gp = GotekPacket::createReadPacket(m_Buffer); |
|---|
| 367 | | |
|---|
| 368 | | uint8_t command = gp->readUInt8(); |
|---|
| 369 | | uint32_t gotekpacketsize = gp->readUInt32(); |
|---|
| 370 | | |
|---|
| 371 | | if (m_Buffer.size() < + gotekpacketsize + 5 ) |
|---|
| 372 | | { |
|---|
| 373 | | *needmoredata = true; |
|---|
| 374 | | delete gp; |
|---|
| 375 | | return CL_ASSIGN; |
|---|
| 376 | | } |
|---|
| 377 | | |
|---|
| 378 | | try |
|---|
| 379 | | { |
|---|
| 380 | | switch ( command ) |
|---|
| | 224 | if (*it == client) |
|---|
| 403 | | catch ( GotekException e ) |
|---|
| 404 | | { |
|---|
| 405 | | return CL_DROP; |
|---|
| 406 | | } |
|---|
| 407 | | |
|---|
| 408 | | m_Buffer.erase(0,gotekpacketsize + 5); |
|---|
| 409 | | |
|---|
| 410 | | return cl; |
|---|
| 411 | | } |
|---|
| 412 | | |
|---|
| 413 | | ConsumeLevel ServiceGotek2Dialogue::processCTRL_CHECK_PRESENCE(GotekPacket *gp) |
|---|
| 414 | | { |
|---|
| 415 | | logPF(); |
|---|
| 416 | | uint8_t hash_type = gp->readUInt8(); |
|---|
| 417 | | if (hash_type != HTYPE_MD5 && hash_type != HTYPE_SHA512) |
|---|
| 418 | | { |
|---|
| 419 | | m_Socket->doWrite(mapEnum(RPL_UNSUPPORTED),1); |
|---|
| 420 | | return CL_ASSIGN; |
|---|
| 421 | | } |
|---|
| 422 | | |
|---|
| 423 | | |
|---|
| 424 | | // create the query context so we know which query returns, so we can answer appropriate |
|---|
| 425 | | |
|---|
| 426 | | SQLContext *sqlctx = new SQLContext(CCMD_CHECK_PRESENCE,time(NULL)); |
|---|
| 427 | | |
|---|
| 428 | | string hash; |
|---|
| 429 | | switch(hash_type) |
|---|
| 430 | | { |
|---|
| 431 | | case HTYPE_SHA512: |
|---|
| 432 | | { |
|---|
| 433 | | string hash = gp->readRaw(64); |
|---|
| 434 | | hash = SQL_ESCAPE_BINARY(&hash); |
|---|
| 435 | | string query = "SELECT \"sha512_hash\" FROM \"users-dp\".\"malware\" WHERE sha512_hash = '" + hash +"';"; |
|---|
| 436 | | SQLQuery *sqlquery = g_Library->getSQLMgr()->addQuery(&query,this,(void *)sqlctx); |
|---|
| 437 | | m_QueryQueue.push_back(sqlquery); |
|---|
| 438 | | } |
|---|
| 439 | | break; |
|---|
| 440 | | |
|---|
| 441 | | case HTYPE_MD5: |
|---|
| 442 | | { |
|---|
| 443 | | string hash = gp->readRaw(16); |
|---|
| 444 | | hash = SQL_ESCAPE_BINARY(&hash); |
|---|
| 445 | | string query = "SELECT \"sha512_hash\" FROM \"users-dp\".\"malware\" WHERE sha512_hash = '" + hash +"';"; |
|---|
| 446 | | SQLQuery *sqlquery = g_Library->getSQLMgr()->addQuery(&query,this,(void *)sqlctx); |
|---|
| 447 | | m_QueryQueue.push_back(sqlquery); |
|---|
| 448 | | } |
|---|
| 449 | | break; |
|---|
| 450 | | |
|---|
| 451 | | } |
|---|
| 452 | | |
|---|
| 453 | | return CL_ASSIGN; |
|---|
| 454 | | } |
|---|
| 455 | | |
|---|
| 456 | | ConsumeLevel ServiceGotek2Dialogue::processCTRL_STORE_MAGNET(GotekPacket *gp) |
|---|
| 457 | | { |
|---|
| 458 | | logPF(); |
|---|
| 459 | | string hash = gp->readRaw(64); |
|---|
| 460 | | uint8_t writemode = gp->readUInt8(); |
|---|
| 461 | | string name = gp->readString(); |
|---|
| 462 | | uint16_t valuesize = gp->readUInt16(); |
|---|
| 463 | | string value = gp->readRaw(valuesize); |
|---|
| 464 | | |
|---|
| 465 | | name = SQL_ESCAPE_STRING(&name); |
|---|
| 466 | | hash = SQL_ESCAPE_BINARY(&hash); |
|---|
| 467 | | value = SQL_ESCAPE_STRING(&value); |
|---|
| 468 | | |
|---|
| 469 | | writemode = 0; |
|---|
| 470 | | |
|---|
| 471 | | SQLContext *sqlctx = new SQLContext(CCMD_STORE_MAGNET,time(NULL)); |
|---|
| 472 | | |
|---|
| 473 | | string query = "INSERT INTO \"users-dp\".\"magnets\" (\"sha512_hash\",\"name\",\"value\") VALUES ('" + hash + "','" + name + "','" + value + "')"; |
|---|
| 474 | | |
|---|
| 475 | | SQLQuery *sqlquery = g_Library->getSQLMgr()->addQuery(&query,this,(void *)sqlctx); |
|---|
| 476 | | m_QueryQueue.push_back(sqlquery); |
|---|
| 477 | | |
|---|
| 478 | | |
|---|
| 479 | | return CL_ASSIGN; |
|---|
| 480 | | } |
|---|
| 481 | | |
|---|
| 482 | | ConsumeLevel ServiceGotek2Dialogue::processCTRL_REQUEST_NOTIFICATION(GotekPacket *gp) |
|---|
| 483 | | { |
|---|
| 484 | | logPF(); |
|---|
| 485 | | return CL_DROP; |
|---|
| 486 | | } |
|---|
| 487 | | |
|---|
| 488 | | ConsumeLevel ServiceGotek2Dialogue::processCTRL_REQUEST_SILENCE(GotekPacket *gp) |
|---|
| 489 | | { |
|---|
| 490 | | logPF(); |
|---|
| 491 | | return CL_DROP; |
|---|
| 492 | | } |
|---|
| 493 | | |
|---|
| 494 | | ConsumeLevel ServiceGotek2Dialogue::processCTRL_REPORT_INSTANCE(GotekPacket *gp) |
|---|
| 495 | | { |
|---|
| 496 | | logPF(); |
|---|
| 497 | | string hash = gp->readRaw(64); |
|---|
| 498 | | hash = SQL_ESCAPE_BINARY(&hash); |
|---|
| 499 | | |
|---|
| 500 | | uint16_t num_magnets = gp->readUInt16(); |
|---|
| 501 | | |
|---|
| 502 | | uint16_t i; |
|---|
| 503 | | |
|---|
| 504 | | string insert_names; |
|---|
| 505 | | string insert_values; |
|---|
| 506 | | |
|---|
| 507 | | for (i=0;i<num_magnets;i++) |
|---|
| 508 | | { |
|---|
| 509 | | |
|---|
| 510 | | string name = gp->readString(); |
|---|
| 511 | | name = SQL_ESCAPE_STRING(&name); |
|---|
| 512 | | |
|---|
| 513 | | insert_names += "\"" + name + "\""; |
|---|
| 514 | | |
|---|
| 515 | | if (i+1 < num_magnets ) |
|---|
| 516 | | { |
|---|
| 517 | | insert_names += ","; |
|---|
| 518 | | } |
|---|
| 519 | | |
|---|
| 520 | | |
|---|
| 521 | | uint16_t valuesize = gp->readUInt16(); |
|---|
| 522 | | string value = gp->readRaw(valuesize); |
|---|
| 523 | | value = SQL_ESCAPE_STRING(&value); |
|---|
| 524 | | |
|---|
| 525 | | insert_values += "'" + value + "'"; |
|---|
| 526 | | |
|---|
| 527 | | if (i+1 < num_magnets ) |
|---|
| 528 | | { |
|---|
| 529 | | insert_values += ","; |
|---|
| 530 | | } |
|---|
| 531 | | } |
|---|
| 532 | | |
|---|
| 533 | | |
|---|
| 534 | | string query = "INSERT INTO \"users-dp\".\"instances\" (" + insert_names + ") VALUES (" + insert_values + ")"; |
|---|
| 535 | | |
|---|
| 536 | | |
|---|
| 537 | | SQLContext *sqlctx = new SQLContext(CCMD_REPORT_INSTANCE,time(NULL)); |
|---|
| 538 | | |
|---|
| 539 | | SQLQuery *sqlquery = g_Library->getSQLMgr()->addQuery(&query,this,sqlctx); |
|---|
| 540 | | m_QueryQueue.push_back(sqlquery); |
|---|
| 541 | | |
|---|
| 542 | | return CL_ASSIGN; |
|---|
| 543 | | } |
|---|
| 544 | | |
|---|
| 545 | | |
|---|
| 546 | | |
|---|
| 547 | | |
|---|
| 548 | | ConsumeLevel ServiceGotek2Dialogue::processDATA(bool *needmoredata) |
|---|
| 549 | | { |
|---|
| 550 | | logPF(); |
|---|
| 551 | | return CL_DROP; |
|---|
| 552 | | } |
|---|
| 553 | | |
|---|
| 554 | | ConsumeLevel ServiceGotek2Dialogue::processDATA_MAGNET(GotekPacket *gp) |
|---|
| 555 | | { |
|---|
| 556 | | logPF(); |
|---|
| 557 | | return CL_DROP; |
|---|
| 558 | | } |
|---|
| 559 | | |
|---|
| 560 | | ConsumeLevel ServiceGotek2Dialogue::processDATA_SAMPLE_GET(GotekPacket *gp) |
|---|
| 561 | | { |
|---|
| 562 | | logPF(); |
|---|
| 563 | | return CL_DROP; |
|---|
| 564 | | } |
|---|
| 565 | | |
|---|
| 566 | | ConsumeLevel ServiceGotek2Dialogue::processDATA_SAMPLE_ADD(GotekPacket *gp) |
|---|
| 567 | | { |
|---|
| 568 | | logPF(); |
|---|
| 569 | | return CL_DROP; |
|---|
| 570 | | } |
|---|
| 571 | | |
|---|
| 572 | | ConsumeLevel ServiceGotek2Dialogue::processDATA_SAMPLE_ADD_GZIP(GotekPacket *gp) |
|---|
| 573 | | { |
|---|
| 574 | | logPF(); |
|---|
| 575 | | return CL_DROP; |
|---|
| 576 | | } |
|---|
| 577 | | |
|---|
| 578 | | |
|---|
| 579 | | |
|---|
| 580 | | /** |
|---|
| 581 | | * Dialogue::handleTimeout(Message *) |
|---|
| 582 | | * as we are not interested in these socket actions |
|---|
| 583 | | * we simply return CL_DROP to show the socket |
|---|
| 584 | | * |
|---|
| 585 | | * @param msg |
|---|
| 586 | | * |
|---|
| 587 | | * @return CL_DROP |
|---|
| 588 | | */ |
|---|
| 589 | | ConsumeLevel ServiceGotek2Dialogue::handleTimeout(Message *msg) |
|---|
| 590 | | { |
|---|
| 591 | | return CL_DROP; |
|---|
| 592 | | } |
|---|
| 593 | | |
|---|
| 594 | | /** |
|---|
| 595 | | * Dialogue::connectionLost(Message *) |
|---|
| 596 | | * as we are not interested in these socket actions |
|---|
| 597 | | * we simply return CL_DROP to show the socket |
|---|
| 598 | | * |
|---|
| 599 | | * @param msg |
|---|
| 600 | | * |
|---|
| 601 | | * @return CL_DROP |
|---|
| 602 | | */ |
|---|
| 603 | | ConsumeLevel ServiceGotek2Dialogue::connectionLost(Message *msg) |
|---|
| 604 | | { |
|---|
| 605 | | return CL_DROP; |
|---|
| 606 | | } |
|---|
| 607 | | |
|---|
| 608 | | /** |
|---|
| 609 | | * Dialogue::connectionShutdown(Message *) |
|---|
| 610 | | * as we are not interested in these socket actions |
|---|
| 611 | | * we simply return CL_DROP to show the socket |
|---|
| 612 | | * |
|---|
| 613 | | * @param msg |
|---|
| 614 | | * |
|---|
| 615 | | * @return CL_DROP |
|---|
| 616 | | */ |
|---|
| 617 | | ConsumeLevel ServiceGotek2Dialogue::connectionShutdown(Message *msg) |
|---|
| 618 | | { |
|---|
| 619 | | return CL_DROP; |
|---|
| 620 | | } |
|---|
| 621 | | |
|---|
| 622 | | |
|---|
| 623 | | bool ServiceGotek2Dialogue::sqlSuccess(SQLResult *sqlresult) |
|---|
| 624 | | { |
|---|
| 625 | | logPF(); |
|---|
| 626 | | |
|---|
| 627 | | |
|---|
| 628 | | if ( m_QueryQueue.size() == 0 ) |
|---|
| 629 | | { |
|---|
| 630 | | logCrit("unexpected Query callback for query %s context %x\n",sqlresult->getQuery().c_str(), sqlresult->getObject()); |
|---|
| 631 | | m_Socket->setStatus(SS_CLOSED); |
|---|
| 632 | | return false; |
|---|
| 633 | | } |
|---|
| 634 | | |
|---|
| 635 | | bool ret = false; |
|---|
| 636 | | |
|---|
| 637 | | switch ( m_ClientType ) |
|---|
| 638 | | { |
|---|
| 639 | | case GCT_LOGIN: |
|---|
| 640 | | ret = sqlSuccessLOGIN(sqlresult); |
|---|
| 641 | | break; |
|---|
| 642 | | |
|---|
| 643 | | case GCT_CONTROL: |
|---|
| 644 | | ret = sqlSuccessCTRL(sqlresult); |
|---|
| 645 | | break; |
|---|
| 646 | | |
|---|
| 647 | | case GCT_DATA: |
|---|
| 648 | | ret = sqlSuccessDATA(sqlresult); |
|---|
| 649 | | break; |
|---|
| 650 | | } |
|---|
| 651 | | |
|---|
| 652 | | m_QueryQueue.pop_front(); |
|---|
| 653 | | return ret; |
|---|
| 654 | | } |
|---|
| 655 | | |
|---|
| 656 | | |
|---|
| 657 | | bool ServiceGotek2Dialogue::sqlSuccessLOGIN(SQLResult *sqlresult) |
|---|
| 658 | | { |
|---|
| 659 | | logPF(); |
|---|
| 660 | | vector< map<string,string> > result = *sqlresult->getResult(); |
|---|
| 661 | | |
|---|
| 662 | | SQLContext *sqlctx = (SQLContext *)sqlresult->getObject(); |
|---|
| 663 | | |
|---|
| 664 | | if ( result.size() == 1 ) |
|---|
| 665 | | { |
|---|
| 666 | | string bkey(result[0]["authkey"].data(), result[0]["authkey"].size()); |
|---|
| 667 | | bkey.append((char *)&m_SessionKey,8); |
|---|
| 668 | | |
|---|
| 669 | | |
|---|
| 670 | | unsigned char hash[64]; |
|---|
| 671 | | g_Library->getUtilities()->sha512((unsigned char *)bkey.c_str(),bkey.size(),hash); |
|---|
| 672 | | |
|---|
| 673 | | if ( memcmp(sqlctx->getString().c_str(),hash,64) == 0 ) |
|---|
| 674 | | { |
|---|
| 675 | | |
|---|
| 676 | | switch ( sqlctx->getCommand() ) |
|---|
| 677 | | { |
|---|
| 678 | | case CTYPE_CTRL: |
|---|
| 679 | | logInfo("Login success (ctrl) :%s\n",m_Username.c_str()); |
|---|
| 680 | | m_ClientType = GCT_CONTROL; |
|---|
| 681 | | break; |
|---|
| 682 | | case CTYPE_DATA: |
|---|
| 683 | | logInfo("Login success (data) :%s\n",m_Username.c_str()); |
|---|
| 684 | | m_ClientType = GCT_DATA; |
|---|
| 685 | | break; |
|---|
| 686 | | default: |
|---|
| 687 | | logCrit("Login error, invalid connection type requested %0x\n",sqlctx->getCommand()); |
|---|
| 688 | | } |
|---|
| 689 | | m_Socket->doWrite(mapEnum(RPL_AUTHORIZED),1); |
|---|
| 690 | | |
|---|
| 691 | | }else |
|---|
| 692 | | { |
|---|
| 693 | | // invalid login |
|---|
| 694 | | logInfo("Login failed: %s\n",m_Username.c_str()); |
|---|
| 695 | | m_Socket->doWrite(mapEnum(RPL_DENIED),1); |
|---|
| 696 | | m_Socket->setStatus(SS_CLEANQUIT); |
|---|
| 697 | | } |
|---|
| 698 | | |
|---|
| 699 | | } else |
|---|
| 700 | | { |
|---|
| 701 | | // invalid login |
|---|
| 702 | | logInfo("Login failed: %s\n",m_Username.c_str()); |
|---|
| 703 | | m_Socket->doWrite(mapEnum(RPL_DENIED),1); |
|---|
| 704 | | m_Socket->setStatus(SS_CLEANQUIT); |
|---|
| 705 | | } |
|---|
| 706 | | |
|---|
| 707 | | delete sqlctx; |
|---|
| 708 | | |
|---|
| 709 | | |
|---|
| 710 | | return true; |
|---|
| 711 | | } |
|---|
| 712 | | |
|---|
| 713 | | bool ServiceGotek2Dialogue::sqlSuccessCTRL(SQLResult *sqlresult) |
|---|
| 714 | | { |
|---|
| 715 | | logPF(); |
|---|
| 716 | | bool retval=false; |
|---|
| 717 | | SQLContext *sqlctx = (SQLContext *)sqlresult->getObject(); |
|---|
| 718 | | switch (sqlctx->getCommand()) |
|---|
| 719 | | { |
|---|
| 720 | | case CCMD_CHECK_PRESENCE: |
|---|
| 721 | | retval = sqlSuccessCTRL_CHECK_PRESENCE(sqlresult); |
|---|
| 722 | | break; |
|---|
| 723 | | |
|---|
| 724 | | case CCMD_STORE_MAGNET: |
|---|
| 725 | | retval = sqlSuccessCTRL_STORE_MAGNET(sqlresult); |
|---|
| 726 | | break; |
|---|
| 727 | | |
|---|
| 728 | | case CCMD_REPORT_INSTANCE: |
|---|
| 729 | | retval = sqlSuccessCTRL_REPORT_INSTANCE(sqlresult); |
|---|
| 730 | | break; |
|---|
| 731 | | } |
|---|
| 732 | | |
|---|
| 733 | | delete sqlctx; |
|---|
| 734 | | return true; |
|---|
| 735 | | } |
|---|
| 736 | | |
|---|
| 737 | | |
|---|
| 738 | | bool ServiceGotek2Dialogue::sqlSuccessCTRL_CHECK_PRESENCE(SQLResult *sqlresult) |
|---|
| 739 | | { |
|---|
| 740 | | logPF(); |
|---|
| 741 | | vector< map<string,string> > result = *sqlresult->getResult(); |
|---|
| 742 | | |
|---|
| 743 | | if (result.size() >= 1) |
|---|
| 744 | | { |
|---|
| 745 | | m_Socket->doWrite(mapEnum(RPL_PRESENT),1); |
|---|
| 746 | | }else |
|---|
| 747 | | { |
|---|
| 748 | | m_Socket->doWrite(mapEnum(RPL_NPRESENT),1); |
|---|
| 749 | | } |
|---|
| 750 | | return true; |
|---|
| 751 | | } |
|---|
| 752 | | |
|---|
| 753 | | bool ServiceGotek2Dialogue::sqlSuccessCTRL_STORE_MAGNET(SQLResult *sqlresult) |
|---|
| 754 | | { |
|---|
| 755 | | logPF(); |
|---|
| 756 | | m_Socket->doWrite(mapEnum(RPL_ACK),1); |
|---|
| 757 | | return true; |
|---|
| 758 | | } |
|---|
| 759 | | |
|---|
| 760 | | bool ServiceGotek2Dialogue::sqlSuccessCTRL_REPORT_INSTANCE(SQLResult *sqlresult) |
|---|
| 761 | | { |
|---|
| 762 | | logPF(); |
|---|
| 763 | | m_Socket->doWrite(mapEnum(RPL_ACK),1); |
|---|
| 764 | | return true; |
|---|
| 765 | | } |
|---|
| 766 | | |
|---|
| 767 | | |
|---|
| 768 | | |
|---|
| 769 | | |
|---|
| 770 | | |
|---|
| 771 | | |
|---|
| 772 | | |
|---|
| 773 | | bool ServiceGotek2Dialogue::sqlSuccessDATA(SQLResult *sqlresult) |
|---|
| 774 | | { |
|---|
| 775 | | logPF(); |
|---|
| 776 | | |
|---|
| 777 | | return true; |
|---|
| 778 | | } |
|---|
| 779 | | |
|---|
| 780 | | |
|---|
| 781 | | |
|---|
| 782 | | |
|---|
| 783 | | |
|---|
| 784 | | |
|---|
| 785 | | bool ServiceGotek2Dialogue::sqlFailure(SQLResult *sqlresult) |
|---|
| 786 | | { |
|---|
| 787 | | logPF(); |
|---|
| 788 | | |
|---|
| 789 | | if ( m_QueryQueue.size() == 0 ) |
|---|
| 790 | | { |
|---|
| 791 | | logCrit("unexpected Query callback for query %s\n",sqlresult->getQuery().c_str()); |
|---|
| 792 | | m_Socket->setStatus(SS_CLOSED); |
|---|
| 793 | | return false; |
|---|
| 794 | | } |
|---|
| 795 | | |
|---|
| 796 | | bool ret = true; |
|---|
| 797 | | |
|---|
| 798 | | switch ( m_ClientType ) |
|---|
| 799 | | { |
|---|
| 800 | | case GCT_LOGIN: |
|---|
| 801 | | ret = sqlFailureLOGIN(sqlresult); |
|---|
| 802 | | break; |
|---|
| 803 | | |
|---|
| 804 | | case GCT_CONTROL: |
|---|
| 805 | | ret = sqlFailureCTRL(sqlresult); |
|---|
| 806 | | break; |
|---|
| 807 | | |
|---|
| 808 | | case GCT_DATA: |
|---|
| 809 | | ret = sqlFailureDATA(sqlresult); |
|---|
| 810 | | break; |
|---|
| 811 | | } |
|---|
| 812 | | |
|---|
| 813 | | m_QueryQueue.pop_front(); |
|---|
| 814 | | return ret; |
|---|
| 815 | | } |
|---|
| 816 | | |
|---|
| 817 | | |
|---|
| 818 | | |
|---|
| 819 | | bool ServiceGotek2Dialogue::sqlFailureLOGIN(SQLResult *sqlresult) |
|---|
| 820 | | { |
|---|
| 821 | | logPF(); |
|---|
| 822 | | |
|---|
| 823 | | return true; |
|---|
| 824 | | } |
|---|
| 825 | | |
|---|
| 826 | | |
|---|
| 827 | | bool ServiceGotek2Dialogue::sqlFailureCTRL(SQLResult *sqlresult) |
|---|
| 828 | | { |
|---|
| 829 | | logPF(); |
|---|
| 830 | | |
|---|
| 831 | | bool retval=false; |
|---|
| 832 | | |
|---|
| 833 | | SQLContext *sqlctx = (SQLContext *)sqlresult->getObject(); |
|---|
| 834 | | switch ( sqlctx->getCommand() ) |
|---|
| 835 | | { |
|---|
| 836 | | case CCMD_STORE_MAGNET: |
|---|
| 837 | | retval = sqlFailureCTRL_STORE_MAGNET(sqlresult); |
|---|
| 838 | | break; |
|---|
| 839 | | |
|---|
| 840 | | case CCMD_REPORT_INSTANCE: |
|---|
| 841 | | retval = sqlFailureCTRL_REPORT_INSTANCE(sqlresult); |
|---|
| 842 | | break; |
|---|
| 843 | | } |
|---|
| 844 | | |
|---|
| 845 | | delete sqlctx; |
|---|
| 846 | | |
|---|
| 847 | | return retval; |
|---|
| 848 | | } |
|---|
| 849 | | |
|---|
| 850 | | bool ServiceGotek2Dialogue::sqlFailureCTRL_STORE_MAGNET(SQLResult *sqlresult) |
|---|
| 851 | | { |
|---|
| 852 | | logPF(); |
|---|
| 853 | | m_Socket->doWrite(mapEnum(RPL_NACK),1); |
|---|
| 854 | | return true; |
|---|
| 855 | | } |
|---|
| 856 | | |
|---|
| 857 | | bool ServiceGotek2Dialogue::sqlFailureCTRL_REPORT_INSTANCE(SQLResult *sqlresult) |
|---|
| 858 | | { |
|---|
| 859 | | logPF(); |
|---|
| 860 | | m_Socket->doWrite(mapEnum(RPL_NACK),1); |
|---|
| 861 | | return true; |
|---|
| 862 | | } |
|---|
| 863 | | |
|---|
| 864 | | |
|---|
| 865 | | bool ServiceGotek2Dialogue::sqlFailureDATA(SQLResult *sqlresult) |
|---|
| 866 | | { |
|---|
| 867 | | logPF(); |
|---|
| 868 | | |
|---|
| 869 | | return true; |
|---|