//we'd better send the right domain and id int send_tc_to_client(uchar *td,struct sockinfo *si,ushort cid) { uchar buffer[255] = {0},*itor = buffer; dnsheader *hdr = (dnsheader*)itor; qdns *qd = NULL; int dlen = -1; if(td == NULL || si == NULL) return -1; hdr->id = cid; hdr->flags = 0; hdr->flags = SET_QR_R(hdr->flags); hdr->flags = SET_RA(hdr->flags); hdr->flags = SET_TC(hdr->flags); hdr->flags = htons(hdr->flags); hdr->qdcount = htons(1); hdr->ancount = hdr->nscount = hdr->arcount = htons(0); itor += sizeof(dnsheader); dlen = strlen(td + 1); memcpy(itor,td + 1,dlen + 1); itor = itor + dlen + 1; qd = (qdns*)itor; qd->type = htons(td[0]); qd->dclass = htons(CLASS_IN); itor += sizeof(qdns); si->buf = buffer; si->buflen = itor - buffer; udp_write_info(si,0); return 0; }
//we'd better send the right domain and id int send_tc_to_client(mbuf_type *mbuf) { uchar *itor = mbuf->buf; dnsheader *hdr = (dnsheader *) itor; qdns *qd = NULL; if (mbuf->td == NULL) return -1; hdr->id = mbuf->id; hdr->flags = 0; hdr->flags = SET_QR_R(hdr->flags); hdr->flags = SET_RA(hdr->flags); hdr->flags = SET_TC(hdr->flags); hdr->flags = htons(hdr->flags); hdr->qdcount = htons(1); hdr->ancount = hdr->nscount = hdr->arcount = htons(0); itor += sizeof(dnsheader); memcpy(itor, mbuf->td, mbuf->dlen); itor = itor + mbuf->dlen; qd = (qdns *) itor; qd->type = htons(mbuf->qtype); qd->dclass = htons(CLASS_IN); itor += sizeof(qdns); mbuf->buflen = itor - mbuf->buf; udp_write_info(mbuf, 0); return 0; }
/** \todo fixup old mpm ptrs. We could use the array directly later */ void MpmStoreFixup(SigGroupHead *sgh) { if (!(SGH_PROTO(sgh, IPPROTO_TCP) || SGH_PROTO(sgh, IPPROTO_UDP))) return; #define SET_TS(sgh, ptr) do { \ if (SGH_DIRECTION_TS((sgh))) \ (ptr) = (sgh)->init->app_mpms[i++]; \ else \ i++; \ } while(0) #define SET_TC(sgh, ptr) do { \ if (SGH_DIRECTION_TC((sgh))) \ (ptr) = (sgh)->init->app_mpms[i++]; \ else \ i++; \ } while(0) int i = 0; SET_TS(sgh, sgh->mpm_uri_ctx_ts); SET_TS(sgh, sgh->mpm_hrud_ctx_ts); SET_TS(sgh, sgh->mpm_hhd_ctx_ts); SET_TC(sgh, sgh->mpm_hhd_ctx_tc); SET_TS(sgh, sgh->mpm_huad_ctx_ts); SET_TS(sgh, sgh->mpm_hrhd_ctx_ts); SET_TC(sgh, sgh->mpm_hrhd_ctx_tc); SET_TS(sgh, sgh->mpm_hmd_ctx_ts); SET_TS(sgh, sgh->mpm_smtp_filedata_ctx_ts); SET_TC(sgh, sgh->mpm_hsbd_ctx_tc); SET_TC(sgh, sgh->mpm_hsmd_ctx_tc); SET_TC(sgh, sgh->mpm_hscd_ctx_tc); SET_TS(sgh, sgh->mpm_hcbd_ctx_ts); SET_TS(sgh, sgh->mpm_hhhd_ctx_ts); SET_TS(sgh, sgh->mpm_hrhhd_ctx_ts); SET_TS(sgh, sgh->mpm_hcd_ctx_ts); SET_TC(sgh, sgh->mpm_hcd_ctx_tc); SET_TS(sgh, sgh->mpm_dnsquery_ctx_ts); BUG_ON(APP_MPMS_MAX != 18 || i != 18); #undef SET_TS #undef SET_TC }