LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 06-05-2009, 12:24 AM   #1
plugo
LQ Newbie
 
Registered: Jun 2009
Posts: 20

Rep: Reputation: 0
proc/net/wireless please HELP


Hello guys, i have some trouble outputting the result of of /proc/net/wireless into my terminal. Somehow it is only showing part of the answer for linkq(), can anybody help me to see what am i missing to display all of the info?? thank you very much.


#include <limits.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <sys/signal.h>
#include <sys/wait.h>
#include <sys/resource.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#define BUFLEN 4096



char *
procread(const char *entry)
{
int fd;
char buf[BUFLEN]="";

if ((fd = open(entry, O_RDONLY)) < 0)
return NULL;
else {
read(fd, buf, BUFLEN);
printf("%s",buf);
close(fd);
return strdup(buf);
}
}


void
linkq(int fd)
{
char *lnq, out[BUFLEN] = "";

if ((lnq = procread("/proc/net/wireless")) == NULL)
write(fd, "could not read /proc/net/wireless\n", BUFLEN);
else {

write(fd, out, strlen(out));
free(lnq);
}
}


int
main()
{
int i;
char t;
for(i=0; i<1; i++)
linkq(t);
return 0;
}
 
Old 06-05-2009, 12:27 AM   #2
plugo
LQ Newbie
 
Registered: Jun 2009
Posts: 20

Original Poster
Rep: Reputation: 0
here is what i mean,

i get this:


root@pedro-laptop:/home/pedro# cc link.c
root@pedro-laptop:/home/pedro# ./a.out
Inter-| sta-| Quality | Discarded packets | Missed | WE
face | tus | link level noise | nwid crypt frag retry misc | beacon | 22

when i should be getting this:
root@pedro-laptop:/home/pedro# cat /proc/net/wireless
Inter-| sta-| Quality | Discarded packets | Missed | WE
face | tus | link level noise | nwid crypt frag retry misc | beacon | 22
eth1: 0000 5. -41. -87. 0 190 0 482 0 0
 
Old 06-05-2009, 05:35 PM   #3
plugo
LQ Newbie
 
Registered: Jun 2009
Posts: 20

Original Poster
Rep: Reputation: 0
any help??
 
Old 06-05-2009, 06:52 PM   #4
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,006

Rep: Reputation: 67
You should check file read return value. Sometime read action is non-complete. For example, you expect to read 4096 byte but 1024 byte is read at first time.
 
Old 06-06-2009, 03:07 PM   #5
plugo
LQ Newbie
 
Registered: Jun 2009
Posts: 20

Original Poster
Rep: Reputation: 0
ahh alright, how would i check though? thanx in advance.
 
Old 06-08-2009, 04:41 PM   #6
plugo
LQ Newbie
 
Registered: Jun 2009
Posts: 20

Original Poster
Rep: Reputation: 0
any more help?? i would appreciate it a lot!
 
Old 06-09-2009, 06:01 PM   #7
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,006

Rep: Reputation: 67
something like this.

totalLen = BUFLEN;
totalLenRead = 0;
while (totalLen > 0)
{
lenRead = read(socket, readString + totalLenRead, totalLen);
if (lenRead <= 0)
break;
else
{
totalLenRead += lenRead;
totalLen -= lenRead;
}
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Relationship between the signal level get from iwconfig and /proc/net/wireless? christyyim Linux - Wireless Networking 0 12-19-2008 11:13 AM
/proc/net/dev_mcast vprakash Linux - Networking 1 09-21-2007 01:03 PM
/proc/dev/net and /proc/net/dev problem ! Linux.tar.gz Slackware 1 05-23-2007 05:24 AM
/proc/net/wireless missing after kernel recompile Outabux Debian 1 07-05-2004 03:16 PM
/proc/net/wireless MarkusMan Linux - Wireless Networking 2 01-26-2004 09:56 PM


All times are GMT -5. The time now is 09:10 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration