diff options
Diffstat (limited to 'src/resolve/resolved-varlink.c')
-rw-r--r-- | src/resolve/resolved-varlink.c | 258 |
1 files changed, 129 insertions, 129 deletions
diff --git a/src/resolve/resolved-varlink.c b/src/resolve/resolved-varlink.c index 3d109026d2..b34d035d96 100644 --- a/src/resolve/resolved-varlink.c +++ b/src/resolve/resolved-varlink.c @@ -42,25 +42,25 @@ static int reply_query_state(DnsQuery *q) { switch (q->state) { case DNS_TRANSACTION_NO_SERVERS: - return varlink_error(q->varlink_request, "io.systemd.Resolve.NoNameServers", NULL); + return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NoNameServers", NULL); case DNS_TRANSACTION_TIMEOUT: - return varlink_error(q->varlink_request, "io.systemd.Resolve.QueryTimedOut", NULL); + return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.QueryTimedOut", NULL); case DNS_TRANSACTION_ATTEMPTS_MAX_REACHED: - return varlink_error(q->varlink_request, "io.systemd.Resolve.MaxAttemptsReached", NULL); + return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.MaxAttemptsReached", NULL); case DNS_TRANSACTION_INVALID_REPLY: - return varlink_error(q->varlink_request, "io.systemd.Resolve.InvalidReply", NULL); + return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.InvalidReply", NULL); case DNS_TRANSACTION_ERRNO: - return varlink_error_errno(q->varlink_request, q->answer_errno); + return sd_varlink_error_errno(q->varlink_request, q->answer_errno); case DNS_TRANSACTION_ABORTED: - return varlink_error(q->varlink_request, "io.systemd.Resolve.QueryAborted", NULL); + return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.QueryAborted", NULL); case DNS_TRANSACTION_DNSSEC_FAILED: - return varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSSECValidationFailed", + return sd_varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSSECValidationFailed", SD_JSON_BUILD_PAIR("result", SD_JSON_BUILD_STRING(dnssec_result_to_string(q->answer_dnssec_result))), SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0, "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)), @@ -68,28 +68,28 @@ static int reply_query_state(DnsQuery *q) { "extendedDNSErrorMessage", SD_JSON_BUILD_STRING(q->answer_ede_msg))); case DNS_TRANSACTION_NO_TRUST_ANCHOR: - return varlink_error(q->varlink_request, "io.systemd.Resolve.NoTrustAnchor", NULL); + return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NoTrustAnchor", NULL); case DNS_TRANSACTION_RR_TYPE_UNSUPPORTED: - return varlink_error(q->varlink_request, "io.systemd.Resolve.ResourceRecordTypeUnsupported", NULL); + return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.ResourceRecordTypeUnsupported", NULL); case DNS_TRANSACTION_NETWORK_DOWN: - return varlink_error(q->varlink_request, "io.systemd.Resolve.NetworkDown", NULL); + return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NetworkDown", NULL); case DNS_TRANSACTION_NO_SOURCE: - return varlink_error(q->varlink_request, "io.systemd.Resolve.NoSource", NULL); + return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NoSource", NULL); case DNS_TRANSACTION_STUB_LOOP: - return varlink_error(q->varlink_request, "io.systemd.Resolve.StubLoop", NULL); + return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.StubLoop", NULL); case DNS_TRANSACTION_NOT_FOUND: /* We return this as NXDOMAIN. This is only generated when a host doesn't implement LLMNR/TCP, and we * thus quickly know that we cannot resolve an in-addr.arpa or ip6.arpa address. */ - return varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSError", + return sd_varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSError", SD_JSON_BUILD_PAIR("rcode", SD_JSON_BUILD_INTEGER(DNS_RCODE_NXDOMAIN))); case DNS_TRANSACTION_RCODE_FAILURE: - return varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSError", + return sd_varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSError", SD_JSON_BUILD_PAIR("rcode", SD_JSON_BUILD_INTEGER(q->answer_rcode)), SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0, "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)), @@ -105,13 +105,13 @@ static int reply_query_state(DnsQuery *q) { } } -static void vl_on_disconnect(VarlinkServer *s, Varlink *link, void *userdata) { +static void vl_on_disconnect(sd_varlink_server *s, sd_varlink *link, void *userdata) { DnsQuery *q; assert(s); assert(link); - q = varlink_get_userdata(link); + q = sd_varlink_get_userdata(link); if (!q) return; @@ -122,15 +122,15 @@ static void vl_on_disconnect(VarlinkServer *s, Varlink *link, void *userdata) { dns_query_complete(q, DNS_TRANSACTION_ABORTED); } -static void vl_on_notification_disconnect(VarlinkServer *s, Varlink *link, void *userdata) { +static void vl_on_notification_disconnect(sd_varlink_server *s, sd_varlink *link, void *userdata) { Manager *m = ASSERT_PTR(userdata); assert(s); assert(link); - Varlink *removed_link = set_remove(m->varlink_subscription, link); + sd_varlink *removed_link = set_remove(m->varlink_subscription, link); if (removed_link) { - varlink_unref(removed_link); + sd_varlink_unref(removed_link); log_debug("%u monitor clients remain active", set_size(m->varlink_subscription)); } } @@ -247,7 +247,7 @@ static void vl_method_resolve_hostname_complete(DnsQuery *query) { r = dns_query_process_cname_many(q); if (r == -ELOOP) { - r = varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL); + r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL); goto finish; } if (r < 0) @@ -265,7 +265,7 @@ static void vl_method_resolve_hostname_complete(DnsQuery *query) { goto finish; if (sd_json_variant_is_blank_object(array)) { - r = varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL); + r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL); goto finish; } @@ -274,7 +274,7 @@ static void vl_method_resolve_hostname_complete(DnsQuery *query) { if (r < 0) goto finish; - r = varlink_replybo( + r = sd_varlink_replybo( q->varlink_request, SD_JSON_BUILD_PAIR("addresses", SD_JSON_BUILD_VARIANT(array)), SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(normalized)), @@ -282,11 +282,11 @@ static void vl_method_resolve_hostname_complete(DnsQuery *query) { finish: if (r < 0) { log_full_errno(ERRNO_IS_DISCONNECT(r) ? LOG_DEBUG : LOG_ERR, r, "Failed to send hostname reply: %m"); - r = varlink_error_errno(q->varlink_request, r); + r = sd_varlink_error_errno(q->varlink_request, r); } } -static int parse_as_address(Varlink *link, LookupParameters *p) { +static int parse_as_address(sd_varlink *link, LookupParameters *p) { _cleanup_free_ char *canonical = NULL; int r, ff, parsed_ifindex, ifindex; union in_addr_union parsed; @@ -302,7 +302,7 @@ static int parse_as_address(Varlink *link, LookupParameters *p) { /* Make sure the data we parsed matches what is requested */ if ((p->family != AF_UNSPEC && ff != p->family) || (p->ifindex > 0 && parsed_ifindex > 0 && parsed_ifindex != p->ifindex)) - return varlink_error(link, "io.systemd.Resolve.NoSuchResourceRecord", NULL); + return sd_varlink_error(link, "io.systemd.Resolve.NoSuchResourceRecord", NULL); ifindex = parsed_ifindex > 0 ? parsed_ifindex : p->ifindex; @@ -311,7 +311,7 @@ static int parse_as_address(Varlink *link, LookupParameters *p) { if (r < 0) return r; - return varlink_replybo( + return sd_varlink_replybo( link, SD_JSON_BUILD_PAIR("addresses", SD_JSON_BUILD_ARRAY( @@ -324,7 +324,7 @@ static int parse_as_address(Varlink *link, LookupParameters *p) { SD_RESOLVED_SYNTHETIC))); } -static int vl_method_resolve_hostname(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) { +static int vl_method_resolve_hostname(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) { static const sd_json_dispatch_field dispatch_table[] = { { "ifindex", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_int, offsetof(LookupParameters, ifindex), 0 }, { "name", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(LookupParameters, name), SD_JSON_MANDATORY }, @@ -343,30 +343,30 @@ static int vl_method_resolve_hostname(Varlink *link, sd_json_variant *parameters assert(link); - m = varlink_server_get_userdata(varlink_get_server(link)); + m = sd_varlink_server_get_userdata(sd_varlink_get_server(link)); assert(m); - if (FLAGS_SET(flags, VARLINK_METHOD_ONEWAY)) + if (FLAGS_SET(flags, SD_VARLINK_METHOD_ONEWAY)) return -EINVAL; - r = varlink_dispatch(link, parameters, dispatch_table, &p); + r = sd_varlink_dispatch(link, parameters, dispatch_table, &p); if (r != 0) return r; if (p.ifindex < 0) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex")); r = dns_name_is_valid(p.name); if (r < 0) return r; if (r == 0) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("name")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("name")); if (!IN_SET(p.family, AF_UNSPEC, AF_INET, AF_INET6)) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("family")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("family")); if (!validate_and_mangle_flags(p.name, &p.flags, SD_RESOLVED_NO_SEARCH)) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags")); r = parse_as_address(link, &p); if (r != 0) @@ -384,8 +384,8 @@ static int vl_method_resolve_hostname(Varlink *link, sd_json_variant *parameters if (r < 0) return r; - q->varlink_request = varlink_ref(link); - varlink_set_userdata(link, q); + q->varlink_request = sd_varlink_ref(link); + sd_varlink_set_userdata(link, q); q->request_family = p.family; q->complete = vl_method_resolve_hostname_complete; @@ -449,7 +449,7 @@ static void vl_method_resolve_address_complete(DnsQuery *query) { r = dns_query_process_cname_many(q); if (r == -ELOOP) { - r = varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL); + r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL); goto finish; } if (r < 0) @@ -484,22 +484,22 @@ static void vl_method_resolve_address_complete(DnsQuery *query) { } if (sd_json_variant_is_blank_object(array)) { - r = varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL); + r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL); goto finish; } - r = varlink_replybo( + r = sd_varlink_replybo( q->varlink_request, SD_JSON_BUILD_PAIR("names", SD_JSON_BUILD_VARIANT(array)), SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q)))); finish: if (r < 0) { log_full_errno(ERRNO_IS_DISCONNECT(r) ? LOG_DEBUG : LOG_ERR, r, "Failed to send address reply: %m"); - r = varlink_error_errno(q->varlink_request, r); + r = sd_varlink_error_errno(q->varlink_request, r); } } -static int vl_method_resolve_address(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) { +static int vl_method_resolve_address(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) { static const sd_json_dispatch_field dispatch_table[] = { { "ifindex", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_int, offsetof(LookupParameters, ifindex), 0 }, { "family", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_int, offsetof(LookupParameters, family), SD_JSON_MANDATORY }, @@ -518,27 +518,27 @@ static int vl_method_resolve_address(Varlink *link, sd_json_variant *parameters, assert(link); - m = varlink_server_get_userdata(varlink_get_server(link)); + m = sd_varlink_server_get_userdata(sd_varlink_get_server(link)); assert(m); - if (FLAGS_SET(flags, VARLINK_METHOD_ONEWAY)) + if (FLAGS_SET(flags, SD_VARLINK_METHOD_ONEWAY)) return -EINVAL; - r = varlink_dispatch(link, parameters, dispatch_table, &p); + r = sd_varlink_dispatch(link, parameters, dispatch_table, &p); if (r != 0) return r; if (p.ifindex < 0) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex")); if (!IN_SET(p.family, AF_INET, AF_INET6)) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("family")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("family")); if (FAMILY_ADDRESS_SIZE(p.family) != p.address_size) - return varlink_error(link, "io.systemd.Resolve.BadAddressSize", NULL); + return sd_varlink_error(link, "io.systemd.Resolve.BadAddressSize", NULL); if (!validate_and_mangle_flags(NULL, &p.flags, 0)) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags")); r = dns_question_new_reverse(&question, p.family, &p.address); if (r < 0) @@ -548,8 +548,8 @@ static int vl_method_resolve_address(Varlink *link, sd_json_variant *parameters, if (r < 0) return r; - q->varlink_request = varlink_ref(link); - varlink_set_userdata(link, q); + q->varlink_request = sd_varlink_ref(link); + sd_varlink_set_userdata(link, q); q->request_family = p.family; q->request_address = p.address; @@ -710,7 +710,7 @@ static int append_srv( return 1; /* added */ } -static Varlink *get_vl_link_aux_query(DnsQuery *aux) { +static sd_varlink *get_vl_link_aux_query(DnsQuery *aux) { assert(aux); /* Find the main query */ @@ -768,7 +768,7 @@ static void resolve_service_all_complete(DnsQuery *query) { assert(bad->auxiliary_result != 0); if (bad->auxiliary_result == -ELOOP) { - r = varlink_error(query->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL); + r = sd_varlink_error(query->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL); goto finish; } @@ -804,7 +804,7 @@ static void resolve_service_all_complete(DnsQuery *query) { } if (sd_json_variant_is_blank_object(srv)) { - r = varlink_error(query->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL); + r = sd_varlink_error(query->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL); goto finish; } @@ -828,7 +828,7 @@ static void resolve_service_all_complete(DnsQuery *query) { if (r < 0) goto finish; - r = varlink_replybo( + r = sd_varlink_replybo( query->varlink_request, SD_JSON_BUILD_PAIR("services", SD_JSON_BUILD_VARIANT(srv)), SD_JSON_BUILD_PAIR_CONDITION(!sd_json_variant_is_blank_object(txt), "txt", SD_JSON_BUILD_VARIANT(txt)), @@ -841,7 +841,7 @@ static void resolve_service_all_complete(DnsQuery *query) { finish: if (r < 0) { log_error_errno(r, "Failed to resolve service: %m"); - r = varlink_error_errno(q->varlink_request, r); + r = sd_varlink_error_errno(q->varlink_request, r); } } @@ -926,7 +926,7 @@ static void vl_method_resolve_service_complete(DnsQuery *query) { r = dns_query_process_cname_many(q); if (r == -ELOOP) { - r = varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL); + r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL); goto finish; } if (r < 0) @@ -970,12 +970,12 @@ static void vl_method_resolve_service_complete(DnsQuery *query) { /* If there's exactly one SRV RR and it uses the root domain as hostname, then the service is * explicitly not offered on the domain. Report this as a recognizable error. See RFC 2782, * Section "Usage Rules". */ - r = varlink_error(q->varlink_request, "io.systemd.Resolve.ServiceNotProvided", NULL); + r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.ServiceNotProvided", NULL); goto finish; } if (found <= 0) { - r = varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL); + r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL); goto finish; } @@ -986,11 +986,11 @@ static void vl_method_resolve_service_complete(DnsQuery *query) { finish: if (r < 0) { log_error_errno(r, "Failed to send address reply: %m"); - r = varlink_error_errno(q->varlink_request, r); + r = sd_varlink_error_errno(q->varlink_request, r); } } -static int vl_method_resolve_service(Varlink* link, sd_json_variant* parameters, VarlinkMethodFlags flags, void* userdata) { +static int vl_method_resolve_service(sd_varlink* link, sd_json_variant* parameters, sd_varlink_method_flags_t flags, void* userdata) { static const sd_json_dispatch_field dispatch_table[] = { { "name", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(LookupParametersResolveService, name), 0 }, { "type", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(LookupParametersResolveService, type), 0 }, @@ -1012,43 +1012,43 @@ static int vl_method_resolve_service(Varlink* link, sd_json_variant* parameters, assert(link); - m = varlink_server_get_userdata(varlink_get_server(link)); + m = sd_varlink_server_get_userdata(sd_varlink_get_server(link)); assert(m); - if (FLAGS_SET(flags, VARLINK_METHOD_ONEWAY)) + if (FLAGS_SET(flags, SD_VARLINK_METHOD_ONEWAY)) return -EINVAL; - r = varlink_dispatch(link, parameters, dispatch_table, &p); + r = sd_varlink_dispatch(link, parameters, dispatch_table, &p); if (r != 0) return r; if (p.ifindex < 0) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex")); if (!IN_SET(p.family, AF_INET, AF_INET6, AF_UNSPEC)) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("family")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("family")); if (isempty(p.name)) p.name = NULL; else if (!dns_service_name_is_valid(p.name)) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("name")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("name")); if (isempty(p.type)) p.type = NULL; else if (!dns_srv_type_is_valid(p.type)) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("type")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("type")); r = dns_name_is_valid(p.domain); if (r < 0) return r; if (r == 0) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("domain")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("domain")); if (p.name && !p.type) /* Service name cannot be specified without service type. */ - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("type")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("type")); if (!validate_and_mangle_flags(p.name, &p.flags, SD_RESOLVED_NO_TXT|SD_RESOLVED_NO_ADDRESS)) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags")); r = dns_question_new_service(&question_utf8, p.name, p.type, p.domain, !(p.flags & SD_RESOLVED_NO_TXT), false); if (r < 0) @@ -1062,11 +1062,11 @@ static int vl_method_resolve_service(Varlink* link, sd_json_variant* parameters, if (r < 0) return r; - q->varlink_request = varlink_ref(link); + q->varlink_request = sd_varlink_ref(link); q->request_family = p.family; q->complete = vl_method_resolve_service_complete; - varlink_set_userdata(link, q); + sd_varlink_set_userdata(link, q); r = dns_query_go(q); if (r < 0) @@ -1091,7 +1091,7 @@ static void vl_method_resolve_record_complete(DnsQuery *query) { r = dns_query_process_cname_many(q); if (r == -ELOOP) { - r = varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL); + r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL); goto finish; } if (r < 0) @@ -1136,22 +1136,22 @@ static void vl_method_resolve_record_complete(DnsQuery *query) { } if (added <= 0) { - r = varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL); + r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL); goto finish; } - r = varlink_replybo( + r = sd_varlink_replybo( q->varlink_request, SD_JSON_BUILD_PAIR("rrs", SD_JSON_BUILD_VARIANT(array)), SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q)))); finish: if (r < 0) { log_full_errno(ERRNO_IS_DISCONNECT(r) ? LOG_DEBUG : LOG_ERR, r, "Failed to send record reply: %m"); - varlink_error_errno(q->varlink_request, r); + sd_varlink_error_errno(q->varlink_request, r); } } -static int vl_method_resolve_record(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) { +static int vl_method_resolve_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) { static const sd_json_dispatch_field dispatch_table[] = { { "ifindex", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_int, offsetof(LookupParameters, ifindex), 0 }, { "name", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(LookupParameters, name), SD_JSON_MANDATORY }, @@ -1171,33 +1171,33 @@ static int vl_method_resolve_record(Varlink *link, sd_json_variant *parameters, assert(link); - m = ASSERT_PTR(varlink_server_get_userdata(varlink_get_server(link))); + m = ASSERT_PTR(sd_varlink_server_get_userdata(sd_varlink_get_server(link))); - if (FLAGS_SET(flags, VARLINK_METHOD_ONEWAY)) + if (FLAGS_SET(flags, SD_VARLINK_METHOD_ONEWAY)) return -EINVAL; - r = varlink_dispatch(link, parameters, dispatch_table, &p); + r = sd_varlink_dispatch(link, parameters, dispatch_table, &p); if (r != 0) return r; if (p.ifindex < 0) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex")); r = dns_name_is_valid(p.name); if (r < 0) return r; if (r == 0) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("name")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("name")); if (!dns_type_is_valid_query(p.type)) - return varlink_error(link, "io.systemd.Resolve.ResourceRecordTypeInvalidForQuery", NULL); + return sd_varlink_error(link, "io.systemd.Resolve.ResourceRecordTypeInvalidForQuery", NULL); if (dns_type_is_zone_transfer(p.type)) - return varlink_error(link, "io.systemd.Resolve.ZoneTransfersNotPermitted", NULL); + return sd_varlink_error(link, "io.systemd.Resolve.ZoneTransfersNotPermitted", NULL); if (dns_type_is_obsolete(p.type)) - return varlink_error(link, "io.systemd.Resolve.ResourceRecordTypeObsolete", NULL); + return sd_varlink_error(link, "io.systemd.Resolve.ResourceRecordTypeObsolete", NULL); if (!validate_and_mangle_flags(p.name, &p.flags, SD_RESOLVED_NO_SEARCH)) - return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags")); + return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags")); _cleanup_(dns_question_unrefp) DnsQuestion *question = dns_question_new(1); if (!question) @@ -1216,8 +1216,8 @@ static int vl_method_resolve_record(Varlink *link, sd_json_variant *parameters, if (r < 0) return r; - q->varlink_request = varlink_ref(link); - varlink_set_userdata(link, q); + q->varlink_request = sd_varlink_ref(link); + sd_varlink_set_userdata(link, q); q->complete = vl_method_resolve_record_complete; r = dns_query_go(q); @@ -1228,38 +1228,38 @@ static int vl_method_resolve_record(Varlink *link, sd_json_variant *parameters, return 1; } -static int vl_method_subscribe_query_results(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) { +static int vl_method_subscribe_query_results(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) { Manager *m; int r; assert(link); - m = ASSERT_PTR(varlink_server_get_userdata(varlink_get_server(link))); + m = ASSERT_PTR(sd_varlink_server_get_userdata(sd_varlink_get_server(link))); /* if the client didn't set the more flag, it is using us incorrectly */ - if (!FLAGS_SET(flags, VARLINK_METHOD_MORE)) - return varlink_error(link, VARLINK_ERROR_EXPECTED_MORE, NULL); + if (!FLAGS_SET(flags, SD_VARLINK_METHOD_MORE)) + return sd_varlink_error(link, SD_VARLINK_ERROR_EXPECTED_MORE, NULL); if (sd_json_variant_elements(parameters) > 0) - return varlink_error_invalid_parameter(link, parameters); + return sd_varlink_error_invalid_parameter(link, parameters); /* Send a ready message to the connecting client, to indicate that we are now listinening, and all * queries issued after the point the client sees this will also be reported to the client. */ - r = varlink_notifybo(link, SD_JSON_BUILD_PAIR("ready", SD_JSON_BUILD_BOOLEAN(true))); + r = sd_varlink_notifybo(link, SD_JSON_BUILD_PAIR("ready", SD_JSON_BUILD_BOOLEAN(true))); if (r < 0) return log_error_errno(r, "Failed to report monitor to be established: %m"); r = set_ensure_put(&m->varlink_subscription, NULL, link); if (r < 0) return log_error_errno(r, "Failed to add subscription to set: %m"); - varlink_ref(link); + sd_varlink_ref(link); log_debug("%u clients now attached for varlink notifications", set_size(m->varlink_subscription)); return 1; } -static int vl_method_dump_cache(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) { +static int vl_method_dump_cache(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) { _cleanup_(sd_json_variant_unrefp) sd_json_variant *list = NULL; Manager *m; int r; @@ -1267,9 +1267,9 @@ static int vl_method_dump_cache(Varlink *link, sd_json_variant *parameters, Varl assert(link); if (sd_json_variant_elements(parameters) > 0) - return varlink_error_invalid_parameter(link, parameters); + return sd_varlink_error_invalid_parameter(link, parameters); - m = ASSERT_PTR(varlink_server_get_userdata(varlink_get_server(link))); + m = ASSERT_PTR(sd_varlink_server_get_userdata(sd_varlink_get_server(link))); LIST_FOREACH(scopes, s, m->dns_scopes) { _cleanup_(sd_json_variant_unrefp) sd_json_variant *j = NULL; @@ -1289,7 +1289,7 @@ static int vl_method_dump_cache(Varlink *link, sd_json_variant *parameters, Varl return r; } - return varlink_replybo(link, SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list))); + return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list))); } static int dns_server_dump_state_to_json_list(DnsServer *server, sd_json_variant **list) { @@ -1306,7 +1306,7 @@ static int dns_server_dump_state_to_json_list(DnsServer *server, sd_json_variant return sd_json_variant_append_array(list, j); } -static int vl_method_dump_server_state(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) { +static int vl_method_dump_server_state(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) { _cleanup_(sd_json_variant_unrefp) sd_json_variant *list = NULL; Manager *m; int r; @@ -1315,9 +1315,9 @@ static int vl_method_dump_server_state(Varlink *link, sd_json_variant *parameter assert(link); if (sd_json_variant_elements(parameters) > 0) - return varlink_error_invalid_parameter(link, parameters); + return sd_varlink_error_invalid_parameter(link, parameters); - m = ASSERT_PTR(varlink_server_get_userdata(varlink_get_server(link))); + m = ASSERT_PTR(sd_varlink_server_get_userdata(sd_varlink_get_server(link))); LIST_FOREACH(servers, server, m->dns_servers) { r = dns_server_dump_state_to_json_list(server, &list); @@ -1344,10 +1344,10 @@ static int vl_method_dump_server_state(Varlink *link, sd_json_variant *parameter return r; } - return varlink_replybo(link, SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list))); + return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list))); } -static int vl_method_dump_statistics(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) { +static int vl_method_dump_statistics(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) { _cleanup_(sd_json_variant_unrefp) sd_json_variant *j = NULL; Manager *m; int r; @@ -1355,34 +1355,34 @@ static int vl_method_dump_statistics(Varlink *link, sd_json_variant *parameters, assert(link); if (sd_json_variant_elements(parameters) > 0) - return varlink_error_invalid_parameter(link, parameters); + return sd_varlink_error_invalid_parameter(link, parameters); - m = ASSERT_PTR(varlink_server_get_userdata(varlink_get_server(link))); + m = ASSERT_PTR(sd_varlink_server_get_userdata(sd_varlink_get_server(link))); r = dns_manager_dump_statistics_json(m, &j); if (r < 0) return r; - return varlink_replyb(link, SD_JSON_BUILD_VARIANT(j)); + return sd_varlink_replyb(link, SD_JSON_BUILD_VARIANT(j)); } -static int vl_method_reset_statistics(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) { +static int vl_method_reset_statistics(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) { Manager *m; assert(link); if (sd_json_variant_elements(parameters) > 0) - return varlink_error_invalid_parameter(link, parameters); + return sd_varlink_error_invalid_parameter(link, parameters); - m = ASSERT_PTR(varlink_server_get_userdata(varlink_get_server(link))); + m = ASSERT_PTR(sd_varlink_server_get_userdata(sd_varlink_get_server(link))); dns_manager_reset_statistics(m); - return varlink_replyb(link, SD_JSON_BUILD_EMPTY_OBJECT); + return sd_varlink_replyb(link, SD_JSON_BUILD_EMPTY_OBJECT); } static int varlink_monitor_server_init(Manager *m) { - _cleanup_(varlink_server_unrefp) VarlinkServer *server = NULL; + _cleanup_(sd_varlink_server_unrefp) sd_varlink_server *server = NULL; int r; assert(m); @@ -1390,17 +1390,17 @@ static int varlink_monitor_server_init(Manager *m) { if (m->varlink_monitor_server) return 0; - r = varlink_server_new(&server, VARLINK_SERVER_ROOT_ONLY); + r = sd_varlink_server_new(&server, SD_VARLINK_SERVER_ROOT_ONLY); if (r < 0) return log_error_errno(r, "Failed to allocate varlink server object: %m"); - varlink_server_set_userdata(server, m); + sd_varlink_server_set_userdata(server, m); - r = varlink_server_add_interface(server, &vl_interface_io_systemd_Resolve_Monitor); + r = sd_varlink_server_add_interface(server, &vl_interface_io_systemd_Resolve_Monitor); if (r < 0) return log_error_errno(r, "Failed to add Resolve.Monitor interface to varlink server: %m"); - r = varlink_server_bind_method_many( + r = sd_varlink_server_bind_method_many( server, "io.systemd.Resolve.Monitor.SubscribeQueryResults", vl_method_subscribe_query_results, "io.systemd.Resolve.Monitor.DumpCache", vl_method_dump_cache, @@ -1410,15 +1410,15 @@ static int varlink_monitor_server_init(Manager *m) { if (r < 0) return log_error_errno(r, "Failed to register varlink methods: %m"); - r = varlink_server_bind_disconnect(server, vl_on_notification_disconnect); + r = sd_varlink_server_bind_disconnect(server, vl_on_notification_disconnect); if (r < 0) return log_error_errno(r, "Failed to register varlink disconnect handler: %m"); - r = varlink_server_listen_address(server, "/run/systemd/resolve/io.systemd.Resolve.Monitor", 0600); + r = sd_varlink_server_listen_address(server, "/run/systemd/resolve/io.systemd.Resolve.Monitor", 0600); if (r < 0) return log_error_errno(r, "Failed to bind to varlink socket: %m"); - r = varlink_server_attach_event(server, m->event, SD_EVENT_PRIORITY_NORMAL); + r = sd_varlink_server_attach_event(server, m->event, SD_EVENT_PRIORITY_NORMAL); if (r < 0) return log_error_errno(r, "Failed to attach varlink connection to event loop: %m"); @@ -1428,7 +1428,7 @@ static int varlink_monitor_server_init(Manager *m) { } static int varlink_main_server_init(Manager *m) { - _cleanup_(varlink_server_unrefp) VarlinkServer *s = NULL; + _cleanup_(sd_varlink_server_unrefp) sd_varlink_server *s = NULL; int r; assert(m); @@ -1436,17 +1436,17 @@ static int varlink_main_server_init(Manager *m) { if (m->varlink_server) return 0; - r = varlink_server_new(&s, VARLINK_SERVER_ACCOUNT_UID); + r = sd_varlink_server_new(&s, SD_VARLINK_SERVER_ACCOUNT_UID); if (r < 0) return log_error_errno(r, "Failed to allocate varlink server object: %m"); - varlink_server_set_userdata(s, m); + sd_varlink_server_set_userdata(s, m); - r = varlink_server_add_interface(s, &vl_interface_io_systemd_Resolve); + r = sd_varlink_server_add_interface(s, &vl_interface_io_systemd_Resolve); if (r < 0) return log_error_errno(r, "Failed to add Resolve interface to varlink server: %m"); - r = varlink_server_bind_method_many( + r = sd_varlink_server_bind_method_many( s, "io.systemd.Resolve.ResolveHostname", vl_method_resolve_hostname, "io.systemd.Resolve.ResolveAddress", vl_method_resolve_address, @@ -1455,15 +1455,15 @@ static int varlink_main_server_init(Manager *m) { if (r < 0) return log_error_errno(r, "Failed to register varlink methods: %m"); - r = varlink_server_bind_disconnect(s, vl_on_disconnect); + r = sd_varlink_server_bind_disconnect(s, vl_on_disconnect); if (r < 0) return log_error_errno(r, "Failed to register varlink disconnect handler: %m"); - r = varlink_server_listen_address(s, "/run/systemd/resolve/io.systemd.Resolve", 0666); + r = sd_varlink_server_listen_address(s, "/run/systemd/resolve/io.systemd.Resolve", 0666); if (r < 0) return log_error_errno(r, "Failed to bind to varlink socket: %m"); - r = varlink_server_attach_event(s, m->event, SD_EVENT_PRIORITY_NORMAL); + r = sd_varlink_server_attach_event(s, m->event, SD_EVENT_PRIORITY_NORMAL); if (r < 0) return log_error_errno(r, "Failed to attach varlink connection to event loop: %m"); @@ -1488,6 +1488,6 @@ int manager_varlink_init(Manager *m) { void manager_varlink_done(Manager *m) { assert(m); - m->varlink_server = varlink_server_unref(m->varlink_server); - m->varlink_monitor_server = varlink_server_unref(m->varlink_monitor_server); + m->varlink_server = sd_varlink_server_unref(m->varlink_server); + m->varlink_monitor_server = sd_varlink_server_unref(m->varlink_monitor_server); } |