Hello linux net.

I am trying to write a new connection based stack using the
AF_PACKET interface of linux.
For a simple two way handshake connection, would something like this
do??

//I am writing a bit of pseudo C and a bit of actual linux kernel
functions

connect()
{
    Send a packet contatining my header, with the CONNECT flag set, and
then.

    while (skb_queue_empty (&sk->recieve_queue))
    {
        wait_for_packet (sk);
        //got a packet in our rcv Q, see if its a connection
acknowledge.
        skb = skb_peek (sk->recieve_queue);
        //retrieve our header, check if the CONNECT_ACK flag is set. If
yes, do whatever else is needed and return (0);
    }
}

accept ()
{
    while (skb_queue_empty (&sk->recieive_queue))
    {
        wait_for_packet (sk);

        //got a packet, it should be a connection request, so check that


        skb = skb_peek (sk->recieve_queue);

        //retrieve the header, if its a CONNECT, then send a CONNECT_ACK
packet,
        do whatever else is needed (suplicating the socket, getting a
new fd, etc), then
        return.


    }
}

All this does a 2 way handshake for connection establishment.

Will this work? Any suggestions?

Thanks
Akshay

-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]

Reply via email to