The Wayback Machine - https://web.archive.org/web/20090129144943/http://www.codeproject.com:80/script/Forums/View.aspx?fid=1213650
Click here to Skip to main content
5,842,883 members and growing! (19,215 online)
Announcements
* Bold indicates new messages since 4:49 29 Jan '09




BullFrog Power
Advanced Search
Sitemap

Linux


Home > Forums > Linux

 Msgs 1 to 23 of 23 (Total in Forum: 85) (Refresh)FirstPrevNext
QuestionLooking for Opensource SNTP client for Linuxmemberneolaser3:27 18 Jan '09  
I am looking for an opensource SNTP client for Linux, preferably with a NON GPL license. I got some programs but most of the programs came with GPL license.
Any links, pointers will be of great help.

Thanks in Advance, Smile
neolaser
QuestionDoing encryption that embedded into mail servermemberxiaomahe8:49 2 Jan '09  
Hello, i am planning to do email with encryption system embedded inside the mail system itself..

Currently, i am not sure on how to do such embedded program (creating a encryption program that plugs to the email itself when u run the email system)..

can somebody gimme ideas on how to do that? i have decided to use postfix and dovecot to setup and the mail system, probably with squirrel mail as well..

ANd which programming language more suitable for encyrption programs?? i know most of the language can be used, but which is the best..
QuestionAccessing ping through c/c++membertassadaque3:18 31 Dec '08  
I want to extract information such as rtt, time from each ping, if i ping some host. i think i should first capture the process id of ping and then use its information to get the required data. Any help in this regard is greatly appreciated
AnswerRe: Accessing ping through c/c++memberCosmic Egg5:03 10 Jan '09  
How about including Ping in your appication...

http://www.codeproject.com/KB/IP/Ping_and_Traceroute.aspx[^]

Can easily retrieve the values from here.
QuestionC programming in Linux warning messagememberKogee San18:24 9 Dec '08  
Hello everyone. Im not quite sure either Im in the right forum since my question is basically on C programming, coding in the linux environment. After I gcc, I got this warning message

"warning: passing argument 1 of 'strcpy' makes pointer from integer without a cast"

When I run the program, I will have a segmentation error fault. This is the code snippet below.


static const char *opt_socket_name[5];

main()
{
int i = 0;

strcpy(*opt_socket_name[i], "testing")
printf("%s", opt_socket_name);
}


Im not quite sure why this happen. Can anyone here help me and explain what is going on behind the scene. Can you guys also give an opinion on how to make it work. A brief on what I am doing is actually, creating multiple socket with different names. I am just about to create different names, but the warning above appeared. Is there any other options to do this? The above code is just a small testing code to make the strcpy() works. Im quite new in programming so currently im learning. Big Grin Thanks
AnswerRe: C programming in Linux warning messagememberL. Madhavan18:58 17 Dec '08  
It looks like you're trying to copy text into a string, but there are quite a few mistakes in the code:

1. A string is an array of characters, for eg. char str[100]. Therefore opt_socket_name[5] is a string that can hold 4 characters (+1 for the null terminator)

3. A * represents a pointer - you can also use a character pointer as a string, but it would point to an existing array of characters.

4. You use either * or an array. In your case, *opt_socket_name[5] means an array of 5 strings.

5. const = constant. Don't use that unless you don't want to modify the string.

So here's what your code should look like:
static char opt_socket_name[20];

main()
{
strcpy(opt_socket_name, "testing");
printf("%s", opt_socket_name);
}

If you're looking for an explanation for your warning and the segmentation fault, here it is: as I mentioned, in your original program, opt_socket_name[i] is a string and *opt_socket_name[i] points to a single character in the string. What you are passing to strcpy is a single character, which in C can be implicitly typecast to an integer, which in turn is typecast to a pointer and hence the warning.
GeneralRe: C programming in Linux warning messagememberKogee San1:45 18 Dec '08  
yeah, That is basically what is I intended to do. I understand with the code you gave me since it is a basic strcpy() syntax. Anyway, thanks for the explanation behind the scene because that is the important thing i want to know. however, im not quite sure about what you mentioned of *opt_socket_name[5] means an array of 5 strings.. So does it means that *opt_socket_name[5] points to 5 strings? What I mean is like this :-

