• Home
  • Raw
  • Download

Lines Matching refs:pkt

104     PktMsg pkt;  member
113 PktMsg pkt; member
205 mDNSlocal void HdrNToH(PktMsg *pkt) in HdrNToH() argument
208 mDNSu8 *ptr = (mDNSu8 *)&pkt->msg.h.numQuestions; in HdrNToH()
209 pkt->msg.h.numQuestions = (mDNSu16)((mDNSu16)ptr[0] << 8 | ptr[1]); in HdrNToH()
210 pkt->msg.h.numAnswers = (mDNSu16)((mDNSu16)ptr[2] << 8 | ptr[3]); in HdrNToH()
211 pkt->msg.h.numAuthorities = (mDNSu16)((mDNSu16)ptr[4] << 8 | ptr[5]); in HdrNToH()
212 pkt->msg.h.numAdditionals = (mDNSu16)((mDNSu16)ptr[6] << 8 | ptr[7]); in HdrNToH()
216 mDNSlocal void HdrHToN(PktMsg *pkt) in HdrHToN() argument
218 mDNSu16 numQuestions = pkt->msg.h.numQuestions; in HdrHToN()
219 mDNSu16 numAnswers = pkt->msg.h.numAnswers; in HdrHToN()
220 mDNSu16 numAuthorities = pkt->msg.h.numAuthorities; in HdrHToN()
221 mDNSu16 numAdditionals = pkt->msg.h.numAdditionals; in HdrHToN()
222 mDNSu8 *ptr = (mDNSu8 *)&pkt->msg.h.numQuestions; in HdrHToN()
351 mDNSlocal int SendPacket(TCPSocket *sock, PktMsg *pkt) in SendPacket() argument
354 mDNSu16 len = htons((mDNSu16)pkt->len); in SendPacket()
359 ntohs(pkt->msg.h.numQuestions), in SendPacket()
360 ntohs(pkt->msg.h.numAnswers), in SendPacket()
361 ntohs(pkt->msg.h.numAuthorities), in SendPacket()
362 ntohs(pkt->msg.h.numAdditionals)); in SendPacket()
363 return MySend(sock, &pkt->msg, pkt->len); in SendPacket()
423 PktMsg * pkt = NULL; in RecvPacket() local
441 pkt = storage; in RecvPacket()
456 pkt = malloc(allocsize); in RecvPacket()
457 require_action_quiet( pkt, exit, err = mStatus_NoMemoryErr; LogErr( "RecvPacket", "malloc" ) ); in RecvPacket()
458 mDNSPlatformMemZero( pkt, sizeof( *pkt ) ); in RecvPacket()
461 pkt->len = msglen; in RecvPacket()
462 srclen = sizeof(pkt->src); in RecvPacket()
464 …if ( getpeername( fd, ( struct sockaddr* ) &pkt->src, &srclen ) || ( srclen != sizeof( pkt->src ) … in RecvPacket()
467 mDNSPlatformMemZero(&pkt->src, sizeof(pkt->src)); in RecvPacket()
470 nread = my_recv(sock, &pkt->msg, msglen, closed ); in RecvPacket()
473 …action_quiet( pkt->len >= sizeof( DNSMessageHeader ), exit, err = mStatus_UnknownErr ; Log( "RecvP… in RecvPacket()
477 if ( err && pkt ) in RecvPacket()
479 if ( pkt != storage ) in RecvPacket()
481 free(pkt); in RecvPacket()
484 pkt = NULL; in RecvPacket()
487 return pkt; in RecvPacket()
531 mDNSlocal mDNSBool IsQuery( PktMsg * pkt ) in IsQuery() argument
533 …return ( pkt->msg.h.flags.b[0] & kDNSFlag0_QROP_Mask ) == (mDNSu8) ( kDNSFlag0_QR_Query | kDNSFlag… in IsQuery()
537 mDNSlocal mDNSBool IsUpdate( PktMsg * pkt ) in IsUpdate() argument
539 return ( pkt->msg.h.flags.b[0] & kDNSFlag0_QROP_Mask ) == (mDNSu8) ( kDNSFlag0_OP_Update ); in IsUpdate()
543 mDNSlocal mDNSBool IsNotify(PktMsg *pkt) in IsNotify() argument
545 return ( pkt->msg.h.flags.b[0] & kDNSFlag0_QROP_Mask ) == ( mDNSu8) ( kDNSFlag0_OP_Notify ); in IsNotify()
549 mDNSlocal mDNSBool IsLLQRequest(PktMsg *pkt) in IsLLQRequest() argument
551 const mDNSu8 *ptr = NULL, *end = (mDNSu8 *)&pkt->msg + pkt->len; in IsLLQRequest()
556 HdrNToH(pkt); in IsLLQRequest()
557 …if ((mDNSu8)(pkt->msg.h.flags.b[0] & kDNSFlag0_QROP_Mask) != (mDNSu8)(kDNSFlag0_QR_Query | kDNSFla… in IsLLQRequest()
559 if (!pkt->msg.h.numAdditionals) goto end; in IsLLQRequest()
560 ptr = LocateAdditionals(&pkt->msg, end); in IsLLQRequest()
564 for (i = 0; i < pkt->msg.h.numAdditionals; i++) in IsLLQRequest()
566 ptr = GetLargeResourceRecord(NULL, &pkt->msg, ptr, end, 0, kDNSRecordTypePacketAdd, &lcr); in IsLLQRequest()
576 HdrHToN(pkt); in IsLLQRequest()
581 mDNSlocal mDNSBool IsLLQAck(PktMsg *pkt) in IsLLQAck() argument
583 …if ((pkt->msg.h.flags.b[0] & kDNSFlag0_QROP_Mask ) == (mDNSu8) ( kDNSFlag0_QR_Response | kDNSFlag0… in IsLLQAck()
584 pkt->msg.h.numQuestions && !pkt->msg.h.numAnswers && !pkt->msg.h.numAuthorities) return mDNStrue; in IsLLQAck()
627 PktMsg * pkt in SetZone() argument
632 const mDNSu8 * ptr = pkt->msg.data; in SetZone()
637 pkt->zone = NULL; in SetZone()
638 pkt->isZonePublic = mDNStrue; in SetZone()
643 QR_OP = ( mDNSu8 ) ( pkt->msg.h.flags.b[0] & kDNSFlag0_QROP_Mask ); in SetZone()
645 if ( IsQuery( pkt ) ) in SetZone()
651 ptr = getQuestion( &pkt->msg, ptr, ( ( mDNSu8* ) &pkt->msg ) + pkt->len, NULL, &question ); in SetZone()
657 else if ( IsUpdate( pkt ) ) in SetZone()
664 ptr = getQuestion( &pkt->msg, ptr, ( ( mDNSu8* ) &pkt->msg ) + pkt->len, NULL, &question ); in SetZone()
675 for ( pkt->zone = self->zones; pkt->zone; pkt->zone = pkt->zone->next ) in SetZone()
677 if ( ZoneHandlesName( &pkt->zone->name, &zname ) ) in SetZone()
679 VLog( "found correct zone %##s for query", pkt->zone->name.c ); in SetZone()
681 pkt->isZonePublic = ( ( pkt->zone->type == kDNSZonePublic ) || exception ); in SetZone()
683 VLog( "zone %##s is %s", pkt->zone->name.c, ( pkt->isZonePublic ) ? "public" : "private" ); in SetZone()
880 mDNSlocal mDNSu8 *PutUpdateSRV(DaemonInfo *d, DNSZone * zone, PktMsg *pkt, mDNSu8 *ptr, char *regty… in PutUpdateSRV() argument
884 mDNSu8 *end = (mDNSu8 *)&pkt->msg + sizeof(DNSMessage); in PutUpdateSRV()
900 if (registration) ptr = PutResourceRecord(&pkt->msg, ptr, &pkt->msg.h.mDNS_numUpdates, &rr.resrec); in PutUpdateSRV()
901 else ptr = putRRSetDeletion(&pkt->msg, ptr, end, &rr.resrec); in PutUpdateSRV()
919 PktMsg pkt; in UpdateSRV() local
920 mDNSu8 *ptr = pkt.msg.data; in UpdateSRV()
921 mDNSu8 *end = (mDNSu8 *)&pkt.msg + sizeof(DNSMessage); in UpdateSRV()
927 InitializeDNSMessage(&pkt.msg.h, zeroID, UpdateReqFlags); in UpdateSRV()
928pkt.src.sin_addr.s_addr = zerov4Addr.NotAnInteger; // address field set solely for verbose logging… in UpdateSRV()
929 pkt.src.sin_family = AF_INET; in UpdateSRV()
932 ptr = putZone(&pkt.msg, ptr, end, &zone->name, mDNSOpaque16fromIntVal(kDNSClass_IN)); in UpdateSRV()
937 … ptr = PutUpdateSRV(d, zone, &pkt, ptr, "_dns-update-tls._tcp.", d->private_port, registration); in UpdateSRV()
939 … ptr = PutUpdateSRV(d, zone, &pkt, ptr, "_dns-query-tls._tcp.", d->private_port, registration); in UpdateSRV()
941 … ptr = PutUpdateSRV(d, zone, &pkt, ptr, "_dns-llq-tls._tcp.", d->private_port, registration); in UpdateSRV()
946 ptr = PutUpdateSRV(d, zone, &pkt, ptr, "_dns-update._udp.", d->llq_port, registration); in UpdateSRV()
948 ptr = PutUpdateSRV(d, zone, &pkt, ptr, "_dns-llq._udp.", d->llq_port, registration); in UpdateSRV()
956 ptr = PutUpdateSRV(d, zone, &pkt, ptr, "_dns-update-tls.", d->private_port, registration); in UpdateSRV()
958 ptr = PutUpdateSRV(d, zone, &pkt, ptr, "_dns-query-tls.", d->private_port, registration); in UpdateSRV()
960 ptr = PutUpdateSRV(d, zone, &pkt, ptr, "_dns-llq-tls.", d->private_port, registration); in UpdateSRV()
964 ptr = PutUpdateSRV(d, zone, &pkt, ptr, "_dns-update._udp.", d->llq_port, registration); in UpdateSRV()
966 ptr = PutUpdateSRV(d, zone, &pkt, ptr, "_dns-llq._udp.", d->llq_port, registration); in UpdateSRV()
970 HdrHToN(&pkt); in UpdateSRV()
974 DNSDigest_SignMessage( &pkt.msg, &ptr, zone->updateKeys, 0 ); in UpdateSRV()
978 pkt.len = ptr - (mDNSu8 *)&pkt.msg; in UpdateSRV()
982 err = SendPacket( sock, &pkt ); in UpdateSRV()
988 ok = SuccessfulUpdateTransaction( &pkt, reply ); in UpdateSRV()
1295 PktMsg pkt; in DeleteOneRecord() local
1296 mDNSu8 *ptr = pkt.msg.data; in DeleteOneRecord()
1297 mDNSu8 *end = (mDNSu8 *)&pkt.msg + sizeof(DNSMessage); in DeleteOneRecord()
1304 InitializeDNSMessage(&pkt.msg.h, zeroID, UpdateReqFlags); in DeleteOneRecord()
1306 ptr = putZone(&pkt.msg, ptr, end, zname, mDNSOpaque16fromIntVal(rr->resrec.rrclass)); in DeleteOneRecord()
1308 ptr = putDeletionRecord(&pkt.msg, ptr, &rr->resrec); in DeleteOneRecord()
1311 HdrHToN(&pkt); in DeleteOneRecord()
1317 DNSDigest_SignMessage(&pkt.msg, &ptr, zone->updateKeys, 0 ); in DeleteOneRecord()
1321 pkt.len = ptr - (mDNSu8 *)&pkt.msg; in DeleteOneRecord()
1322pkt.src.sin_addr.s_addr = zerov4Addr.NotAnInteger; // address field set solely for verbose logging… in DeleteOneRecord()
1323 pkt.src.sin_family = AF_INET; in DeleteOneRecord()
1324 if (SendPacket( sock, &pkt)) { Log("DeleteOneRecord: SendPacket failed"); } in DeleteOneRecord()
1329 if (!SuccessfulUpdateTransaction(&pkt, reply)) in DeleteOneRecord()
1374 mDNSlocal void UpdateLeaseTable(PktMsg *pkt, DaemonInfo *d, mDNSs32 lease) in UpdateLeaseTable() argument
1386 HdrNToH(pkt); in UpdateLeaseTable()
1387 ptr = pkt->msg.data; in UpdateLeaseTable()
1388 end = (mDNSu8 *)&pkt->msg + pkt->len; in UpdateLeaseTable()
1389 ptr = getQuestion(&pkt->msg, ptr, end, 0, &zone); in UpdateLeaseTable()
1391 ptr = LocateAuthorities(&pkt->msg, end); in UpdateLeaseTable()
1394 for (i = 0; i < pkt->msg.h.mDNS_numUpdates; i++) in UpdateLeaseTable()
1398 ptr = GetLargeResourceRecord(NULL, &pkt->msg, ptr, end, 0, kDNSRecordTypePacketAns, &lcr); in UpdateLeaseTable()
1459 tmp->cli.sin_addr = pkt->src.sin_addr; in UpdateLeaseTable()
1471 HdrHToN(pkt); in UpdateLeaseTable()
1709 mDNSlocal int SendLLQ(DaemonInfo *d, PktMsg *pkt, struct sockaddr_in dst, TCPSocket *sock) in SendLLQ() argument
1714 HdrHToN(pkt); in SendLLQ()
1718 if ( SendPacket( sock, pkt ) != 0 ) in SendLLQ()
1726 …if (sendto(d->llq_udpsd, &pkt->msg, pkt->len, 0, (struct sockaddr *)&dst, sizeof(dst)) != (int)pkt in SendLLQ()
1734 HdrNToH(pkt); in SendLLQ()
2304 PktMsg * pkt in RecvNotify() argument
2310 pkt->msg.h.flags.b[0] |= kDNSFlag0_QR_Response; in RecvNotify()
2312 …res = sendto( d->udpsd, &pkt->msg, pkt->len, 0, ( struct sockaddr* ) &pkt->src, sizeof( pkt->src )… in RecvNotify()
2313 …require_action( res == ( int ) pkt->len, exit, err = mStatus_UnknownErr; LogErr( "RecvNotify", "se… in RecvNotify()
2321 mDNSlocal int RecvLLQ( DaemonInfo *d, PktMsg *pkt, TCPSocket *sock ) in RecvLLQ() argument
2327 const mDNSu8 *qptr = pkt->msg.data; in RecvLLQ()
2328 const mDNSu8 *end = (mDNSu8 *)&pkt->msg + pkt->len; in RecvLLQ()
2333 HdrNToH(pkt); in RecvLLQ()
2334 aptr = LocateAdditionals(&pkt->msg, end); // Can't do this until after HdrNToH(pkt); in RecvLLQ()
2335 inet_ntop(AF_INET, &pkt->src.sin_addr, addr, 32); in RecvLLQ()
2339 if (!pkt->msg.h.numQuestions || !pkt->msg.h.numAdditionals) in RecvLLQ()
2341 …rmatted LLQ from %s with %d questions, %d additionals", addr, pkt->msg.h.numQuestions, pkt->msg.h.… in RecvLLQ()
2349 for (i = 0; i < pkt->msg.h.numAdditionals; i++) in RecvLLQ()
2351 aptr = GetLargeResourceRecord(NULL, &pkt->msg, aptr, end, 0, kDNSRecordTypePacketAdd, &opt); in RecvLLQ()
2358pkt->msg.h.numQuestions * DNSOpt_LLQData_Space) { Log("Malformatted LLQ from %s: OPT RR to small (… in RecvLLQ()
2361 for (i = 0; i < pkt->msg.h.numQuestions; i++) in RecvLLQ()
2363 qptr = getQuestion(&pkt->msg, qptr, end, 0, &q); in RecvLLQ()
2368 e = LookupLLQ(d, pkt->src, &q.qname, q.qtype, &llq->id); in RecvLLQ()
2372 e = NewLLQ(d, pkt->src, &q.qname, q.qtype, llq->llqlease ); in RecvLLQ()
2375 UpdateLLQ(d, e, llq, pkt->msg.h.id, sock); in RecvLLQ()
2380 HdrHToN(pkt); in RecvLLQ()
2385 mDNSlocal mDNSBool IsAuthorized( DaemonInfo * d, PktMsg * pkt, DomainAuthInfo ** key, mDNSu16 * rco… in IsAuthorized() argument
2390 mDNSu8 * end = ( mDNSu8* ) &pkt->msg + pkt->len; in IsAuthorized()
2401 HdrNToH(pkt); in IsAuthorized()
2405 if ( pkt->msg.h.numAdditionals ) in IsAuthorized()
2407 ptr = LocateAdditionals(&pkt->msg, end); in IsAuthorized()
2410 for (i = 0; i < pkt->msg.h.numAdditionals; i++) in IsAuthorized()
2413 ptr = GetLargeResourceRecord(NULL, &pkt->msg, ptr, end, 0, kDNSRecordTypePacketAdd, &lcr); in IsAuthorized()
2432 if ( !pkt->zone ) in IsAuthorized()
2439 if ( IsQuery( pkt ) ) in IsAuthorized()
2441 keys = pkt->zone->queryKeys; in IsAuthorized()
2444 else if ( IsUpdate( pkt ) ) in IsAuthorized()
2446 keys = pkt->zone->updateKeys; in IsAuthorized()
2456 if ( pkt->isZonePublic ) in IsAuthorized()
2466 Log( "Invalid TSIG spec %##s for zone %##s", lcr.r.resrec.name->c, pkt->zone->name.c ); in IsAuthorized()
2486 Log( "Invalid TSIG name %##s for zone %##s", lcr.r.resrec.name->c, pkt->zone->name.c ); in IsAuthorized()
2497 pkt->msg.h.numAdditionals--; in IsAuthorized()
2499 HdrHToN( pkt ); in IsAuthorized()
2501 ok = DNSDigest_VerifyMessage( &pkt->msg, ( mDNSu8* ) lastPtr, &lcr, (*key), rcode, tcode ); in IsAuthorized()
2503 HdrNToH( pkt ); in IsAuthorized()
2505 pkt->msg.h.numAdditionals++; in IsAuthorized()
2513 pkt->msg.h.numAdditionals--; in IsAuthorized()
2514 pkt->len = lastPtr - ( mDNSu8* ) ( &pkt->msg ); in IsAuthorized()
2517 HdrHToN(pkt); in IsAuthorized()
2539 reply = HandleRequest( context->d, &context->pkt ); in UDPMessageHandler()
2542 …d, &reply->msg, reply->len, 0, ( struct sockaddr* ) &context->pkt.src, sizeof( context->pkt.src ) … in UDPMessageHandler()
2583 …res = recvfrom(sd, &context->pkt.msg, sizeof(context->pkt.msg), 0, (struct sockaddr *)&context->cl… in RecvUDPMessage()
2586 context->pkt.len = res; in RecvUDPMessage()
2588 context->pkt.src = context->cliaddr; in RecvUDPMessage()
2592 SetZone( context->d, &context->pkt ); in RecvUDPMessage()
2596 if ( IsNotify( &context->pkt ) ) in RecvUDPMessage()
2598 int e = RecvNotify( self, &context->pkt ); in RecvUDPMessage()
2602 else if ( IsAuthorized( context->d, &context->pkt, &key, &rcode, &tcode ) ) in RecvUDPMessage()
2604 if ( IsLLQRequest( &context->pkt ) ) in RecvUDPMessage()
2607 int e = RecvLLQ( self, &context->pkt, NULL ); in RecvUDPMessage()
2612 if ( IsLLQAck(&context->pkt ) ) in RecvUDPMessage()
2630 memcpy( &reply, &context->pkt, sizeof( PktMsg ) ); in RecvUDPMessage()
2635 … sd, &reply.msg, reply.len, 0, ( struct sockaddr* ) &context->pkt.src, sizeof( context->pkt.src ) … in RecvUDPMessage()
2684 reply = HandleRequest( context->d, &context->pkt ); in TCPMessageHandler()
2716 PktMsg * pkt; in RecvTCPMessage() local
2725 pkt = RecvPacket( context->sock, &context->pkt, &closed ); in RecvTCPMessage()
2726 if (pkt) HdrNToH(pkt); in RecvTCPMessage()
2727 require_action( pkt || !closed, exit, err = mStatus_UnknownErr; LogMsg( "client disconnected" ) ); in RecvTCPMessage()
2729 if ( pkt ) in RecvTCPMessage()
2739 SetZone( context->d, &context->pkt ); in RecvTCPMessage()
2744 if ( IsAuthorized( context->d, &context->pkt, &key, &rcode, &tcode ) ) in RecvTCPMessage()
2746 if ( IsLLQRequest( &context->pkt ) ) in RecvTCPMessage()
2749 RecvLLQ( context->d, &context->pkt, context->sock); in RecvTCPMessage()
2773 …LogMsg( "Client %s Not authorized for zone %##s", inet_ntoa( context->pkt.src.sin_addr ), pkt->zon… in RecvTCPMessage()
2775 memcpy( &reply, &context->pkt, sizeof( PktMsg ) ); in RecvTCPMessage()