-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Cannot run rpiplay on multiple computers of the same network or pc #244
base: master
Are you sure you want to change the base?
Fix: Cannot run rpiplay on multiple computers of the same network or pc #244
Conversation
…piplay checks gets the mac address of the passed interface, this solve the bug that multiple instances of rpiplay cannot be lauch on the same network address
I recreate the pr cuz last time I set the master branch of my fork now is a separate branch. Original pr: https://github.com/FD-/RPiPlay/pull/230 |
I added an option called --randomMac that allows you to run more than one rpiplay instances on the same pc. With this option a random mac will be calculated, and also it generates a random name for the rpiplay instance Also if you want to set a custom name just simply use the -n option with the --randomMac |
I made the -i option enable to run on macOS. I referred to the following repository to build RPiPlay on macOS and to run it on multiple computers of the same network. |
why do you say multiple instances of rpiplay cannot be launched on the same computer? I can see that if the actual mac address is somehow not found, it is not a good idea to have a hard-coded DEFAULT_HW_ADDRESS, and that should perhaps be randomly chosen, but that would be for different computers on the same network, both of which failed to find their true mac address. Please explain. |
I pulled the lastest version 35dd995 and I can reproduce the problem. I'm using rpiplay on a pc with ArchLinux when I launch the rpiplay with an -n option my ipad is able to connect but when another instance on the same pc is launch with different -n option we can see in the ipad how the first server is renamed to second one. Which env are you using? |
I am on opensuse 15.3. If the two ipads are not mirroring, only the latest server instance shows as available. I'm guessing this is a Bonjour server issue. and your change may be needed for both server choices to be offered simultaneously on the ipad.. |
you probably need to appropriately fix the second hex character modulo 4 in the random mac address. |
what you say about bonjour fits me. Regarding the mac address... You mean second digit means unicast/multicast universally/local, right? @fduncanh If you can confirm if this is what you are referring to. |
This may be a cleaner way to generate a random hw_addr
|
…ayada proposed (I cannot test it as I don't have any macOS device. I believe in the code proposed by yousukeayada works :D)
I made the changes proposed by @fduncanh and also added the macOS that @yousukeayada said. |
memcpy(name, dl->sdl_data, dl->sdl_nlen); | ||
name[dl->sdl_nlen] = '\0'; | ||
addr = (unsigned char*)LLADDR(dl); | ||
if(strcmp(name, interface) == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a space after the if
#endif | ||
|
||
std::string find_mac() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the empty line here
int octet; | ||
for (int i = 0; i < hw_addr.size(); i++) { | ||
if (i == 0) { | ||
octet = rand()%64; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add spaces around the modulo operator
octet = (octet << 1) + LOCAL; | ||
octet = (octet << 1) + MULTICAST; | ||
} else { | ||
octet = rand()%256; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
} else { | ||
octet = rand()%256; | ||
} | ||
hw_addr.at(i) = (char) octet ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the space before the semicolon
Please clarify why -i is what allows to run multiple instance in the same network. That should be working already. |
Also, please improve your formatting |
I also fixed all these issues in UxPlay 1.3x. These is no need for a "-i" option when random mac is implemented. I have got UxPlay to build and run on macOS. The mac just fails to find the true hw_address and just uses the random one, when it is implemented. My inclination would in fact be to reverse things, and actually make a random mac address the default, and include a Linux-specific option to look for the "real" one if that was needed. |
rpiplay checks gets the mac address of the past interface, this solves the bug that multiple instances of rpiplay cannot be launch on the same network address