*opt_socket_name[0] is pointing to a string for example char string1[10];
*opt_socket_name[1] is pointing to a string example char string2[10];
*opt_socket_name[2] is pointing to a string for example char string3[10];
*opt_socket_name[i] is pointing to a string for example char stringi[10];


How can i make a program to test this if my understanding here is true. The test is just to secure my knowledge and understanding. Thank a lot.
GeneralRe: C programming in Linux warning messagememberL. Madhavan2:15 18 Dec '08  
You're partially right about the *opt_socket_name[5] thing. You declare the array of pointers using a *, eg. char *opt_socket_name[5].

Now, for a normal pointer, you would assign it the address of an existing variable. Example:
int value = 10;
int *pointer = &value;
printf("%d\n", *pointer);

But the problem is that there is no string data type in C. A string itself is an array of characters and an array is internally a pointer, which means that a string is already a pointer. So the & and * are not used at all. This is how you would use an array of strings:
main() {
int i;
char *opt_socket_name[5];

char string1[10];
// ...
char string5[10];

strcpy(string1, "hello 1");
// ...
strcpy(string5, "hello 5");

opt_socket_name[0] = string1;
// ...
opt_socket_name[4] = string5;

for (i = 0; i < 5; i++)
printf("%s\n", opt_socket_name[i]);
}

GeneralRe: C programming in Linux warning messagememberKogee San21:54 18 Dec '08  
wow. Thanks man. This explanation really helps my understanding in C character pointers. I will try this testing code later. Thanks a lot.
QuestionLinux web proxymemberMekong River18:16 27 Nov '08  
Hi, I used to learn Red Hat Linux version 9 and now I didn't continue to study it. At my work place I have a problem with my internet connection that over usage. As I have check with the document, I found that suse linux could be setup as a web proxy (squids) which could control and limit the amount of usage of internet. From here I would like to have a question as follow:

1. Is it possible for me to read only the chapter of setup and configure linux as web proxy?

2. Does the machine run as linux web proxy require one or two network interface card?

3. Do I need to read any additional document regarding to configure and monitoring linux web proxy?

Thank in advance!!!
AnswerRe: Linux web proxymemberL. Madhavan19:04 17 Dec '08  
For questions 1 and 3: If you're familiar with Linux, yes, it's enough you read up the chapter on squid. I also found a simple tutorial here[^].

For question 2: Generally, you need two. One connects the proxy server to the local network. Another connects it to the internet, unless you're using an interface other than Ethernet.
QuestionEncoding problem of use ftp with C#membercrushglass17:24 19 Nov '08  
I need to create a folder on the server with chinese or japanese name. I encode the folder name to UTF-8. I found that I can create the folder. But name of the folder I created on the server become unreadable code.

Thank for any reply.
QuestionPackets are getting dropped when receiving mobility header.membershekharban3:54 13 Nov '08  
Hi,

I am trying to recieve Mobility Header sent (raw sockets). The problem is after receiving, packets are not sent to ip6_input_finish; it is dropped here. (tshark running shows the packet is received)

int ip6_input(struct sk_buff *skb)
{
//It is coming here and NF_HOOK is returning -1
return NF_HOOK(PF_INET6, NF_INET_LOCAL_IN, skb, skb->dev, NULL,
ip6_input_finish);
}

If you need i will send the sender program.

Thanks,
Chandrashekhar

banshekhar

AnswerRe: Packets are getting dropped when receiving mobility header.membershekharban22:46 13 Nov '08  
Problem got solved after doing ip6tables -F.

Thanks,
Chandrashekhar

banshekhar

Questionwhy the option CONFIG_NETFILTER_DEBUG is set when compiling kernelmembershekharban3:46 13 Nov '08  
Hi,

Please let me know why the option CONFIG_NETFILTER_DEBUG is set while compiling kernel.


Thanks,
Chandrashekhar

banshekhar

Questionlivecd.sgnmember_chew7:04 8 Nov '08  
Hello guys

