Hello, my name is Stephen and moving forward with our exploration, let's delve into the subsequent
stages of our program development.
So we will be deciphering each steps involved in detail, enabling you to gain an in-depth understanding
of the underlying mechanisms.
So without further ado, let's break down the our code here, which is going to be.
We will need this port to convert it into bytes.
Uh, so in order to do that, we will again use the Python tool.
And what we're going to do is we will import sockets.
Import socket and hex here.
Socket socket dot h.
So I will explain why what we why we did that.
So 7331.
This is this was our port number and that's it.
So this is our output here.
Let's take this and write it.
Note it down somewhere like here.
So.
And.
In this, um, phase.
Here we are translating the port number to a format that suits networking requirements.
So this is a crucial for ensuring the consistent communication across different systems.
So the port number uh uh 7331 uh when converted to it it's H turns which is uh host to network short
form becomes 0XA uh 31 C.
So basically E 31 z.
And this zero x uh tells us that this is a hexadecimal character.
So this transformation serves as important step in preparing our program for efficient networking operations.
And now we will create our, um, here.
Yeah, we will create our assembly code.
So this code is going to be long and interesting way to do so.
We will write it down phase by phase.
So now what we're going to do is we will let's actually name this the TCP bind dot asm here.
And uh without anything we will just xor uh XOR.
Racks.
So we will push the racks here again.
And after that we will push the world here.
So we will push this as world here.
And a 30 1CI guess.
Yeah a 31 C.
And after that we will pass the word.
0X02.
So here we are preparing the groundwork for setting up our circuit structure by encoding the necessary
values.
So but before that let's actually write it down that uh passing port here port number.
Now here we start by setting Rax register to zero using x or x rax.
And this initializes rax to serve as a holder for upcoming values.
And we then push the value of rax onto the stack.
This action ensures that the stack remains aligned as we perform further operations, and following
this, we push the uh, a 31 C value onto the stack using the push word uh 0X8 31 C.
So this value represents our previously converted port number in H two format.
And uh, after that, finally we push the value 0X0 stack onto the stack.
So this value corresponds to the protocol identifier for AF init.
So indicating that we are working with the IP version uh for here.
So actually I want to note this down here and this two here.
So port h I think.
Yeah h h turns h turn format to three.
No 77331.
And after that we have this, which is.
We are.
Indicating that we are working with IP version four and that's why.
Indicator for IP version.
IP version four.
Which is also called af init.
And after that, having our structure set.
Let's prepare the bind function here.
So with this bind function we will go to.
Now, um, this see here again.
And now what we're going to do is we will.
Here.
We have already, actually.
And mice and mice the size of my socket address.
Yes.
So we actually already developed this band mind function here.
This function takes three arguments.
The first one is my sock, my socket feed here, which is already stored in the RDA register.
The second is our structure in the form of a reference here.
And the third is length of the length of the length of our structure, which is somewhere like 816.
So now what's left is um, to do get the bind fiscal number.
So you learned how we need to get this bind fiscal number.
And uh here we will use cat again create here clear cat.
USR include x86 64 Linux GNU here.
ASM here.
Uh en este en este de.
Yeah.
Uh NIST 64 dot h.
Uh pip here grep bind.
Now this is our bind here.
So this command is instrumental in pinpointing the precise numeric code assigned to the bind system
call.
So this numeric code serves as the key to unlocking the functionality of the operating system.
So throughout the explanation of the output we can extract the essential information we require here.
And let's uh continue noting down here.
So syscall for um.
Bind.
Bind is 49.
And after that.
Uh, as we advance, uh, let's let's transition our focus to the creation of bind system call.
It is a pivotal step in orchestrating our communication infrastructure.
So the bind system call acts as linchpin.
So bridging the gap between our programming realm and the underlying operating system.
So let's go through the code step by step here.
So now we will also um sorry here.
Now we will also here bind here which is 49.
Now we will move the we will move the RSI, RSP, the XOR, RDX, RDX and add RDX 16 now 16 and XOR
racks racks again and add racks 49.
And Cisco.
And here we are assembling the ingredients over for the bind system call.
So we are preparing the RSI Register here to hold the address of our socket socket infrastructure.
Socket structure.
So this structure houses information important to our networking operation.
And by executing uh ECS or RDX, RDX, we are efficiently and effectively clearing the RDX register,
ensuring that it's ready to serve its purpose.
And subsequently we are adding 16 to the RDX register.
So this value corresponds to the size of our socket structure, aligning it appropriately for the subsequent
system call and to initiate bind system call, we are setting the Rax register to zero using Xrx rax.
So we are then adding the uh bind syscall number, which is 49 as we've seen, and to the Rax register.
So with all the components aligned, we finalized, uh, we finalize this phase by executing this syscall
instruction, triggering the operation operating system to carry out the bind operation.
Now, uh, let's set the listen function, which takes the two arguments here.
Um, it should be.
Yeah.
We are.
Yeah.
And here this is our listen here.
That's actually why we do that.
Completed in assembly.
So completed in assembly here.
We also do that.
So why we are writing converting this code into the assembly code.
So let's actually add comments that we have completed it.
So no this hasn't completed yet.
Here.
Yeah.
Also, this line of code also completed here.
Perfect.
And here we need to.
And this step on our journey is to configure the listen function.
This is a key element in refining um to access like for listening here.
And this is actually very important for service behavior.
And now let's uh breaking down break.
Okay.
Let's break down the arguments of the lesson function.
So the first argument my feet my feet here refers to the socket file descriptor descriptor, our gateway
to networking interactions here.
And we already stored this in this RDA register.
Remember somewhere this here right.
And also we have won.
The second argument one signifies the maximum number of connections the server is ready to accept,
and in this concept, we are allowing only one incoming connections because we don't want to be two
hackers in one target here.
Right.
So, uh, and what we're going to do here, uh, we will need to call the.
Listen here.
So we will need to get listen Siskel number here.
So we will do the same procedure here.
This we will need to change bind to listen here list not list.
Listen.
And this is 50.
That's it.
Right.
So the bind was 49 and listen was 50.
Yeah that's okay.
So by executing this command we pinpoint the number code associated with the listen system call.
So this code acts as a trigger for operating system to facilitate the listen action, setting the stage
for the server to anticipate and manage incoming connections.
And uh, now let's actually write that, uh, keep this knot somewhere here.
So remember listen for listen or Cisco Cisco or listen.
And that's it.
So we can go to back, go back to our assembly and we will use the listen, listen.
15.
And here we will build our assembly code here.
Now yeah, we did bind and we just need to write our, um.
Listen, uh, before except of course.
And yeah, we will do the same with the bind.
And yes, yeah, we will do the same with the bind.
But we will use to resize so we will.
We will like define our size as zero before.
Yeah.
So xor xor are racks racks here again.
Mhm.
Mm mm mm mm.
And that's it.
So we will add uh we will make racks.
Where is it?
Should be Rax or RDX?
No.
It's 50.
Because of the lesson.
Yeah, we did the same here, remember?
Now we will use XOR.
I will explain all of this here right now.
RSI, RSI and inverse.
Here we will know I and C.
Just yeah Inc RSI.
And after that, uh, Cisco.
That's it.
And now in this, uh, example, let's, uh, actually explain this.
So here we are constructing the here, here we are constructing the ingredients for invoking the bind
system call.
So by executing XOR rax rax we are ensuring that Rax register is set to zero.
This is a foundational step in the Cisco system call processes.
And we have the incrementing a value in racks by 50, effectively assigning it the listen syscall number
and to prepare the RSA register.
Um, to prepare the RSA register for usage, we execute XOR, rsa, rc, ensuring it's initialized for
forthcoming actions.
Furthermore, RSA was.
Incremented its value by one using ink.
RSI, so this action aligns RSI to serve as a placeholder for arguments.
And finally, syscall instruction is executed, serving as the conduit through which the operating system
enacts the bind.
Uh.
Listen.
Action!
Aligning our, uh, server for interaction.
And here, uh, now we will need to write the.
Except here.
So except let's see what is except here.
So also let's.
Listen.
We have and accept.
So complete an assembly.
Not yet.
But actually we will do that.
Now, what we're going to do is, um, as a progress, the accept function takes the center stage.
So driving the evolution of our program.
So let's delve into the intricacies of the arguments and implications of implications of this function.
So the first argument here, uh, my client Ph.D..
Signifies that.
No.
Actually, um, do we need to use this for the clients or.
I think we previously we.
Client if the except.
My secret.
Yeah, this is correct code here.
So here, uh, my client.
If we are creating this new variable.
This is not new.
We actually created this somewhere here.
We defined this here.
Yeah.
My circle.
My client.
My.
Yeah.
My client.
Where are you?
Yeah.
My client display here.
So this is integer.
But here we are accepting.
Hear this?
My socket, my sock feet signifies the file descriptor.
This is a gateway to our networking endeavors.
So this parameter has been that will be stored in the RDA register positioning us for seamless interaction.
And the second and third argument are deliberately set to null.
By doing so, we are essentially indicating that we are not providing specific client information or
additional context at this stage.
So now we will do the same to get the accept syscall number.
We will.
Let's actually accept I think it will.
It should be like 51 I think.
Let's try this.
Accept.
Oh no 43.
So, Siskel.
Or accept.
And 43.
So executing this command here in the terminal and label is enables us to identify the numeric code
assigned to the accept system call.
So this numeric representation plays a pivotal role in conveying our intentions to the programming and
know the intentions the operating system.
So facilitating the accept operation with precision.
So with each step we are delving deeper into the intricacies of networking programming and system system
calls.
Now let's proceed to analyze the subsequent uh, sections of code here.
So now what we're going to do is we will also create our accepts here.
Um, let's bind accept.
It was 43 I think.
Yeah 43.
Now we will do X or.
Rags.
Racks again.
Here.
No, no.
Here.
Yeah.
Exo racks.
Racks and racks 43 and exo RSI.
RSI X or.
RDX.
That's it.
And that's that.
Of course, we need to call this fiscal as we always do.
Now here in this code, we are moving the output of the accept function, which is stored in the Rax
register and represents the client, my client feet to more secure location, the RDX register.
So, um, this maneuver ensures that the data is safeguarded, allowing us to work with it more efficiently.
And after that.
What are we going to do here is let's actually.
Yeah, we're done with this here.
And.
Remember we had this course here in TCP bind.
See?
Here.
Uh, the DUP two, DUP two here.
So we set set this.
My client left my client left my client F10 012.
And each of these parameters means something uh, to our C program here to our system.
And which we will do that in next lecture.
So I'm waiting to the next lecture.