Re: Re: connect pdu error.

"Rene Kluwen" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Just to make sure: Did you realize that the wapforum specs display the 
least significant bit first?

A TR-Invoke PDU is build as follows (first octet):

CON PDU PDU PDU PDU GTR TTR RID
-------------------------------
 0   1   0   0   0   1   1   0

This makes a hex value of 62.

Also, your TID is a little high to begin with... But still allowed.

-- Rene...



----- Original Message -----
Date: Thu  September 19, 2002  08:43 AM
From: Nigar  Sultana <[email protected]>
To: [email protected]
Subject: Re: Re: connect pdu error. 

Hello

I am sending the code. First four bytes is TR-Invoke.Req,the 1st 
byte value is 0x07,2nd and 3rd byte is transaction id,fourth byte 
0x02. Rest bytes are Connect Pdu. am i sending the pdu with the 
correct value.

The hex values of the pdu is given below:
07 31 30 02 01 10 7f 02 13 08 12 43 12

please help me.

regards
Nigar

On Thu, 19 Sep 2002 Rene Kluwen wrote :
>Could you post the PDU that you are sending?
>
>On Thu, 2002-09-19 at 10:09, Nigar Sultana wrote:
> > Hello All
> >
> > I have written a udp client prgm which will send the connect 
>req
> > to the wap gate
> > way. using kannel as the wap gateway. while executing i am 
>coming
> > across few pro
> > blems:
> > 1> the udp data contains first 4bytes the TR-Invoke pdu. and 
>rest
> > is the connect
> >   pdu data. wapgateway is throwing these errors:
> >          WTP PDU with unknown type -1
> >          pdu unpacking returned NULL
> >          an erronous pdu received.
> > please help me.
> >
> > regards
> > Nigar
> >
>
>
udpclient.connect.c (application/octet-stream, 2.3 KB)
// This prgm sends S_Connect
// First four bytes is TR-InvokeReq,and the rest bytes are Connect PDU

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include "asn1type.h"

int main ( )
{
        int send_len , sockfd , cli_len , buffer_length , serv_len ;
        struct sockaddr_in serv_addr , cli_addr ;
	int offset=0;
	char method [255],capabilities[50],cap_buff[20],header[20];
	char wtp[5],wtp_flag;
	int l,capa_offset,wtp_len;

	memset(method,'\0',sizeof(method));
	memset(capabilities,'\0',sizeof(capabilities));
	memset(cap_buff,'\0',sizeof(cap_buff));
	memset(header,'\0',sizeof(header));
	memset(wtp,'\0',sizeof(wtp));
	
	//set the tr invoke pdu
	wtp_flag=0;
	//wtp_flag=0x07;
	wtp_flag=0x70;
	wtp[0]=wtp_flag;
	wtp_len=1;
	memcpy(wtp+wtp_len,"10",2);
	wtp_len=wtp_len+2;
	//wtp[wtp_len]=0x02;
	wtp[wtp_len]=0x20;


	//set the capabilities
	capa_offset=0;
	l=0;
	memcpy(cap_buff,"kannel wap gateway",strlen("kannel wap gateway"));
	l=strlen(cap_buff);
	capabilities[0]=l+1;
	capabilities[1]=0x08;
	capabilities[2]=l;
	
	memcpy(method,wtp,4);
	offset=4;
	method[4]=0x01;
	method[5]=0x10; //wsp protocol version
	method[6]=127; //capabilities len
	method[7]=2;   //length of header
	offset=8;
	memcpy(method+offset,capabilities,3);
	offset=offset+3;	
	
	//header
	header[0]=0x43;
	header[1]=0x12;
	memcpy(method+offset,header,2);
	offset=offset+2;



	//Fill the structure of the server address with the address of the server that we want to send to
	bzero ( ( char * ) &serv_addr , sizeof ( serv_addr ) ) ;
        serv_addr.sin_family = AF_INET ;
        serv_addr.sin_addr.s_addr = inet_addr("127.0.0.1") ;
        serv_addr.sin_port = htons (9201) ;
	serv_len = sizeof ( serv_addr ) ;

        //open udp socket
        if ( ( sockfd = socket ( AF_INET , SOCK_DGRAM , 0 ) ) < 0 )
                printf ( "Server Cannot Open datagram socket \n " ) ;
        else
                printf ( "The socket fd : %d \n " , sockfd ) ;

	//sendto 
	printf("Total number of bytes:%d\n", offset);
	xu_hex_dump((unsigned char*)method,offset,TRUE);
	send_len = sendto ( sockfd , method , offset , 0 , ( struct sockaddr * ) &serv_addr , sizeof ( serv_addr ) ) ;
	if ( send_len < 0 ) 
		printf ( "Error in Sendto \n " ) ;
	else 
		printf ( "Success in sendto \n " ) ;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.