Lines Matching refs:handle

75 int ns_msg_getflag(ns_msg handle, int flag) {
76 return(((handle)._flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift);
104 ns_initparse(const u_char *msg, int msglen, ns_msg *handle) {
108 handle->_msg = msg;
109 handle->_eom = eom;
112 NS_GET16(handle->_id, msg);
115 NS_GET16(handle->_flags, msg);
119 NS_GET16(handle->_counts[i], msg);
122 if (handle->_counts[i] == 0)
123 handle->_sections[i] = NULL;
126 handle->_counts[i]);
130 handle->_sections[i] = msg;
135 setsection(handle, ns_s_max);
140 ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
148 if (section != handle->_sect)
149 setsection(handle, section);
153 rrnum = handle->_rrnum;
154 if (rrnum < 0 || rrnum >= handle->_counts[(int)section])
156 if (rrnum < handle->_rrnum)
157 setsection(handle, section);
158 if (rrnum > handle->_rrnum) {
159 b = ns_skiprr(handle->_msg_ptr, handle->_eom, section,
160 rrnum - handle->_rrnum);
164 handle->_msg_ptr += b;
165 handle->_rrnum = rrnum;
169 b = dn_expand(handle->_msg, handle->_eom,
170 handle->_msg_ptr, rr->name, NS_MAXDNAME);
173 handle->_msg_ptr += b;
174 if (handle->_msg_ptr + NS_INT16SZ + NS_INT16SZ > handle->_eom)
176 NS_GET16(rr->type, handle->_msg_ptr);
177 NS_GET16(rr->rr_class, handle->_msg_ptr);
183 if (handle->_msg_ptr + NS_INT32SZ + NS_INT16SZ > handle->_eom)
185 NS_GET32(rr->ttl, handle->_msg_ptr);
186 NS_GET16(rr->rdlength, handle->_msg_ptr);
187 if (handle->_msg_ptr + rr->rdlength > handle->_eom)
189 rr->rdata = handle->_msg_ptr;
190 handle->_msg_ptr += rr->rdlength;
192 if (++handle->_rrnum > handle->_counts[(int)section])
193 setsection(handle, (ns_sect)((int)section + 1));
203 ns_parserr2(ns_msg *handle, ns_sect section, int rrnum, ns_rr2 *rr) {
210 if (section != handle->_sect)
211 setsection(handle, section);
215 rrnum = handle->_rrnum;
216 if (rrnum < 0 || rrnum >= handle->_counts[(int)section])
218 if (rrnum < handle->_rrnum)
219 setsection(handle, section);
220 if (rrnum > handle->_rrnum) {
221 b = ns_skiprr(handle->_msg_ptr, handle->_eom, section,
222 rrnum - handle->_rrnum);
226 handle->_msg_ptr += b;
227 handle->_rrnum = rrnum;
231 b = ns_name_unpack2(handle->_msg, handle->_eom, handle->_msg_ptr,
235 handle->_msg_ptr += b;
236 if (handle->_msg_ptr + NS_INT16SZ + NS_INT16SZ > handle->_eom)
238 NS_GET16(rr->type, handle->_msg_ptr);
239 NS_GET16(rr->rr_class, handle->_msg_ptr);
245 if (handle->_msg_ptr + NS_INT32SZ + NS_INT16SZ > handle->_eom)
247 NS_GET32(rr->ttl, handle->_msg_ptr);
248 NS_GET16(rr->rdlength, handle->_msg_ptr);
249 if (handle->_msg_ptr + rr->rdlength > handle->_eom)
251 rr->rdata = handle->_msg_ptr;
252 handle->_msg_ptr += rr->rdlength;
254 if (++handle->_rrnum > handle->_counts[(int)section])
255 setsection(handle, (ns_sect)((int)section + 1));