Hello, I need help with the new queue system pf, what I want is to know how
to add a rule in c using pfvar.h, so far what I have is this:

#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/fcntl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <net/pfvar.h>

int main()
{
        struct pfioc_queue q;
        int device;

        if( device < 0 )
                err( 1 , "open Error: " );

        memset( &q, '\0', sizeof( q ) );

        if( ioctl( device, DIOCGETQUEUES, &q ) < 0 ){
                err( 1 , "DIOCGETQUEUES Error: " );
                return 0;
        }

        strlcpy( q.queue.qname , "ID1b" , sizeof( "ID1b" ) );
        strlcpy( q.queue.parent , "full_bajada" , sizeof( "full_bajada" ) );
        strlcpy( q.queue.ifname , "em0" , sizeof( "em0" ) );
        q.queue.qlimit = 50;
        q.queue.qid = 10;
        q.queue.qid = 10;
        q.queue.parent_qid = 2;
        q.queue.linkshare.m1.absolute = 512000;
        q.queue.linkshare.m2.absolute = 512000;
        q.queue.upperlimit.m1.absolute = 1024000;
        q.queue.upperlimit.m2.absolute = 1024000;

        if( ioctl( device, DIOCADDQUEUE , &q ) < 0 ){
                err( 1 , "DIOCADDQUEUE Error: " );
                return 0;
        }

        return 0;
}

The code does not throw any errors, but I have doubts about how to get the
ticket, and if something is missing because "pfctl -sq" no new queue
appears.

I get not really understand how it works, if anyone can give me a simple
code example will appreciate.

Reply via email to