Lines Matching refs:handle

83 int ns_msg_getflag(ns_msg handle, int flag) {
84 return((u_int32_t)((handle)._flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift);
113 ns_initparse(const u_char *msg, int msglen, ns_msg *handle) {
117 handle->_msg = msg;
118 handle->_eom = eom;
121 NS_GET16(handle->_id, msg);
124 NS_GET16(handle->_flags, msg);
128 NS_GET16(handle->_counts[i], msg);
131 if (handle->_counts[i] == 0)
132 handle->_sections[i] = NULL;
135 handle->_counts[i]);
139 handle->_sections[i] = msg;
144 setsection(handle, ns_s_max);
149 ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
157 if (section != handle->_sect)
158 setsection(handle, section);
162 rrnum = handle->_rrnum;
163 if (rrnum < 0 || rrnum >= handle->_counts[(int)section])
165 if (rrnum < handle->_rrnum)
166 setsection(handle, section);
167 if (rrnum > handle->_rrnum) {
168 b = ns_skiprr(handle->_msg_ptr, handle->_eom, section,
169 rrnum - handle->_rrnum);
173 handle->_msg_ptr += b;
174 handle->_rrnum = rrnum;
178 b = dn_expand(handle->_msg, handle->_eom,
179 handle->_msg_ptr, rr->name, NS_MAXDNAME);
182 handle->_msg_ptr += b;
183 if (handle->_msg_ptr + NS_INT16SZ + NS_INT16SZ > handle->_eom)
185 NS_GET16(rr->type, handle->_msg_ptr);
186 NS_GET16(rr->rr_class, handle->_msg_ptr);
192 if (handle->_msg_ptr + NS_INT32SZ + NS_INT16SZ > handle->_eom)
194 NS_GET32(rr->ttl, handle->_msg_ptr);
195 NS_GET16(rr->rdlength, handle->_msg_ptr);
196 if (handle->_msg_ptr + rr->rdlength > handle->_eom)
198 rr->rdata = handle->_msg_ptr;
199 handle->_msg_ptr += rr->rdlength;
201 if (++handle->_rrnum > handle->_counts[(int)section])
202 setsection(handle, (ns_sect)((int)section + 1));
212 ns_parserr2(ns_msg *handle, ns_sect section, int rrnum, ns_rr2 *rr) {
220 if (section != handle->_sect)
221 setsection(handle, section);
225 rrnum = handle->_rrnum;
226 if (rrnum < 0 || rrnum >= handle->_counts[(int)section])
228 if (rrnum < handle->_rrnum)
229 setsection(handle, section);
230 if (rrnum > handle->_rrnum) {
231 b = ns_skiprr(handle->_msg_ptr, handle->_eom, section,
232 rrnum - handle->_rrnum);
236 handle->_msg_ptr += b;
237 handle->_rrnum = rrnum;
241 b = ns_name_unpack2(handle->_msg, handle->_eom, handle->_msg_ptr,
245 handle->_msg_ptr += b;
246 if (handle->_msg_ptr + NS_INT16SZ + NS_INT16SZ > handle->_eom)
248 NS_GET16(rr->type, handle->_msg_ptr);
249 NS_GET16(rr->rr_class, handle->_msg_ptr);
255 if (handle->_msg_ptr + NS_INT32SZ + NS_INT16SZ > handle->_eom)
257 NS_GET32(rr->ttl, handle->_msg_ptr);
258 NS_GET16(rr->rdlength, handle->_msg_ptr);
259 if (handle->_msg_ptr + rr->rdlength > handle->_eom)
261 rr->rdata = handle->_msg_ptr;
262 handle->_msg_ptr += rr->rdlength;
264 if (++handle->_rrnum > handle->_counts[(int)section])
265 setsection(handle, (ns_sect)((int)section + 1));