A network daemon could not run on Solaris 9

From: Julie Xu (j.xu@uws.edu.au)
Date: Mon Aug 26 2002 - 20:50:30 EDT


Greeting,

I have machine:
$ uname -a
SunOS xxxx 5.9 Generic sun4u sparc SUNW,Sun-Blade-100

I have also an network daemon which may be writen on Lunix machine and
running find on Redhat 7.3.

I have succefully compile it on my solaris, but it crashed. So, I have
use gdb to debug it.

The problem source code:
 int get_request(int sock, VQP_REQUEST *r)
{
        int n;
        int addr_len;
        u_char buf[MAX_PACKET_SIZE];
        u_char *p;

        struct sockaddr_in cli;
        unsigned long int type;
        unsigned short int size;

        int i;

        addr_len = sizeof(cli);
        n = recvfrom(sock, buf, MAX_PACKET_SIZE, 0, (struct sockaddr
*)&cli, &addr_len);

........other program lines.................

        p = buf;

        r->head.unkn1 = *p++;
        r->head.req_type = *p++;

 ........other program lines.................

               switch (type) {
                        case VQP_CLI_ADDR:
                                r->client_ip.s_addr = ntohl( *((unsigned
long int *)p) );
                                p += size;
                                break;

........other program lines.................
}

The daemon start ok and the poss the control to the deamon child ok
also. After client send a request to the daemon and the daemon crash at:
 r->client_ip.s_addr = ntohl( *((unsigned long int *)p) );

The gdb debug output as:

Single stepping until exit from function _so_recvfrom,
which has no line number information.
get_request (sock=0, r=0xffbffd68) at vqp.c:23
23 if ( n < 0 ) {
/home/a9500672/source/vmps (gdb) p *r
$2 = {head = {unkn1 = 255 '', req_type = 191 '?', response = 254 '~',
    nitems = 108 'l', seq_no = 4290772620}, client_ip = {S_un = {S_un_b
= {
        s_b1 = 0 '\000', s_b2 = 1 '\001', s_b3 = 0 '\000', s_b4 = 52
'4'},
      S_un_w = {s_w1 = 1, s_w2 = 52}, S_addr = 65588}},
  port = "<\020\220\000\000\aZ<\030j",
  vlan = "?mx", '\000' <repeats 29 times>,
  domain = "\000\000?fD", '\000' <repeats 24 times>, "?~",
  mac = "(\000\000\000\000", cli = {sin_family = 0, sin_port = 0,
sin_addr = {
      S_un = {S_un_b = {s_b1 = 0 '\000', s_b2 = 0 '\000', s_b3 = 0
'\000',
          s_b4 = 0 '\000'}, S_un_w = {s_w1 = 0, s_w2 = 0}, S_addr = 0}},
    sin_zero = "\000\000\000\000\000\000\000"}
(gdb) p buf
$3 =
"\001\001\000\006\000\000\005#\000\000\f\001\000\004\211\232B\013\000\00
0\f
\002\000\005Fa0/4\000\000\f\003\000\b--NONE--\000\000\f\004\000\006UWSM-
C\000\00
0\f\a\000\001\000\000\000\f\005\000@\000\004,V5\b\006\000\001\b\0
00\006\0
04\000\001\000\004,V5\211\232IP\000\000\000\000\000\000\211\232I\001",
'\000' <
repeats 18 times>,
",\236=^\000\000\005\000\000\000\000T?q0\000\000\000\030\000
\000\000\030?v0ALLOCATE: 2a248 : 9
bytes\n\000\000\000\000\000\000\000\000\000\
004\000\000\000\000\000\003ib?z\032%|\2256"...
(gdb) p *buf
$4 = 1 '\001'
(gdb) p p
$5 = (u_char *) 0x0
(gdb) p *p
Cannot access memory at address 0x0
(gdb) p n
$6 = 132
...................more steps...........
(gdb) step
63 switch (type) {
(gdb) p type
$26 = 3073
(gdb) step
65 r->client_ip.s_addr = ntohl(
*((unsigned long int *)p) );
(gdb) p r->client_ip.s_addr
There is no member named s_addr
(gdb) p r->client_ip.s_addr
There is no member named s_addr.
(gdb) p r->client_ip
$27 = {S_un = {S_un_b = {s_b1 = 0 '\000', s_b2 = 0 '\000', s_b3 = 0
'\000',
      s_b4 = 0 '\000'}, S_un_w = {s_w1 = 0, s_w2 = 0}, S_addr = 0}}

Obviously, there is no s_addr but only S_addr. I thought or maybe the
solaris is different then linux so I change code to use S_addr, but, I
can not compile after change.

The structure of r is:

typedef struct {
        VQP_HEADER head;
        struct in_addr client_ip; ---- problem point.
        char port[PORT_NAME_MAX+1];
        char vlan[VLAN_NAME_MAX+1];
        char domain[DOMAIN_NAME_MAX+1];
        u_char mac[ETH_ALEN];
        struct sockaddr_in cli;
} VQP_REQUEST;

Am I point a correct problem? If so, how can I fix it? If not, what is
next thing I should to find the real problem.

Any comments will be appreciated

Thank in advance

Julie Xu

Data Communication Team
Information Technology Directorate
University of Western Sydney
Locked Bag 1797
Penrith South DC NSW 1797
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:24:50 EDT