I need to modify mount app, so that I can specify the source port to be one specific one not the randomly generated by the OS.
For example lets say we are trying to mount a filesystem in a computer with ip 10.0.0.55 and our computer where we going to be executing the mount is 10.0.0.40
so when you do the command the destination port (ie the port 10.0.0.55 is listening ) is fine but when you do the command the source port is randomly generated by the os and that is the port 10.0.0.55 uses to reply back to the other pc that pc is behind a router so there have to be an specific port
Any ideas I have tried modifying where the function bindresvport() is called and binding that socket to an specific port but it doesnt seem to work
I already solve this, the answer was to create a new struct sockaddr, open a socket for that struct bind it to the port you want and then call connect to the struct that the mount client is using and with you socket. That way you force the kernel not to choose the src port for you. Note that you will have to do the same when you are going to ask the server (Where the filesystem you are trying to mount is) for the file handles. Also in the end of the mount client calls the mount function from the kernel and it puts a random port again for the src port, so this approach is good if you want to modify the kernel as well.
Maybe I did not explain myself well, when I made the question but what I was trying to accomplish was to mount a filesystem in Computer A from Computer B. Computer A is behind a router Computer B is on the router's outside network or like the isp network
For Example
Computer A will have lets said 192.168.1.99 Router (Gateway) 192.168.1.1 Router Wan Ip 10.0.0.26 Computer B 10.0.0.55
so in order for computer B to talk to computer A there have to be a port opened in Router to allow the traffic to go through. And when you issue a mount the src port is generated randomly in the range 512-1023 and happens to be the same port that computer B sends info to. I solve this by open it up that range on the router, It was not an option for me to modify the kernel. I hope this helps @mikea