Lines Matching refs:req

56 	struct isns_req *req;  in isns_req_alloc()  local
58 req = calloc(sizeof(struct isns_req), 1); in isns_req_alloc()
59 if (req == NULL) { in isns_req_alloc()
63 req->ir_buflen = sizeof(struct isns_hdr); in isns_req_alloc()
64 req->ir_usedlen = 0; in isns_req_alloc()
65 req->ir_buf = calloc(req->ir_buflen, 1); in isns_req_alloc()
66 if (req->ir_buf == NULL) { in isns_req_alloc()
67 free(req); in isns_req_alloc()
71 return (req); in isns_req_alloc()
77 struct isns_req *req; in isns_req_create() local
80 req = isns_req_alloc(); in isns_req_create()
81 req->ir_usedlen = sizeof(struct isns_hdr); in isns_req_create()
82 hdr = (struct isns_hdr *)req->ir_buf; in isns_req_create()
86 return (req); in isns_req_create()
90 isns_req_free(struct isns_req *req) in isns_req_free() argument
93 free(req->ir_buf); in isns_req_free()
94 free(req); in isns_req_free()
98 isns_req_getspace(struct isns_req *req, uint32_t len) in isns_req_getspace() argument
103 if (req->ir_usedlen + len <= req->ir_buflen) in isns_req_getspace()
105 newlen = 1 << flsl(req->ir_usedlen + len); in isns_req_getspace()
106 newbuf = realloc(req->ir_buf, newlen); in isns_req_getspace()
111 req->ir_buf = newbuf; in isns_req_getspace()
112 req->ir_buflen = newlen; in isns_req_getspace()
117 isns_req_add(struct isns_req *req, uint32_t tag, uint32_t len, in isns_req_add() argument
124 isns_req_getspace(req, sizeof(*tlv) + vlen); in isns_req_add()
125 tlv = (struct isns_tlv *)&req->ir_buf[req->ir_usedlen]; in isns_req_add()
131 req->ir_usedlen += sizeof(*tlv) + vlen; in isns_req_add()
135 isns_req_add_delim(struct isns_req *req) in isns_req_add_delim() argument
138 isns_req_add(req, 0, 0, NULL); in isns_req_add_delim()
142 isns_req_add_str(struct isns_req *req, uint32_t tag, const char *value) in isns_req_add_str() argument
145 isns_req_add(req, tag, strlen(value) + 1, value); in isns_req_add_str()
149 isns_req_add_32(struct isns_req *req, uint32_t tag, uint32_t value) in isns_req_add_32() argument
154 isns_req_add(req, tag, sizeof(value), &beval); in isns_req_add_32()
158 isns_req_add_addr(struct isns_req *req, uint32_t tag, struct addrinfo *ai) in isns_req_add_addr() argument
171 isns_req_add(req, tag, sizeof(buf), buf); in isns_req_add_addr()
175 isns_req_add(req, tag, sizeof(in6->sin6_addr), &in6->sin6_addr); in isns_req_add_addr()
184 isns_req_add_port(struct isns_req *req, uint32_t tag, struct addrinfo *ai) in isns_req_add_port() argument
194 isns_req_add(req, tag, sizeof(buf), &buf); in isns_req_add_port()
199 isns_req_add(req, tag, sizeof(buf), &buf); in isns_req_add_port()
208 isns_req_send(int s, struct isns_req *req) in isns_req_send() argument
213 hdr = (struct isns_hdr *)req->ir_buf; in isns_req_send()
214 be16enc(hdr->ih_length, req->ir_usedlen - sizeof(*hdr)); in isns_req_send()
220 res = write(s, req->ir_buf, req->ir_usedlen); in isns_req_send()
225 isns_req_receive(int s, struct isns_req *req) in isns_req_receive() argument
230 req->ir_usedlen = 0; in isns_req_receive()
231 isns_req_getspace(req, sizeof(*hdr)); in isns_req_receive()
232 res = read(s, req->ir_buf, sizeof(*hdr)); in isns_req_receive()
235 req->ir_usedlen = sizeof(*hdr); in isns_req_receive()
236 hdr = (struct isns_hdr *)req->ir_buf; in isns_req_receive()
243 isns_req_getspace(req, len); in isns_req_receive()
244 res = read(s, &req->ir_buf[req->ir_usedlen], len); in isns_req_receive()
247 req->ir_usedlen += len; in isns_req_receive()
252 isns_req_get_status(struct isns_req *req) in isns_req_get_status() argument
255 if (req->ir_usedlen < sizeof(struct isns_hdr) + 4) in isns_req_get_status()
257 return (be32dec(&req->ir_buf[sizeof(struct isns_hdr)])); in isns_req_get_status()