aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/libhicnctrl
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2022-10-07 15:54:49 +0000
committerGerrit Code Review <gerrit@fd.io>2022-10-07 15:54:49 +0000
commit0b65acf82a4a1199220d4473d426a9da221e9629 (patch)
tree650f6fe445c636a923bf07b4b8d48c90c2b1a915 /ctrl/libhicnctrl
parent03fb1444ad41d254469b4749382d1bf2b7cc48da (diff)
parenta61398ad90acdfa4ea0ac03f3d2b9bcbfd7a6dd3 (diff)
Merge "refactor(hicn-light): cleanup and optimizations to UDP socket face"
Diffstat (limited to 'ctrl/libhicnctrl')
-rw-r--r--ctrl/libhicnctrl/src/api_private.h12
-rw-r--r--ctrl/libhicnctrl/src/commands/command_listener.c7
-rw-r--r--ctrl/libhicnctrl/src/modules/hicn_light.c5
-rw-r--r--ctrl/libhicnctrl/src/modules/hicn_light/connection.c8
-rw-r--r--ctrl/libhicnctrl/src/modules/hicn_light/face.c12
-rw-r--r--ctrl/libhicnctrl/src/modules/hicn_light/face.h2
-rw-r--r--ctrl/libhicnctrl/src/objects/subscription.c2
7 files changed, 16 insertions, 32 deletions
diff --git a/ctrl/libhicnctrl/src/api_private.h b/ctrl/libhicnctrl/src/api_private.h
index 53be809da..2f483ad2d 100644
--- a/ctrl/libhicnctrl/src/api_private.h
+++ b/ctrl/libhicnctrl/src/api_private.h
@@ -75,16 +75,4 @@ typedef struct hc_sock_impl_s hc_sock_impl_t;
int hc_data_ensure_available(hc_data_t *data, size_t count);
u8 *hc_data_get_next(hc_data_t *data);
-int hc_listener_to_face(const hc_listener_t *listener, hc_face_t *face);
-
-int hc_connection_to_face(const hc_connection_t *connection, hc_face_t *face);
-
-int hc_face_to_listener(const hc_face_t *face, hc_listener_t *listener);
-
-int hc_connection_to_local_listener(const hc_connection_t *connection,
- hc_listener_t *listener);
-
-int hc_face_to_connection(const hc_face_t *face, hc_connection_t *connection,
- bool generate_name);
-
#endif // HICN_API_PRIVATE_H
diff --git a/ctrl/libhicnctrl/src/commands/command_listener.c b/ctrl/libhicnctrl/src/commands/command_listener.c
index bba4f4541..c11742bba 100644
--- a/ctrl/libhicnctrl/src/commands/command_listener.c
+++ b/ctrl/libhicnctrl/src/commands/command_listener.c
@@ -68,8 +68,13 @@ int on_listener_create(hc_listener_t* listener) {
case FACE_TYPE_HICN:
listener->type = FACE_TYPE_HICN_LISTENER;
break;
- default:
+ case FACE_TYPE_UDP_LISTENER:
+ case FACE_TYPE_TCP_LISTENER:
+ case FACE_TYPE_HICN_LISTENER:
break;
+ case FACE_TYPE_UNDEFINED:
+ case FACE_TYPE_N:
+ return -1;
}
return 0;
}
diff --git a/ctrl/libhicnctrl/src/modules/hicn_light.c b/ctrl/libhicnctrl/src/modules/hicn_light.c
index 379cd2fa9..9c6722975 100644
--- a/ctrl/libhicnctrl/src/modules/hicn_light.c
+++ b/ctrl/libhicnctrl/src/modules/hicn_light.c
@@ -919,9 +919,8 @@ NEXT:
if (hc_connection_to_local_listener(&object->connection,
&listener.listener) < 0) {
ERROR(
- "[hicnlight_prepare_connection_create] Could not convert face "
- "to "
- "local listener.");
+ "[hicnlight_prepare_connection_create] Could not "
+ "convert connection to local listener.");
return -1;
}
hc_request_set_state(current_request,
diff --git a/ctrl/libhicnctrl/src/modules/hicn_light/connection.c b/ctrl/libhicnctrl/src/modules/hicn_light/connection.c
index 83f7a2e27..d5648d794 100644
--- a/ctrl/libhicnctrl/src/modules/hicn_light/connection.c
+++ b/ctrl/libhicnctrl/src/modules/hicn_light/connection.c
@@ -95,22 +95,22 @@ static int hicnlight_connection_parse(const uint8_t *buffer, size_t size,
}
if (!IS_VALID_ADDRESS(item->local_address)) {
- ERROR("[hc_connection_parse] Invalid address received");
+ ERROR("[hc_connection_parse] Invalid local address received");
return -1;
}
if (!IS_VALID_PORT(ntohs(item->local_port))) {
- ERROR("[hc_connection_parse] Invalid port received");
+ ERROR("[hc_connection_parse] Invalid local port received");
return -1;
}
if (!IS_VALID_ADDRESS(item->remote_address)) {
- ERROR("[hc_connection_parse] Invalid address received");
+ ERROR("[hc_connection_parse] Invalid remote address received");
return -1;
}
if (!IS_VALID_PORT(ntohs(item->remote_port))) {
- ERROR("[hc_connection_parse] Invalid port received");
+ ERROR("[hc_connection_parse] Invalid remote port received");
return -1;
}
diff --git a/ctrl/libhicnctrl/src/modules/hicn_light/face.c b/ctrl/libhicnctrl/src/modules/hicn_light/face.c
index 46adf633d..4dcd96191 100644
--- a/ctrl/libhicnctrl/src/modules/hicn_light/face.c
+++ b/ctrl/libhicnctrl/src/modules/hicn_light/face.c
@@ -161,15 +161,5 @@ int hc_face_to_connection(const hc_face_t *face, hc_connection_t *connection,
}
int hc_face_to_listener(const hc_face_t *face, hc_listener_t *listener) {
- switch (face->type) {
- case FACE_TYPE_HICN_LISTENER:
- break;
- case FACE_TYPE_TCP_LISTENER:
- break;
- case FACE_TYPE_UDP_LISTENER:
- break;
- default:
- return -1;
- }
- return -1; /* XXX Not implemented */
+ return -99; /* XXX Not implemented */
}
diff --git a/ctrl/libhicnctrl/src/modules/hicn_light/face.h b/ctrl/libhicnctrl/src/modules/hicn_light/face.h
index 9e1cd48c2..6f202b4ce 100644
--- a/ctrl/libhicnctrl/src/modules/hicn_light/face.h
+++ b/ctrl/libhicnctrl/src/modules/hicn_light/face.h
@@ -4,6 +4,8 @@
#include <hicn/ctrl/objects/connection.h>
#include <hicn/ctrl/objects/face.h>
+int hc_connection_to_face(const hc_connection_t *connection, hc_face_t *face);
+
int hc_face_from_connection(const hc_connection_t *connection, hc_face_t *face);
int hc_face_to_connection(const hc_face_t *face, hc_connection_t *connection,
diff --git a/ctrl/libhicnctrl/src/objects/subscription.c b/ctrl/libhicnctrl/src/objects/subscription.c
index 087e42ffb..8db55660d 100644
--- a/ctrl/libhicnctrl/src/objects/subscription.c
+++ b/ctrl/libhicnctrl/src/objects/subscription.c
@@ -55,7 +55,7 @@ int _hc_subscription_cmp(const hc_object_t *object1,
/* /!\ Please update constants in header file upon changes */
int hc_subscription_snprintf(char *s, size_t size,
const hc_subscription_t *subscription) {
- return -1;
+ return -99; /* Not implemented */
}
int _hc_subscription_snprintf(char *s, size_t size, const hc_object_t *object) {
id='n500' href='#n500'>500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866