printingairprintios9.3

Will my AirPrint Code connect to an IPv6-only Printer?


Below is my code to connect to an IPv4 Printer. Everything is OK.

NSString *printerURL = @"ipp://192.168.1.3:631/ipp/print" //IPv4 : OK

UIPrinter *myPrint = [UIPrinter printerWithURL:[NSURL URLWithString:printerURL]];
    [myPrint contactPrinter:^(BOOL available) {
        if(!available){
            // Show error
        }
        [printInteraction printToPrinter:myPrint completionHandler:^(UIPrintInteractionController * _Nonnull printInteractionController, BOOL completed, NSError * _Nullable error) {
            // Print
        }];
    }];

Because I do not have the IpV6 printer, I do not know what will happen with the code below:

NSString *printerURL = @"ipp://FE80::FE3F:DBFF:FE51:6BA:631/ipp/print" //IPv6 : ????

Will it connect to an IPv6 printer?


Solution

  • I don't have an IPv6 printer neither, nor an AirPrint-capable device.

    But I have a suggestion for you, how you could test if your code works for IPv6 connections:

    Here are the detailed steps:

    1. Make sure an IPv6 address is assigned to your MacBook. (How you do that is beyond the scope of this answer.)

    2. Make sure that your MacBook's CUPS services is allowing only IPv6 connections by adding a line to cupsd.conf:

       Listen [xxxx::xxxx:xxxx:xxxx:xxxx]:631
       Listen  /private/var/run/cupsd
       # Port 631
      
    3. Make sure that your cupsd.conf has also this line:

       DefaultAuthType None
      

      This makes sure you'll not need to debug Authentication or Authorization problems on top of your IPv6 and AirPrint functionality. (You can change that back later, once your current problem is solved.)

    4. Create a shared print queue on your MacBook and name it, say, abcd. The queue does not need to connect to an AirPrint device -- any other printer will be "good enough". Also, the printer can also be IPv4-only, or USB, or Bluetooth -- as long as your MacBook can connect to it. (How you do that is beyond the scope of this answer.)

    5. Test your printer: make sure your MacBook prints to it, and make sure that other clients are able to print to the shared queue.

    6. Your Mac clients will now be able to "see" and use your abcd print queue -- but your iOS clients will not (yet) see an AirPrint device.

    7. Now use the dns-sd utility to announce a fake AirPrint device to your local network, pointing to the real print queue named abcd. The general syntax for the command is this:

      dns-sd -P <Name> <Type> <Domain> <Port> <Hostname> <IP> [<TXT>...]
      

      Now to run the real command, open a Terminal.app window and type this:

       dns-sd                 \
         -P AirPrint-abcd     \
         _ipp._tcp,_universal \
         local.               \
         631                  \
         mymacbook.local.                     \
           xxxx::xxxx:xxxx:xxxx:xxxx          \
           pdl="application/pdf,image/urf"    \
           kind="document"                    \
           priority="1"                       \
           product="Model Name of my Printer" \
           rp="printers/abcd"                 \
           URF="DM3"                          \
           Duplex="T"                         \
           Color="T"                          \
           note="Testing AirPrint on MacBook" \
           txtvers="1"                        \
           qtotal="1"                         \
           printer-type="0x0480FFFC"          \
           printer-state="3"                  \
           air="none"                         \
           UUID="54321abc-1234-1234-abcd-ffa8e4bdcbf8"
      

      Here,

      • xxxx::xxxx:xxxx:xxxx:xxxx is the IPv6 address of your MacBook
      • mymacbook is the hostname of your MacBook
    8. Now your iOS client should be able to see and use an AirPrint device named AirPrint-abcd. The service announcement also tells them that the connection path to this AirPrinter is the IPv6 address of your MacBook and the port to use is 631.


    Additional Explanation:

    The -P parameter to the dns-sd utility will make a Bonjour "proxy announcement" to your local LAN/WLAN. For details about this utility see man dns-sd. For more background, see dns-sd.org and these other answers.