Lines Matching refs:req

52 	struct isns_req *req;
54 req = calloc(sizeof(struct isns_req), 1);
55 if (req == NULL) {
59 req->ir_buflen = sizeof(struct isns_hdr);
60 req->ir_usedlen = 0;
61 req->ir_buf = calloc(req->ir_buflen, 1);
62 if (req->ir_buf == NULL) {
63 free(req);
67 return (req);
73 struct isns_req *req;
76 req = isns_req_alloc();
77 req->ir_usedlen = sizeof(struct isns_hdr);
78 hdr = (struct isns_hdr *)req->ir_buf;
82 return (req);
86 isns_req_free(struct isns_req *req)
89 free(req->ir_buf);
90 free(req);
94 isns_req_getspace(struct isns_req *req, uint32_t len)
99 if (req->ir_usedlen + len <= req->ir_buflen)
101 newlen = 1 << flsl(req->ir_usedlen + len);
102 newbuf = realloc(req->ir_buf, newlen);
107 req->ir_buf = newbuf;
108 req->ir_buflen = newlen;
113 isns_req_add(struct isns_req *req, uint32_t tag, uint32_t len,
120 isns_req_getspace(req, sizeof(*tlv) + vlen);
121 tlv = (struct isns_tlv *)&req->ir_buf[req->ir_usedlen];
127 req->ir_usedlen += sizeof(*tlv) + vlen;
131 isns_req_add_delim(struct isns_req *req)
134 isns_req_add(req, 0, 0, NULL);
138 isns_req_add_str(struct isns_req *req, uint32_t tag, const char *value)
141 isns_req_add(req, tag, strlen(value) + 1, value);
145 isns_req_add_32(struct isns_req *req, uint32_t tag, uint32_t value)
150 isns_req_add(req, tag, sizeof(value), &beval);
154 isns_req_add_addr(struct isns_req *req, uint32_t tag, struct addrinfo *ai)
167 isns_req_add(req, tag, sizeof(buf), buf);
171 isns_req_add(req, tag, sizeof(in6->sin6_addr), &in6->sin6_addr);
180 isns_req_add_port(struct isns_req *req, uint32_t tag, struct addrinfo *ai)
190 isns_req_add(req, tag, sizeof(buf), &buf);
195 isns_req_add(req, tag, sizeof(buf), &buf);
204 isns_req_send(int s, struct isns_req *req)
209 hdr = (struct isns_hdr *)req->ir_buf;
210 be16enc(hdr->ih_length, req->ir_usedlen - sizeof(*hdr));
216 res = write(s, req->ir_buf, req->ir_usedlen);
221 isns_req_receive(int s, struct isns_req *req)
226 req->ir_usedlen = 0;
227 isns_req_getspace(req, sizeof(*hdr));
228 res = read(s, req->ir_buf, sizeof(*hdr));
231 req->ir_usedlen = sizeof(*hdr);
232 hdr = (struct isns_hdr *)req->ir_buf;
239 isns_req_getspace(req, len);
240 res = read(s, &req->ir_buf[req->ir_usedlen], len);
243 req->ir_usedlen += len;
248 isns_req_get_status(struct isns_req *req)
251 if (req->ir_usedlen < sizeof(struct isns_hdr) + 4)
253 return (be32dec(&req->ir_buf[sizeof(struct isns_hdr)]));