aboutsummaryrefslogtreecommitdiff
path: root/src/service/gns/gnunet-service-gns_resolver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/gns/gnunet-service-gns_resolver.c')
-rw-r--r--src/service/gns/gnunet-service-gns_resolver.c94
1 files changed, 60 insertions, 34 deletions
diff --git a/src/service/gns/gnunet-service-gns_resolver.c b/src/service/gns/gnunet-service-gns_resolver.c
index 538f95aa1..3f21a3b8c 100644
--- a/src/service/gns/gnunet-service-gns_resolver.c
+++ b/src/service/gns/gnunet-service-gns_resolver.c
@@ -580,6 +580,46 @@ timeout_resolution (void *cls)
580 580
581 581
582/** 582/**
583 * Function called to receive the protocol number for a service.
584 *
585 * @param name name of the protocol
586*/
587static struct protoent *
588resolver_getprotobyname(const char *name) {
589 struct protoent *pe = getprotobyname(name);
590 if (pe == NULL && strcmp(name, "trust") == 0) {
591 pe = GNUNET_new(struct protoent);
592 pe->p_name = "trust";
593 pe->p_proto = 242;
594 }
595 return pe;
596}
597
598
599/**
600 * Function called to receive the port number for a service.
601 *
602 * @param name name of the service
603 * @param proto name of the protocol
604*/
605static struct servent *resolver_getservbyname(const char *name, const char *proto){
606 struct servent *se = getservbyname(name, proto);
607 if (se == NULL && strcmp(proto, "trust") == 0) {
608 if (strcmp(name, "trustlist") == 0) {
609 se = GNUNET_new(struct servent);
610 se->s_name = "trustlist";
611 se->s_port = htons(1002);
612 } else if (strcmp(name, "scheme") == 0) {
613 se = GNUNET_new(struct servent);
614 se->s_name = "scheme";
615 se->s_port = htons(1003);
616 }
617 }
618 return se;
619}
620
621
622/**
583 * Get the next, rightmost label from the name that we are trying to resolve, 623 * Get the next, rightmost label from the name that we are trying to resolve,
584 * and update the resolution position accordingly. Labels usually consist 624 * and update the resolution position accordingly. Labels usually consist
585 * of up to 63 characters without a period ("."); however, we use a special 625 * of up to 63 characters without a period ("."); however, we use a special
@@ -662,47 +702,33 @@ resolver_lookup_get_next_label (struct GNS_ResolverHandle *rh)
662 rh->name_resolution_pos - (dot - rh->name) 702 rh->name_resolution_pos - (dot - rh->name)
663 - 2); 703 - 2);
664 rh->name_resolution_pos = 0; 704 rh->name_resolution_pos = 0;
665 pe = getprotobyname (proto_name); 705 pe = resolver_getprotobyname (proto_name);
666 if (NULL == pe) 706 if (NULL == pe)
667 { 707 {
668 if (strcmp(proto_name, "trust") == 0){ 708 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
669 pe = GNUNET_new(struct protoent); 709 _ ("Protocol `%s' unknown, skipping labels.\n"),
670 pe->p_name = "trust"; 710 proto_name);
671 pe->p_proto = 242; 711 GNUNET_free (proto_name);
672 } else { 712 GNUNET_free (srv_name);
673 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 713 return ret;
674 _ ("Protocol `%s' unknown, skipping labels.\n"),
675 proto_name);
676 GNUNET_free (proto_name);
677 GNUNET_free (srv_name);
678 return ret;
679 }
680 } 714 }
681 se = getservbyname (srv_name, 715 se = resolver_getservbyname (srv_name,
682 proto_name); 716 proto_name);
683 if (NULL == se) 717 if (NULL == se)
684 { 718 {
685 if(strcmp(proto_name,"trust") == 0 && (strcmp(srv_name,"trustlist") == 0 || strcmp(srv_name,"scheme") == 0)){ 719 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
686 if(strcmp(srv_name,"trustlist") == 0) { 720 _ (
687 rh->service = 1002; 721 "Service `%s' unknown for protocol `%s', trying as number.\n"),
688 } else if (strcmp(srv_name,"scheme") == 0) { 722 srv_name,
689 rh->service = 1003; 723 proto_name);
690 } 724 if (1 != sscanf (srv_name, "%u", &rh->service))
691 } else { 725 {
692 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 726 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
693 _ ( 727 _ ("Service `%s' not a port, skipping service labels.\n"),
694 "Service `%s' unknown for protocol `%s', trying as number.\n"), 728 srv_name);
695 srv_name, 729 GNUNET_free (proto_name);
696 proto_name); 730 GNUNET_free (srv_name);
697 if (1 != sscanf (srv_name, "%u", &rh->service)) 731 return ret;
698 {
699 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
700 _ ("Service `%s' not a port, skipping service labels.\n"),
701 srv_name);
702 GNUNET_free (proto_name);
703 GNUNET_free (srv_name);
704 return ret;
705 }
706 } 732 }
707 } 733 }
708 else 734 else