Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!inferno.mpx.com.au!nsw1.news.telstra.net!wa.news.telstra.net!news.telstra.net!news-out.internetmci.com!newsfeed.internetmci.com!cpk-news-hub1.bbnplanet.com!cam-news-hub1.bbnplanet.com!news.bbnplanet.com!howland.erols.net!math.ohio-state.edu!jussieu.fr!univ-lyon1.fr!news
From: dfaure@SabPC.resi.insa-lyon.fr (David Faure)
Newsgroups: comp.os.linux.networking,comp.unix.bsd.netbsd.misc
Subject: 'sockaddr' type versus 'osockaddr', under linux & bsd... help!
Date: 25 Mar 1997 22:55:22 GMT
Organization: C.I.S.M. Universite de Lyon 1 / INSA de Lyon
Lines: 40
Message-ID: <5h9l4q$m3f@tempo.univ-lyon1.fr>
NNTP-Posting-Host: i019.resi.insa-lyon.fr
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Newsreader: knews 0.9.8
Xref: euryale.cc.adfa.oz.au comp.os.linux.networking:73440 comp.unix.bsd.netbsd.misc:5705
I'm trying to port back to bsd a linux daemon that was ported to linux,
years ago.
I don't understand the difference between sockaddr and osockaddr
(apart from the fact that sockaddr begins with the length ... that's for
the structure difference ...). When should I use one or the other ?
Under linux (2.0.29), osockaddr, used in the program is defined to be
sockaddr, which is defined as
struct sockaddr
{
unsigned short sa_family; /* address family, AF_xxx */
char sa_data[14]; /* 14 bytes of protocol address */
}; /* from socket.h */
Under bsd (netbsd), it appears that osockaddr is exactly the same thing
as below, but that sockaddr is
struct sockaddr {
u_char sa_len; /* total length */
u_char sa_family; /* address family */
char sa_data[14]; /* actually longer; address value */
}; /* from socket.h */
The problem is that I can't use the short version all the time because
all socket functions (connect, sendto, bind ...) require a 'sockaddr *'.
Is it sufficient to use always the 'short' version (sockaddr under linux and
osockaddr under bsd) and to typecast for socket system calls ?
Probably not, because it seems that the 'old' protocol requires use of
htons and ntohs for sa_family... I guess it because old is 'u_char' and
new is 'unsigned short'.
Please help getting me out of this *mess* .... Thanks !
Please cc: by mail and post to the newsgroup. Thanks.
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
* David Faure david.faure@ifhamy.insa-lyon.fr
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*