catalinux / Conn (public) (License: LGPLv2) (since 2016-03-01) (hash sha1)
Net library for easy building ipv4/ipv6 network daemons/clients
List of commits:
Subject Hash Author Date (UTC)
Store also local address for incoming connections. 0548ce6434185cdd36e110c61315b4cb21849666 Catalin(ux) M. BOIE 2009-08-25 18:15:46
Added possibility to shutdown blackhole_s server by typing 'quit'. 5fd60900809e1a2d7554aa7fa93ce83b29214de0 Catalin(ux) M. BOIE 2009-08-25 17:54:27
Cosmetic changes. 7099dd49a270b9f4ecc0cb2e55254bef671202e5 Catalin(ux) M. BOIE 2009-08-25 17:54:15
Improved status output. 1ff597059bbb208b56ad18bf8324fae5b63950a2 Catalin(ux) M. BOIE 2009-08-25 17:53:44
Conn_type_* becomes CONN_TYPE_*. b284a20cc5430042cc662edc4d121c7f18cb3569 Catalin(ux) M. BOIE 2009-08-25 17:52:51
Improved status logging. 54fea00d8f16127244fd15b209c24f606adb20b3 Catalin(ux) M. BOIE 2009-08-25 17:33:14
Added Conn_strcasestr for case insensitive search in buffer. ca14b37b2a1f23887ad12fed729a3dd0ff253443 Catalin(ux) M. BOIE 2009-08-24 17:18:24
Improved ntime example. b63de9b82ffab1c0d759571a40f1d72f9b8df927 Catalin(ux) M. BOIE 2009-08-24 17:09:21
Removed unused includes. 8af81a4c311caa7d738000a5208d01d7620d1040 Catalin(ux) M. BOIE 2009-08-21 18:57:33
Improved blackhole example. 2fd7ff181a412f4ba060b0e89b97acdf89a8fb88 Catalin(ux) M. BOIE 2009-08-21 18:03:22
Fixed connections to outside. Still, it is a little mess there. 417ccd4a48508a810377676658d51c5103168472 Catalin(ux) M. BOIE 2009-08-21 17:42:37
addr and bind_addr are not pointers! Corrected them. e1deeb765500ee079802c2cd6543f9c9496d8f9b Catalin(ux) M. BOIE 2009-08-21 16:49:24
Exported _alloc and _commit functions. 9a3159e89eff020cfb75b9eec49a45a637a6da57 Catalin(ux) M. BOIE 2009-08-21 16:39:27
Added blackhole example. 8a7ac49b018ad65ba386f8a50725745127b4cbd2 Catalin(ux) M. BOIE 2009-08-21 15:54:55
TODO in/out. fdcfbf9e18ed5fbe0135b9aa702e09432fa71e93 Catalin(ux) M. BOIE 2009-08-21 15:53:05
First chunk of generic socket handling. b9a488ba615c4322b5d116a29919f11fd476b200 Catalin(ux) M. BOIE 2009-08-21 15:50:45
Added ntime example (returns CLOCK_REALTIME as fast as it can). e2fa318caf3e9aea09a853ab2b4af4b5a2cc8261 Catalin(ux) M. BOIE 2009-08-20 15:41:20
TODO ins and outs. 66a987be5d8e08ef6fe1ce0c056b8c3acd65bdb7 Catalin(ux) M. BOIE 2009-08-20 15:36:14
Cosmetic change. 5dab6539af2ca97f3f3f9b55e20be7d6f423829e Catalin(ux) M. BOIE 2009-08-20 15:34:01
Abort if current slot is in state FREE. It must not happen. 14dc9f444309cddd46996a47277cefe4eec77db5 Catalin(ux) M. BOIE 2009-08-20 15:33:31
Commit 0548ce6434185cdd36e110c61315b4cb21849666 - Store also local address for incoming connections.
Signed-off-by: Catalin(ux) M. BOIE <catab@embedromix.ro>
Author: Catalin(ux) M. BOIE
Author date (UTC): 2009-08-25 18:15
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2009-09-02 15:42
Parent(s): 5fd60900809e1a2d7554aa7fa93ce83b29214de0
Signing key:
Tree: 60bc961f4b6b9078910cbb8961967ef7c4a7592a
File Lines added Lines deleted
Conn.c 26 6
Conn_engine_core.c 4 2
File Conn.c changed (mode: 100644) (index 60b95db..a8e3c53)
... ... struct Conn *Conn_connect(const int domain, const int type, const char *addr,
714 714 static void Conn_accept(struct Conn *C) static void Conn_accept(struct Conn *C)
715 715 { {
716 716 int fd, err; int fd, err;
717 struct sockaddr *pca;
718 struct sockaddr_in ca4;
719 struct sockaddr_in6 ca6;
720 socklen_t cax_len;
717 struct sockaddr *pca, *psa;
718 struct sockaddr_in ca4, sa4;
719 struct sockaddr_in6 ca6, sa6;
720 socklen_t cax_len, sax_len;
721 721 struct Conn *X; struct Conn *X;
722 722 unsigned int Cslot; unsigned int Cslot;
723 723
724 Log(10, "Accepting a connection via %s/%d, type %s, domain %s.\n",
725 C->bind_addr, C->bind_port, Conn_type(C), Conn_domain(C));
724 Log(10, "Accepting a connection via %s/%d, type %s, domain %s"
725 ", protocol %s.\n",
726 C->bind_addr, C->bind_port, Conn_type(C), Conn_domain(C),
727 Conn_get_socket_protocol(C));
726 728
727 729 switch(C->sock_domain) { switch(C->sock_domain) {
728 730 case PF_INET: case PF_INET:
729 731 pca = (struct sockaddr *) &ca4; pca = (struct sockaddr *) &ca4;
730 732 cax_len = sizeof(ca4); cax_len = sizeof(ca4);
733 psa = (struct sockaddr *) &sa4;
734 sax_len = sizeof(sa4);
731 735 break; break;
732 736
733 737 case PF_INET6: case PF_INET6:
734 738 pca = (struct sockaddr *) &ca6; pca = (struct sockaddr *) &ca6;
735 739 cax_len = sizeof(ca6); cax_len = sizeof(ca6);
740 psa = (struct sockaddr *) &sa6;
741 sax_len = sizeof(sa6);
736 742 break; break;
737 743
738 744 default: default:
 
... ... static void Conn_accept(struct Conn *C)
765 771 return; return;
766 772 } }
767 773
774 err = getsockname(fd, psa, &sax_len);
775
768 776 switch (C->sock_domain) { switch (C->sock_domain) {
769 777 case PF_INET: case PF_INET:
778 /* remote */
770 779 inet_ntop(C->sock_domain, &ca4.sin_addr, X->addr, sizeof(X->addr)); inet_ntop(C->sock_domain, &ca4.sin_addr, X->addr, sizeof(X->addr));
771 780 X->port = ntohs(ca4.sin_port); X->port = ntohs(ca4.sin_port);
781 /* local */
782 if (err == 0) {
783 inet_ntop(C->sock_domain, &sa4.sin_addr, X->bind_addr, sizeof(X->bind_addr));
784 X->bind_port = ntohs(sa4.sin_port);
785 }
772 786 break; break;
773 787
774 788 case PF_INET6: case PF_INET6:
789 /* remote */
775 790 inet_ntop(C->sock_domain, &ca6.sin6_addr, X->addr, sizeof(X->addr)); inet_ntop(C->sock_domain, &ca6.sin6_addr, X->addr, sizeof(X->addr));
776 791 X->port = ntohs(ca6.sin6_port); X->port = ntohs(ca6.sin6_port);
792 /* local */
793 if (err == 0) {
794 inet_ntop(C->sock_domain, &sa6.sin6_addr, X->addr, sizeof(X->addr));
795 X->port = ntohs(sa6.sin6_port);
796 }
777 797 break; break;
778 798 } }
779 799
File Conn_engine_core.c changed (mode: 100644) (index 77ef865..8f9b3db)
... ... char *Conn_status_slot(struct Conn *C)
448 448 local_addr = C->bind_addr; local_addr = C->bind_addr;
449 449 local_port = C->bind_port; local_port = C->bind_port;
450 450 } else if (C->type == CONN_TYPE_P2P) { } else if (C->type == CONN_TYPE_P2P) {
451 local_addr = C->bind_addr;
452 local_port = C->bind_port;
451 if (strlen(C->bind_addr) > 0) {
452 local_addr = C->bind_addr;
453 local_port = C->bind_port;
454 }
453 455 remote_addr = C->addr; remote_addr = C->addr;
454 456 remote_port = C->port; remote_port = C->port;
455 457 } }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/Conn

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/Conn

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/Conn

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main