I'm trying to boot Linux from USB. It's an ISO file. But boot can't continue due to a fatal error. Boot is looking for this livecd.sgn file which I think was included in the image file. Then it had this suggestion of copying the data to hard drive and reboot again. It seems that kernel is expecting this file to be in the hard drive. Really no idea how to proceed with this.
QuestionInvalid argument error while sending routing header in ipv6membershekharban4:24 3 Nov '08  
Hi,

While trying to send routing header by using following raw socket program, i am getting invalid argument error. Can anyone tell me what wrong with this.

#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
#include <errno.h>
#include <string.h>


void main()
{
int sock_fd;
int on = 1;
int offset = 4;
int ret = 0;

struct sockaddr_in6 *daddr;
struct in6_pktinfo pinfo;
struct msghdr msg;
struct cmsghdr *cmsg;
struct iovec *iovector;
socklen_t rthlen = 0;
int cmsglen;

bzero (&msg, sizeof(msg));

sock_fd = socket(AF_INET6, SOCK_RAW, IPPROTO_IPV6);

if(sock_fd < 0)
{
printf("\nClient: Socket Creation Failed: Error %d\n", errno);
return;
}

iovector = (struct iovec*)calloc(1, sizeof(struct iovec));


/* Since for Mobility Header the checksum is located in offset 4, we need to
* set the offset to 4
*/

if (setsockopt(sock_fd, IPPROTO_IPV6, IPV6_RECVRTHDR, &on, sizeof(on)) < 0)
{
printf("\nClient: RTHDR option set failed\n");
return;
}

/* Our Destination Address is fe80::21d:9ff:fe17:5d0e eth0 interface
* i.e. fe80Red facedRed facedRed faced:021d:09ff:fe17:5d0e
*/
daddr = (struct sockaddr_in6*)calloc(1, sizeof(struct sockaddr_in6));

daddr->sin6_family = AF_INET6;

daddr->sin6_addr.s6_addr16[0] = 0xfe80;
daddr->sin6_addr.s6_addr16[1] = 0x0;
daddr->sin6_addr.s6_addr16[2] = 0x0;
daddr->sin6_addr.s6_addr16[3] = 0x0;
daddr->sin6_addr.s6_addr16[4] = 0x021d;
daddr->sin6_addr.s6_addr16[5] = 0x09ff;
daddr->sin6_addr.s6_addr16[6] = 0xfe17;
daddr->sin6_addr.s6_addr16[7] = 0x5d0e;

daddr->sin6_port = htons(IPPROTO_IPV6);

/* Our Source Address is fe80::21d:9ff:fe17:58c7 eth0 interface
* i.e. fe80Red facedRed facedRed faced:021d:09ff:fe17:58c7
*/
memset(&pinfo, 0, sizeof(struct in6_pktinfo));

pinfo.ipi6_addr.s6_addr16[0] = 0xfe80;
pinfo.ipi6_addr.s6_addr16[1] = 0x0;
pinfo.ipi6_addr.s6_addr16[2] = 0x0;
pinfo.ipi6_addr.s6_addr16[3] = 0x0;
pinfo.ipi6_addr.s6_addr16[4] = 0x021d;
pinfo.ipi6_addr.s6_addr16[5] = 0x09ff;
pinfo.ipi6_addr.s6_addr16[6] = 0xfe17;
pinfo.ipi6_addr.s6_addr16[7] = 0x58c7;

pinfo.ipi6_ifindex = 2; /* Interface Id */

//Fill ancilliary data and call sendmsg
void *extptr;
socklen_t extlen;
struct cmsghdr *cmsgptr;

extlen = inet6_rth_space(IPV6_RTHDR_TYPE_0, 1);
cmsglen = CMSG_SPACE(extlen);
cmsgptr = malloc(cmsglen);
cmsgptr->cmsg_len = CMSG_LEN(extlen);
cmsgptr->cmsg_level = IPPROTO_IPV6;
cmsgptr->cmsg_type = IPV6_RTHDR;

extptr = CMSG_DATA(cmsgptr);
extptr = inet6_rth_init(extptr, extlen, IPV6_RTHDR_TYPE_0, 1);

int check = inet6_rth_add(extptr, &daddr->sin6_addr);

if (check < 0)
{
printf("FAILURE \n");

}

msg.msg_control = cmsgptr;
msg.msg_controllen = cmsglen;


iovector->iov_base = malloc(10);
iovector->iov_len = 10;

strcpy(iovector->iov_base, "MAG-TO-LMA");
msg.msg_iov = iovector;
msg.msg_iovlen = 1;
msg.msg_name = (void *)daddr;
msg.msg_flags = 0;

msg.msg_namelen = sizeof(struct sockaddr_in6);



ret = sendmsg(sock_fd, &msg, 0);
if (ret < 0)
{
printf("\nClient:Send Message Failed: Error %d Ret %d\n", errno, ret);
free(iovector->iov_base);
free(iovector);
return;
}
}

