What Network Am I Attached To? (Socket Question)

What Network Am I Attached To? (Socket Question)

Post by der Mou » Wed, 17 Mar 1993 02:47:39

> I am writing a program in which I need to write UDP messages to the
> network which my program is running on.

Which network?  The machine you're running on may be multihomed.

Quote:> Is there a standard way to determine the network address of my
> current network?

First you'll have to define "my current network".

Quote:> Please note that I cannot depend upon the high order octet of the
> address to let me know what class of network I'm attached to because
> of subnetting.

The high order bits of the address *do* tell you what class of network
you're on, *by definition*.  A subnet with high bits 10xx, subnetted to
24 bits of network and 8 of host, is still a class B network; it's just
a subnetted class B network.

What you are probably looking for is the SIOCGIFCONF ioctl to get the
list of interfaces, then when you've chosen an interface somehow,
SIOCGIFADDR and SIOCGIFNETMASK to get its address and netmask.
(Actually, the SIOCGIFADDR isn't necessary because SIOCGIFCONF returns
interface addresses as well as names.)

                                        der Mouse


1. Questions about attach (9E), open (2) and deferred attach

Seems there's a potential catch-22 situation between the open (2)
system call & the attach (9E) entry point when a driver is loaded for
the very first time and its device special file doesn't exist yet.
*  open (2) requires attach (9E) to create a device file as its valid
*  attach (9E) needs open (2) to initiate the process of loading the

WDD (Writing Device Driver) has a very brief mention of the "Deferred
Attach" mechanism, where the open (9E) entry point returns ENXIO to
allow attach (9E) to attempt at an unready device.
But what if we have no device number to pass to open (7E) in the first

Also wonder how the user commands devfsadm (1M), drvconfig (1M) and
friends manage to resolve the issue.

For example, putting everything together, curious to see if the
followings are what happen when a new external SCSI hard disk is
attached to a Solaris box. Assume the target minor node, say c1t1d0s0,
is absent from the device tree at the time of running the drvconfig
(1M) command.
1. open (2) system call is invoked to test a range of device candidates
like c0t2d0s0, ..., c0t3d0s0, ..., c1t1d0s0, ...
2. open (7E) entry point returns ENXIO for these candidates and
attempts deferred attachment to them.
3. attach (7E) succeeds with the c1t1d0s0 instance, creates the node
and device files accordingly.

Any idea?

One more thing, can any one please post a sample truss list of the
devfsadm (1M) or drvconfig (1M) command, irrespective of the device
being added.
Pity that there's no R & D machine available to me :-(


2. sendmail redirection

3. ..every socket is attached to a program, but how...

4. Newbie Video question

5. attaching process to socket

6. Full duplex connection problem

7. How to attach socket to file handle

8. Metro-x and dual head display

9. Socket Question: ( Unix Network Programming book)

10. Obscure networking question (shutdown on socket WITHOUT discarding data...)

11. sockets: what am I missing?

12. Help: I am New IN Socket Programming!!

13. What am I doing wrong here (UNIX-domain sockets don't work)?