SCTP Discussions

Text archives Help


[SCTP-Discussion] The difference between ext_sendto() and sctp_sendx()


Chronological Thread 
  • From: "Xu Yun,SCNB R&D NNC(BJ)" <xu.yun AT siemens.com>
  • To: discussion AT sctp.de
  • Subject: [SCTP-Discussion] The difference between ext_sendto() and sctp_sendx()
  • Date: Tue Aug 9 09:12:06 2005
  • List-id: SCTP Discussions <discussion.sctp.de>

Dear all,

I'm a very new user of this sctp stack. These days I'm trying to integrate
this stack to a m3ua stack (also open source, from sourceforge). Everything
looks well when I choose ext_sendto() to send and ext_recvfrom() to receive
m3ua messages except the ppid is always '0'. The sctp payload protocol id of
M3ua should be '3'. So I turned to use sctp_sendx() and sctp_recvmsg()
providing ppid by cmsg, and I met a serious problem: after receiving and
sending several m3ua messages, sctp layer starts reporting to receive a
message endlessly even after I killed the peer. Could somebody give me some
hints? The following is main part of receiving and sending:

int m3ua_sendmsg(m3_u32 assoc_id,
m3_u32 stream_id,
m3_u32 msglen,
m3_u8 *pmsg)
{
int ret;
int tid = assoc_table[assoc_id].to;
int fid = assoc_table[assoc_id].from;
struct sctp_sndrcvinfo info;

....

info.sinfo_ppid=3;
info.sinfo_stream=0;
info.sinfo_assoc_id=0;
info.sinfo_timetolive=60000;
info.sinfo_flags=MSG_PR_SCTP_TTL;

ret = sctp_sendx(from[fid].sockid,pmsg, msglen,(struct
sockaddr*)&to[tid].addr,1,&info,0);

if (-1 == ret) {
printf("ERRNO:%d\n", errno);
perror("E_sendto_Fail");
}
return 0;
}

void* waitfor_message(void *not_used)
{
int ret;
struct timeval timeout;
int idx;
fd_set rfds;
unsigned char msg[1024];
unsigned int msglen = 0;

timeout.tv_sec = 1;
timeout.tv_usec = 0;
while(1) {
rfds = readfds;
ret = ext_select(FD_SETSIZE, &rfds, NULL, NULL, &timeout);
if (0 == ret) {
timeout.tv_sec = 0;
timeout.tv_usec = 0;
m3timer_ckexpiry(NULL);
um3_timer_ckexpiry(NULL);
}
else if (0 < ret) {
for (idx = 0; idx < MAX_LOCAL_EP; idx++)
if (1 == from[idx].e_state &&
FD_ISSET(from[idx].sockid,&rfds))
get_message(idx, from[idx].sockid, msg, &msglen);
}
else {
perror("E_select_Fail");
}
...
...
}
return NULL;
}

int get_message( int fid,
int sockid,
unsigned char msg[1024],
unsigned int *pmsglen)
{
...
struct sockaddr_in addr;
int from_len = sizeof(struct sockaddr);
struct sctp_sndrcvinfo info;
int flags;

memset(&addr, 0, sizeof(struct sockaddr));

info.sinfo_ppid=3;
info.sinfo_stream=0;
info.sinfo_assoc_id=0;
info.sinfo_timetolive=60000;
info.sinfo_flags=MSG_PR_SCTP_TTL;

*pmsglen=sctp_recvmsg(sockid,msg,1024,(struct
sockaddr*)&addr,&from_len,&info,&flags);
if (0 < *pmsglen) {
/* search for association for which data is received */
...
}
return 0;
}


Thank you in advance!

Best Regards,
Xu Yun




Archive powered by MHonArc 2.6.19+.

Top of page