Regards,
Shekharban

banshekhar

AnswerRe: Invalid argument error while sending routing header in ipv6membershekharban23:25 3 Nov '08  
Hi,

Meanwhile i was trying to send icmp packets; got to know that byte ordering of address is wrong. I tried the above program by changing the address byte order, but with no luck. Could any one please let me know how routing header can be sent as a ancilliary data in v6 and what might be wrong with this code.

#include &lt;sys/types.h&gt;
#include &lt;netinet/in.h&gt;
#include &lt;netinet/ip6.h&gt;
#include &lt;errno.h&gt;
#include &lt;string.h&gt;

void main()
{
   int sock_fd;
   int on = 1;
   int offset = 4;
   int ret = 0;

   struct sockaddr_in6 *daddr;
   struct in6_pktinfo pinfo;
   struct msghdr msg;
   struct cmsghdr *cmsg;
   struct iovec *iovector;
   socklen_t rthlen = 0;
   int cmsglen;

   sock_fd = socket(AF_INET6, SOCK_RAW, IPPROTO_IPV6);

   if(sock_fd &lt; 0)
   {
      printf("\nClient: Socket Creation Failed: Error %d\n", errno);
      return;
   }

   iovector = (struct iovec*)calloc(1, sizeof(struct iovec));


   /* Since for Mobility Header the checksum is located in offset 4, we need to
   *   set the offset to 4
   */

   if (setsockopt(sock_fd, IPPROTO_IPV6, IPV6_RECVRTHDR, &amp;on, sizeof(on)) &lt; 0)
   {
      printf("\nClient: RTHDR option set failed\n");
      return;
   }

   /* Our Destination Address is fe80::21d:9ff:fe17:5d0e eth0 interface
   *   i.e. fe80Red facedRed facedRed faced:021d:09ff:fe17:5d0e
   */
   daddr = (struct sockaddr_in6*)calloc(1, sizeof(struct sockaddr_in6));

   daddr-&gt;sin6_family = AF_INET6;

   daddr-&gt;sin6_addr.s6_addr16[0] = 0x80fe;
   daddr-&gt;sin6_addr.s6_addr16[1] = 0x0;
   daddr-&gt;sin6_addr.s6_addr16[2] = 0x0;
   daddr-&gt;sin6_addr.s6_addr16[3] = 0x0;
   daddr-&gt;sin6_addr.s6_addr16[4] = 0x1d02;
   daddr-&gt;sin6_addr.s6_addr16[5] = 0xff09;
   daddr-&gt;sin6_addr.s6_addr16[6] = 0x17fe;
   daddr-&gt;sin6_addr.s6_addr16[7] = 0x0e5d;

   daddr-&gt;sin6_port = htons(IPPROTO_IPV6);

   /* Our Source Address is fe80::21d:9ff:fe17:58c7 eth0 interface
   * i.e. fe80Red facedRed facedRed faced:021d:09ff:fe17:58c7
   */
   memset(&amp;pinfo, 0, sizeof(struct in6_pktinfo));

   pinfo.ipi6_addr.s6_addr16[0] = 0x80fe;
   pinfo.ipi6_addr.s6_addr16[1] = 0x0;
   pinfo.ipi6_addr.s6_addr16[2] = 0x0;
   pinfo.ipi6_addr.s6_addr16[3] = 0x0;
   pinfo.ipi6_addr.s6_addr16[4] = 0x1d02;
   pinfo.ipi6_addr.s6_addr16[5] = 0xff09;
   pinfo.ipi6_addr.s6_addr16[6] = 0x17fe;
   pinfo.ipi6_addr.s6_addr16[7] = 0xc758;

   pinfo.ipi6_ifindex = 2; /* Interface Id */


   /* Fill the Routing Header in ancillary data */
   rthlen = inet6_rth_space(IPV6_RTHDR_TYPE_0, 1);
   cmsglen = CMSG_SPACE(rthlen);
   printf("\nClient: rthlen is %d\n", rthlen);
   cmsg = malloc(cmsglen);
   if (cmsg == NULL)
   {
      printf("\nClient:Ancillary Data memory allocation failed\n");
      return;
   }

   memset(cmsg, 0, cmsglen);
   memset(&amp;msg, 0, sizeof(msg));

   iovector-&gt;iov_base = malloc(10);
   iovector-&gt;iov_len = 10;

   strcpy(iovector-&gt;iov_base, "TEST-4-RH");

   msg.msg_control = (void *)cmsg;
   msg.msg_controllen = cmsglen;
   msg.msg_iov = iovector;
   msg.msg_iovlen = 1;
   msg.msg_name = (void *)daddr;
   msg.msg_namelen = sizeof(struct sockaddr_in6);

   void *rthp;

   cmsg = CMSG_FIRSTHDR(&amp;msg);
   cmsg-&gt;cmsg_len = CMSG_LEN(rthlen);
   cmsg-&gt;cmsg_level = IPPROTO_IPV6;
   cmsg-&gt;cmsg_type = IPV6_RTHDR;

   rthp = CMSG_DATA(cmsg);
   rthp = inet6_rth_init(rthp, rthlen, IPV6_RTHDR_TYPE_0, 1);

   if(rthp == NULL)
   {
      printf("\nClient: Routing Header Init failed\n");
      return;
   }

   inet6_rth_add(rthp, &amp;daddr-&gt;sin6_addr);
   rthp = NULL;

   ret = sendmsg(sock_fd, &amp;msg, 0);
   if (ret &lt; 0)
   {
      printf("\nClient:Send Message Failed: Error %d Ret %d\n", errno, ret);
      free(iovector-&gt;iov_base);
      free(iovector);
      return;
   }
}

