Login
Username:

Password:

Remember me



Lost Password?

Register now!
Sections
Who's Online
18 user(s) are online (9 user(s) are browsing Forums)

Members: 0
Guests: 18

more...
Support us!
Recent OS4 Files
OS4Depot.net





Quick networking question
Home away from home
Joined:
2007/1/26 21:48
From New Zealand
Posts: 2178
I've posted a quick networking question over on os4coding (link).

Just cross-posting here because I'm not sure how actively developers visit that site.

Hans

_________________
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more.
https://keasigmadelta.com/ - more of my work
   Report Go to top

Re: Quick networking question
Home away from home
Joined:
2006/12/4 23:15
Posts: 2126
@Hans


Answred there:

Quote:


If you are coding on AmigaOS4 and don't require backwards compatabilty the easiest solution is to use the interface.

ie

definetly bsdsocket

ISocket->connect()

Otherwise it's being careful about how you order your includes.

Just adding

#include <proto/bsdsocket.h>

Should be enough in most cases as that wil pull in the inlines and those will replace the functions call with macros referenceing ISocket or SocketBase depending on the target (AmigaOS4 or 68k).

It's little easier to be certain with clib2 as there is a separate libnet.a so not linking against that will give erreors if you messed up your inlcudes.


_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top

Re: Quick networking question
Home away from home
Joined:
2007/1/26 21:48
From New Zealand
Posts: 2178
I've got another networking question: link.

Hans

_________________
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more.
https://keasigmadelta.com/ - more of my work
   Report Go to top

Re: Quick networking question
Home away from home
Joined:
2006/12/4 23:15
Posts: 2126
@Hans

Replied on thread:

here's copy

This code
#include <stdio.h>
 
 
int main
(int argcchar ** argv)
{
    
char host[256];
 
    host
[0] = 0;
 
    gethostname
(host,255);
 
    printf
("host: "%s"n",host); 
}

returns the correct hostname for me

eg

Quote:

ram:testhostname
host: "amiga"


Though that is not not quite what you want as that hostname is local to my SAM 440 on the rest of the network it's defeined as SAM in the various local hosts databases. Using fixed ips on my network so the router doesn't knw the hostnames of the machines.

So what does the hostname command return?

eg here on my SAM I get:
Quote:

10.AmigaOS4:> hostname
amiga

which matches up.

Do you actually want the hostname or the address?


_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top

Re: Quick networking question
Just can't stay away
Joined:
2006/12/1 18:01
From Copenhagen, Denmark
Posts: 1106
As far as I know, any host on the network can define another host in its hosts table using any hostname it likes. It acts as sort of a local "DNS" on that host.

And there is nothing forcing you to give a hostname when you hook up to the LAN - at least not when you use a fixed IP address, and I think also not with DHCP.

