OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::BonjourRequest Struct Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/Utils/Bonjour.hpp>

Collaboration diagram for Slic3r::BonjourRequest:

Static Public Member Functions

static boost::optional< BonjourRequest > make_PTR (const std::string &service, const std::string &protocol)
static boost::optional< BonjourRequest > make_A (const std::string &hostname)
static boost::optional< BonjourRequest > make_AAAA (const std::string &hostname)

Public Attributes

std::vector< char > m_data

Static Public Attributes

static const boost::asio::ip::address_v4 MCAST_IP4 { 0xe00000fb }
static const boost::asio::ip::address_v6 MCAST_IP6 = asio::ip::make_address_v6("ff02::fb")
static const uint16_t MCAST_PORT = 5353

Private Member Functions

 BonjourRequest (std::vector< char > &&data)

Detailed Description

Constructor & Destructor Documentation

◆ BonjourRequest()

Slic3r::BonjourRequest::BonjourRequest ( std::vector< char > && data)
inlineprivate
118: m_data(std::move(data)) {}
std::vector< char > m_data
Definition Bonjour.hpp:112

References m_data.

Referenced by make_A(), make_AAAA(), and make_PTR().

Here is the caller graph for this function:

Member Function Documentation

◆ make_A()

optional< BonjourRequest > Slic3r::BonjourRequest::make_A ( const std::string & hostname)
static
555{
556 // todo: why is this and what is real max
557 if (hostname.size() > 30) {
558 return boost::none;
559 }
560
561 std::vector<char> data;
562 data.reserve(hostname.size() + 18);
563
564 // Add metadata
565 static const unsigned char rq_meta[] = {
566 0x00, 0x00, // Query ID (zero for mDNS)
567 0x00, 0x00, // Flags
568 0x00, 0x01, // One query
569 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Zero Answer, Authority, and Additional RRs
570 };
571 std::copy(rq_meta, rq_meta + sizeof(rq_meta), std::back_inserter(data));
572
573 // Add hostname without .local
574 data.push_back(hostname.size());
575 data.insert(data.end(), hostname.begin(), hostname.end());
576
577 // Add the rest of A record
578 static const unsigned char ptr_tail[] = {
579 0x05, // length of "local"
580 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00,// "local" string and terminator
581 0x00, 0x01, // Type A
582 0x00, 0xff, // Class - 01 is internet 0xff is any
583 };
584 std::copy(ptr_tail, ptr_tail + sizeof(ptr_tail), std::back_inserter(data));
585
586 return BonjourRequest(std::move(data));
587}
BonjourRequest(std::vector< char > &&data)
Definition Bonjour.hpp:118

References BonjourRequest().

Referenced by Slic3r::ResolveSocket::create_requests().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_AAAA()

optional< BonjourRequest > Slic3r::BonjourRequest::make_AAAA ( const std::string & hostname)
static
590{
591 // todo: why is this and what is real max
592 if (hostname.size() > 30) {
593 return boost::none;
594 }
595
596 std::vector<char> data;
597 data.reserve(hostname.size() + 18);
598
599 // Add metadata
600 static const unsigned char rq_meta[] = {
601 0x00, 0x00, // Query ID (zero for mDNS)
602 0x00, 0x00, // Flags
603 0x00, 0x01, // One query
604 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Zero Answer, Authority, and Additional RRs
605 };
606 std::copy(rq_meta, rq_meta + sizeof(rq_meta), std::back_inserter(data));
607
608 // Add hostname without .local
609 data.push_back(hostname.size());
610 data.insert(data.end(), hostname.begin(), hostname.end());
611
612 // Add the rest of A record
613 static const unsigned char ptr_tail[] = {
614 0x05, // length of "local"
615 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, // "local" string and terminator
616 0x00, 0x1c, // Type AAAA
617 0x00, 0xff, // Class - 01 is internet 0xff is any
618 };
619 std::copy(ptr_tail, ptr_tail + sizeof(ptr_tail), std::back_inserter(data));
620
621 return BonjourRequest(std::move(data));
622}

References BonjourRequest().

Referenced by Slic3r::ResolveSocket::create_requests().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_PTR()

optional< BonjourRequest > Slic3r::BonjourRequest::make_PTR ( const std::string & service,
const std::string & protocol )
static
517{
518 if (service.size() > 15 || protocol.size() > 15) {
519 return boost::none;
520 }
521
522 std::vector<char> data;
523 data.reserve(service.size() + 18);
524
525 // Add metadata
526 static const unsigned char rq_meta[] = {
527 0x00, 0x00, // Query ID (zero for mDNS)
528 0x00, 0x00, // Flags
529 0x00, 0x01, // One query
530 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Zero Answer, Authority, and Additional RRs
531 };
532 std::copy(rq_meta, rq_meta + sizeof(rq_meta), std::back_inserter(data));
533
534 // Add PTR query name
535 data.push_back(service.size() + 1);
536 data.push_back('_');
537 data.insert(data.end(), service.begin(), service.end());
538 data.push_back(protocol.size() + 1);
539 data.push_back('_');
540 data.insert(data.end(), protocol.begin(), protocol.end());
541
542 // Add the rest of PTR record
543 static const unsigned char ptr_tail[] = {
544 0x05, // length of "label"
545 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, // "label" string and terminator
546 0x00, 0x0c, // Type PTR
547 0x00, 0xff, // Class ANY
548 };
549 std::copy(ptr_tail, ptr_tail + sizeof(ptr_tail), std::back_inserter(data));
550
551 return BonjourRequest(std::move(data));
552}

References BonjourRequest().

Referenced by Slic3r::LookupSocket::create_request().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_data

std::vector<char> Slic3r::BonjourRequest::m_data

Referenced by BonjourRequest().

◆ MCAST_IP4

const asio::ip::address_v4 Slic3r::BonjourRequest::MCAST_IP4 { 0xe00000fb }
static

◆ MCAST_IP6

const asio::ip::address_v6 Slic3r::BonjourRequest::MCAST_IP6 = asio::ip::make_address_v6("ff02::fb")
static

◆ MCAST_PORT

const uint16_t Slic3r::BonjourRequest::MCAST_PORT = 5353
static

The documentation for this struct was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/Utils/Bonjour.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/Utils/Bonjour.cpp