Regards,
Shekharban

banshekhar
Questionhow detect "pressing key"memberBlood_HaZaRd4:26 2 Nov '08  
Hi all,

I m working with C under linux and i have a little prob :


while(1)
{
if(scanf("%s", msg)>0)
printf("Yr message is %s\n", msg);
else
/* some other Job */
}


but when i run the prog it still frozen waiting for the message but i wanna it do the other Job bloc. So is there any function that helps me detecting if there is a key pressed or no ???

Thx.

"The Ultimate Limit Is Only Your Imagination."

AnswerRe: how detect "pressing key"memberShyam Bharath19:12 5 Nov '08  
I guess scanf is always returning a value > 0 in ur code.

You would want to use a getch() like function to detect keypress rather than scanf. Check this out http://cboard.cprogramming.com/archive/index.php/t-27714.html[^]

-------------------------------------------
It's code that drives you - Shyam

AnswerRe: downloading DSLmemberL. Madhavan19:08 17 Dec '08  
Go to http://damnsmalllinux.org/download.html[^], select any of the mirrors, then go to the current folder and download current.iso. Burn the image onto a CD, then reboot your system and the DSL live CD should load.
AnswerRe: Is Linux worth it?memberflydream204622:08 13 Dec '08  
I think it's not about free or not ,it's about the open source ,a open soft spirit!
however , it does depend on your own choice .no one can deny your choice except yourself... Big Grin
GeneralRe: What do I need to learn?memberMikeMarq13:03 31 Oct '08  
Thank you for your excellent reply. Big Grin

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Last Updated 9 Aug 2007
Web17 | Advertise | Privacy
Copyright © CodeProject, 1999-2009
All Rights Reserved. Terms of Use