So in our previous lecture we saw how to capture packets.
Now our next goal would be to start capturing packets.
So in order to capture packets what you need to do is you need to create something called handle.
So you can create handlers using be kept low Brady.
So to do this you have to be kept dot open life function.
So what this function does is that it takes in Chapter several parameters and then it returns a handle
a handle can be tarred as something as like a connection order tool that is used for capturing or filtering
packets over a network.
So as you can see that there are several.
It requires several parameters.
So the first thing it requires is a device name then a snapshot land then promiscuous and then time
out.
So I will explain each of them in detail.
So before I go here I need to create certain variables.
So I will go here and I will create some variables.
So the first thing we need to create is snapshot land.
So snapshot land would be defined as the length of data for each frame.
For example how much data you want to capture in each frame.
So to do this let's say I'm going to create that land and then it would be of type in 32
and then we need to provide the lens.
Let's say you want to capture sixteen hundred votes but frame the next thing you need to do is you need
to define a timeout.
So I'm going to call creativity able call timeout and then I want to block this feature and block the
filtering capability in our program recommends wants to.
So we can use peak cab don't lock forever and this will block forever.
Additionally you start capturing packets.
Then the program exits.
So it will stop execution at this time out and then it will start capturing and displaying packets continuously
again and again and again.
So then we need to define a band called food.
So and as you know that when you're working with fire shall we define several filters for example DCP
dart source and DCP our destination because equals to something like that.
So in this program we have to define certain filters but these filters are specific types for example
there are these are called day something I think maybe of three types of something like that.
So what their goal is that they have a specific syntax and you need to follow this syntax in order to
create a special filter for these type of capturing.
So let's say I'm going to show an example filter and then you can read more about them on the Internet.
So let's say you want to create a packet that is off DCP transmit.
So where DCP protocol and then we want to capture communication that goes over the edge due to be astute
U.P.S. protocol.
In this example I'm going to show you an example lower asked you to be as profitable which is a secure
protocol.
So I am going to write DCP and port and then the port any number which is 443.
So now we have a device name here Step Short land here timeout here and through that here.
So let's go ahead and open it and let's see the documentation once again.
So the first thing is Device name which would be our interface
and then the step Shortland which would be snapped land in our case and that term is promiscuous.
So let's create a new variable here.
Who must give us one of equals to set it to false so promiscuous more means that we want to if it is
true we want to capture everything go over this interface but we don't want to do this or you want to
capture only certain packets.
So I'm going to call promiscuous here and its value is false and then the last thing it requires is
you open documentation.
Here is timeout so I'm going to provide this timeout which is locked forever here.
Timeout.
So now we have we have a function which takes an interface snapshot land promise guess more named timeout.
And then this function will return a handle.
And then we can work with this handle to tell about captured packets.
So it's going to return to variables handle or add if there is no.
If it cannot create any handle then we can simply check from an error if it is not equal to nil.
We can simply panic and exit and the next lecture we will learn how to use this handle to root out and
capture packets.