So (if I'm correct) it doesn't even necessarily make sense to ask for "the name all hosts call a particular machine".

Why do you need it?

Best regards,

Niels

   Report Go to top

Re: Quick networking question
Home away from home
Joined:
2007/1/26 21:48
From New Zealand
Posts: 2178
@nbache

Quote:
As far as I know, any host on the network can define another host in its hosts table using any hostname it likes. It acts as sort of a local "DNS" on that host.

True, but that's NOT useful, especially when your LAN has a router at its centre that does NOT allow you to set static IP addresses.

Quote:
Why do you need it?

To identify machines on the network in a human readable form in an environment where everyone has a dynamic IP address. The information is there (Avast's Wifi Inspector can read it); I just want to use it.

Hans

_________________
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more.
https://keasigmadelta.com/ - more of my work
   Report Go to top

Re: Quick networking question
Not too shy to talk
Joined:
2011/11/29 0:54
From Norway
Posts: 259
@Hans

never come across routers that don't allow static ip addresses, but i know they exist.. but to change it to static ip, it must be set at the routers settings to make it work.. if that ruter isn't accessible because of dhcp rule, then you need too unplug the dhcp master ruter from it and then change settings.. probably need to reset it first

_________________
Sam460ex 2GB 120Gb SSD&1Tb HD7750 Envy24HT A-Eon Drv 2.10+Warp3D New Uboot
Amiga 1230 33mhz 128MB Indivision ACA 1200 MK2 USB PCMCIA WIFI 60GB&DVD-ROM OS 3.9
AmigaOne X1000 250SSD+1TB 7970
   Report Go to top

Re: Quick networking question
Home away from home
Joined:
2006/12/4 23:15
Posts: 2126
@Hans

Ah so what you need is to get a list of machines on the network and then reverse DNS them to get their names.

Really don't know how to do that except by pinging all possible addresses. Which seems like brute force.

This is where we need Olaf B to join the conversation






_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top

Re: Quick networking question
Amigans Defender
Joined:
2006/11/17 22:40
From England
Posts: 3226
@broadblues

I think it involves ARP tables. I'm not sure if querying from the local machine is sufficient (try "arp -a") or if you need to query the router.

Otherwise you're probably looking at some code to pick up broadcast packets.

I have no idea how either of these things works :D

   Report Go to top

Re: Quick networking question
Home away from home
Joined:
2006/12/4 23:15
Posts: 2126
Interesting arp -a run on my SAM shows my X1000 and my router (fixed ips) but not the Linux laptop or phone that are both using DHCP

_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top

Re: Quick networking question
Home away from home
Joined:
2007/1/26 21:48
From New Zealand
Posts: 2178
@broadblues

Yes, that's what I'm trying to do. My original goal was to just get a usable hostname for the local machine (which AmigaOS doesn't report correctly). However, ultimately I want to be able to identify all machines on the network.

Avast's Wifi Inspector is able to do that,** so it's got to be possible.

Hans


** Probably with the exception of machines in "stealth mode" that don't even respond to pings.

_________________
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more.
https://keasigmadelta.com/ - more of my work
   Report Go to top

Re: Quick networking question
Just popping in
Joined:
2015/9/28 23:42
From Bettendorf, IA, USA
Posts: 213
@Hans

In Workbench Explorer, turn on Preview Pane, go to Computer, what does the line "Network device name:" say for you? The name you want?

   Report Go to top

Re: Quick networking question
Home away from home
Joined:
2007/1/26 21:48
From New Zealand
Posts: 2178
@mritter0

I don't get a "Network device name:" line in the preview pane for Computer. This is with the latest version off os4depot (1.8 01/03/2018).

@broadblues
Quote:
Interesting arp -a run on my SAM shows my X1000 and my router (fixed ips) but not the Linux laptop or phone that are both using DHCP

I've found that I have to ping another machine before it's listed by arp -a. However, only the router's name appears.

Hans

_________________
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more.
https://keasigmadelta.com/ - more of my work
   Report Go to top

Re: Quick networking question
Just popping in
Joined:
2015/9/28 23:42
From Bettendorf, IA, USA
Posts: 213
@Hans

OS4Depot latest is v2.2, Dec 19, 2018. Look again. I think it is what you want.

   Report Go to top

Re: Quick networking question
Home away from home
Joined:
2007/1/26 21:48
From New Zealand
Posts: 2178
@mritter0

Oops! I updated the version on the wrong partition. Running with the actual latest version, the "Network device name" is NOT the same as the hostname that's sent to the DHCP server.

Hans

_________________
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more.
https://keasigmadelta.com/ - more of my work
   Report Go to top

Re: Quick networking question
Home away from home
Joined:
2006/11/20 16:26
From Norway
Posts: 2733
@Hans

Quote:
especially when your LAN has a router at its centre that does NOT allow you to set static IP addresses.


The ip address is normally assigned sequentially, starting with first in the range where normally the last in range, is least likely to be assigned. In that case I use like *.*.*.254 or *.*.*.253 for static ip' etc. or can just pop a router or network bridge that do not suck in-between.

_________________
(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
   Report Go to top

Re: Quick networking question
Home away from home
Joined:
2006/12/4 23:15
Posts: 2126
@Hans

Quote:

I've found that I have to ping another machine before it's listed by arp -a. However, only the router's name appears.


Ah yes that does appear to be the case. The arp table contains the primary host name the IP and the Mac address of the machines that have been connected to from the machine I run 'arp' on.

If I ping an address that doesn;t exist then I get an incomplete record in the table that disappears after a while.


I wonder if the hostname as presented to the router is the one you want to use in practice, if I copy and paste the hostname of my phone from the DHCP table on my router I can't use that as the domain name to ping it only it's address or domain name as defined in my hosts file.

So

ping all possible addresses in subnet
read arp table
discard incomplete entries
?????
profit!






_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top

Re: Quick networking question
Home away from home
Joined:
2007/1/26 21:48
From New Zealand
Posts: 2178
@broadblues

Quote:
ping all possible addresses in subnet
read arp table
discard incomplete entries
?????
profit!

That half works for me. I get the MAC addresses, but the hostnames are still missing. Wifi Inspector must have another trick up its sleeve.

Hans

_________________
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more.
https://keasigmadelta.com/ - more of my work
   Report Go to top





[Advanced Search]


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project