+ rh->protocol = 0;
+ rh->service = 0;
+ ret = GNUNET_strndup (rp, len);
+ /* If we have labels starting with underscore with label on
+ * the right (SRV/DANE/BOX case), determine port/protocol;
+ * The format of `rh->name` must be "_PORT._PROTOCOL".
+ */
+ if ( ('_' == rh->name[0]) &&
+ (NULL != (dot = memrchr (rh->name,
+ (int) '.',
+ rh->name_resolution_pos))) &&
+ ('_' == dot[1]) &&
+ (NULL == memrchr (rh->name,
+ (int) '.',
+ dot - rh->name)) )
+ {
+ srv_name = GNUNET_strndup (&rh->name[1],
+ (dot - rh->name) - 1);
+ proto_name = GNUNET_strndup (&dot[2],
+ rh->name_resolution_pos - (dot - rh->name) - 1);
+ rh->name_resolution_pos = 0;
+ pe = getprotobyname (proto_name);
+ if (NULL == pe)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Protocol `%s' unknown, skipping labels.\n"),
+ proto_name);
+ GNUNET_free (proto_name);
+ GNUNET_free (srv_name);
+ return ret;
+ }
+ se = getservbyname (srv_name,
+ proto_name);
+ if (NULL == se)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Service `%s' unknown for protocol `%s', skipping labels.\n"),
+ srv_name,
+ proto_name);
+ GNUNET_free (proto_name);
+ GNUNET_free (srv_name);
+ return ret;
+ }
+ rh->protocol = pe->p_proto;
+ rh->service = se->s_port;
+ }
+ return ret;