[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PPP port: iface_Create
From: |
Daniel E Baumann |
Subject: |
Re: PPP port: iface_Create |
Date: |
Sat, 2 Dec 2000 18:56:10 -0600 |
On Saturday 02 December 2000 13:52, Marcus Brinkmann wrote:
> On Sat, Dec 02, 2000 at 12:31:27PM -0600, Daniel E Baumann wrote:
> > I have writen the function to create an iface startuct in PPP using
> > several SIOC* ioctl glibc calls. This is the first time I've used this so
> > I am posting it for inspection, comments and all that.
> >
> > struct ifreq *ifr;
>
> You don't need to dynamically allocate this. Just define it as
>
> struct ifreq ifr;
>
> and set
>
> strncpy (ifr.name, name, IFNAMSIZ);
I had it as just a plain struct before then I made it a pointer. Guess I
should've left it like I had it in the first place :).
> etc
>
> This way, the program flow is a bit simpler, too.
>
> > ioctl(s, SIOCGIFFLAGS, &ifr);
>
> We have this, but ifr isn't initialized yet! You need to set the name.
> Also, the second argument is a struct ifreq **, while you need a struct
> ifreq *. But if you change ifr as above, the code gets correct again :)
So before I use an ifreq I have to set its name. What do you mean the second
argument is a struct ifreq **, I thought it was "int request" like the man
page and header flie says?
> > flags = ifr->ifr_flags;
> >
> > iface->flags = flags;
>
> What about
>
> iface->flags = ifr.ifr_flags;
>
> and drop flags?
Yeah that was stupid, but I thought I might have to set a bunch of temporary
variables. I'll do it the straight forward way without the temporary
variable.
I am also considering factoring this code into a separate file as this part
will be permanent changes as the glibc functionality is/will be there, the
rest of the changes I am leaving as #ifdef'd. I'll probably talk to the
maintainer and see if he's happy with my changes and if he'll incorporate
them upstream. Also, I hasve been using Debian for quite a while and would
like to learn how to make a deb package. Do you think it would be useful to
make a deb of ppp when it's done? I know that you Marcus, probably could do
this with no problem, but I'd like to learn how to make one. I have a
SourceForge account to if that helps any, my user name is baumannd.
Dan
---------------------------------------------------------
Daniel E. Baumann
E-mail:
baumannd@msoe.edu (preferred)
baumannd@users.sourceforge.net
baumannd@penguinpowered.com
baumannd@obfuscation.penguinpowered.com (caution: dynamic DNS)
Web location:
http://www.msoe.edu/~baumannd
http://www.linuxfreak.com/~baumannd
"Life would be so much easier if we could just look at the source code."
-- Dave Olson
"...that as we enjoy great advantages from the inventions of others, we should
be glad of an opportunity to serve others by an invention of ours, and this we
should do freely and generously..."
-- Benjamin Franklin