1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <resolv.h>
17 #include <stdio.h>
18 #include <string.h>
19 #include "test.h"
20
21 const int op = QUERY;
22 const int class = C_IN;
23 const int type = T_TXT;
24 const char dname[] = "www.example.com";
25 const unsigned char *data = (const unsigned char *)"";
26 const char qbuf[] = "\0\1\0\0\0\0\0\0";
27 const char qname[] = "\3www\7example\3com";
28
29 /**
30 * @tc.name : res_send_0100
31 * @tc.desc : Send a preformatted query given in msg of length msglen
32 * @tc.level : Level 0
33 */
res_send_0100(void)34 void res_send_0100(void)
35 {
36 unsigned char buf[BUFSIZ] = {0};
37 unsigned char answer[512];
38 int ret = res_mkquery(op, dname, class, type, data, 0, NULL, buf, sizeof(buf));
39 if (ret < 0) {
40 t_error("%s failed: ret = %d\n", __func__, ret);
41 }
42
43 int result = res_send(buf, ret, answer, sizeof(answer));
44 if (result == -1) {
45 t_error("%s res_send failed\n", __func__);
46 }
47 }
48
main(int argc,char * argv[])49 int main(int argc, char *argv[])
50 {
51 res_send_0100();
52 return t_status;
53 }