Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::BonjourRequest Struct Reference

#include <src/slic3r/Utils/Bonjour.hpp>

+ Collaboration diagram for Slic3r::BonjourRequest:

Static Public Member Functions

static boost::optional< BonjourRequestmake_PTR (const std::string &service, const std::string &protocol)
 
static boost::optional< BonjourRequestmake_A (const std::string &hostname)
 
static boost::optional< BonjourRequestmake_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
105: m_data(std::move(data)) {}
std::vector< char > m_data
Definition Bonjour.hpp:99

Member Function Documentation

◆ make_A()

optional< BonjourRequest > Slic3r::BonjourRequest::make_A ( const std::string &  hostname)
static
533{
534 // todo: why is this and what is real max
535 if (hostname.size() > 30) {
536 return boost::none;
537 }
538
539 std::vector<char> data;
540 data.reserve(hostname.size() + 18);
541
542 // Add metadata
543 static const unsigned char rq_meta[] = {
544 0x00, 0x00, // Query ID (zero for mDNS)
545 0x00, 0x00, // Flags
546 0x00, 0x01, // One query
547 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Zero Answer, Authority, and Additional RRs
548 };
549 std::copy(rq_meta, rq_meta + sizeof(rq_meta), std::back_inserter(data));
550
551 // Add hostname without .local
552 data.push_back(hostname.size());
553 data.insert(data.end(), hostname.begin(), hostname.end());
554
555 // Add the rest of A record
556 static const unsigned char ptr_tail[] = {
557 0x05, // length of "local"
558 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00,// "local" string and terminator
559 0x00, 0x01, // Type A
560 0x00, 0xff, // Class - 01 is internet 0xff is any
561 };
562 std::copy(ptr_tail, ptr_tail + sizeof(ptr_tail), std::back_inserter(data));
563
564 return BonjourRequest(std::move(data));
565}
constexpr auto data(C &c) -> decltype(c.data())
Definition span.hpp:195
BonjourRequest(std::vector< char > &&data)
Definition Bonjour.hpp:105

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

+ Here is the caller graph for this function:

◆ make_AAAA()

optional< BonjourRequest > Slic3r::BonjourRequest::make_AAAA ( const std::string &  hostname)
static
568{
569 // todo: why is this and what is real max
570 if (hostname.size() > 30) {
571 return boost::none;
572 }
573
574 std::vector<char> data;
575 data.reserve(hostname.size() + 18);
576
577 // Add metadata
578 static const unsigned char rq_meta[] = {
579 0x00, 0x00, // Query ID (zero for mDNS)
580 0x00, 0x00, // Flags
581 0x00, 0x01, // One query
582 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Zero Answer, Authority, and Additional RRs
583 };
584 std::copy(rq_meta, rq_meta + sizeof(rq_meta), std::back_inserter(data));
585
586 // Add hostname without .local
587 data.push_back(hostname.size());
588 data.insert(data.end(), hostname.begin(), hostname.end());
589
590 // Add the rest of A record
591 static const unsigned char ptr_tail[] = {
592 0x05, // length of "local"
593 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, // "local" string and terminator
594 0x00, 0x1c, // Type AAAA
595 0x00, 0xff, // Class - 01 is internet 0xff is any
596 };
597 std::copy(ptr_tail, ptr_tail + sizeof(ptr_tail), std::back_inserter(data));
598
599 return BonjourRequest(std::move(data));
600}

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

+ 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
495{
496 if (service.size() > 15 || protocol.size() > 15) {
497 return boost::none;
498 }
499
500 std::vector<char> data;
501 data.reserve(service.size() + 18);
502
503 // Add metadata
504 static const unsigned char rq_meta[] = {
505 0x00, 0x00, // Query ID (zero for mDNS)
506 0x00, 0x00, // Flags
507 0x00, 0x01, // One query
508 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Zero Answer, Authority, and Additional RRs
509 };
510 std::copy(rq_meta, rq_meta + sizeof(rq_meta), std::back_inserter(data));
511
512 // Add PTR query name
513 data.push_back(service.size() + 1);
514 data.push_back('_');
515 data.insert(data.end(), service.begin(), service.end());
516 data.push_back(protocol.size() + 1);
517 data.push_back('_');
518 data.insert(data.end(), protocol.begin(), protocol.end());
519
520 // Add the rest of PTR record
521 static const unsigned char ptr_tail[] = {
522 0x05, // length of "label"
523 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, // "label" string and terminator
524 0x00, 0x0c, // Type PTR
525 0x00, 0xff, // Class ANY
526 };
527 std::copy(ptr_tail, ptr_tail + sizeof(ptr_tail), std::back_inserter(data));
528
529 return BonjourRequest(std::move(data));
530}

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

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_data

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

◆ 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: