hi,

i'm using a uclinux on h8 arch. i'm running 2.4.x
kernel with sctp module, developed by openss7.

i'm trying to send a file through a sctp socket. it
seems
to work, but at the end i'm getting an abort chunk
from the client. there is no proper shutdown. the
client just send abort. the server prints an error:
accept: Software caused connection abort.
the client/server buffers are i.e 256. the last sent
data chunk is i.e 6. i'm having non-block mode.

i have attached client and server code and a
capture.

could somebody give me any clue how to fix this
problem?

greetings
magda


---------------------------------------------
server
------------------------------------------
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
int nodelay =1;
#define HOST_BUF_LEN 256
char buf[HOST_BUF_LEN];
int init_server(int port){
struct sockaddr_in addr;
int sd;

addr.sin_family = PF_INET;
addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_port = htons(port);
if( (sd=socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) < 0 ) {
perror("socket failed\n");
return(-1);

}

if( bind( sd, (struct sockaddr *)&addr,sizeof(addr) ) == -1 ) {
perror("bind");
goto errout;
exit(1);
}
else printf("binded\n");
if (listen(sd, 1)==-1) {
printf("not listening...\n");
goto errout;
}
else printf("listening...\n");
return sd;
errout:
close(sd);
return(-1);
}
void serve(int listener){
fd_set master; // master file descriptor list
fd_set read_fds; //temp file descriptor list for select()
//struct sockaddr_in myaddr; //server address
struct sockaddr_in remoteaddr; //client address
int fdmax; // maximum file descriptor number
//int listener;// listening socket descriptor
int newfd; // newly accept()ed socket descriptor
char buf[HOST_BUF_LEN]; // buffer for client data
int nbytes;
int addrlen;
int i ;
FD_ZERO(&master); // clear the master and temp sets
FD_ZERO(&read_fds);
FD_SET(listener, &master);
//keep track of the biggest file descriptor
fdmax = listener; //so far, it's this one
//main loop
for(; {
read_fds = master; //copy it
if (select(fdmax+1, &read_fds, NULL, NULL, NULL) == -1) {
perror("select");
exit(1);
}

//run through the existing connections looking for data to read
for(i = 0; i <= fdmax; i++) {

if (FD_ISSET(i, &read_fds)) { //we got one!!
if (i == listener) {
//handle new connections
addrlen = sizeof remoteaddr;
if ((newfd = accept(listener, (struct sockaddr *)&remoteaddr,
&addrlen)) == -1) {
perror("accept");
} else {
if (fcntl(i, F_SETFL, O_NONBLOCK) < 0) {
perror("fcntl");
}
if (setsockopt(i, SOL_SCTP, SCTP_NODELAY, &nodelay,
sizeof(nodelay)) < 0) {
perror("setsockopt");
}
FD_SET(newfd, &master); //add to master set
if (newfd > fdmax) { //keep track of the maximum
fdmax = newfd;
}
}
} else {
//handle data from a client

if ((nbytes = recv(i, buf, sizeof buf, MSG_DONTWAIT )) <= 0) {
//got error or connection closed by client
if (nbytes == 0) {
//connection closed
printf("selectserver: socket %d hung up\n", i);
} else {
perror("recv");
}
close(i); //bye!
FD_CLR(i, &master); //remove from master set
} else {

fwrite(buf,nbytes,1,stdout);
}
}
}
}
}
}
int main(int argc, char *argv[]){
serve(init_server(atoi(argv[1])));

return 1;
}

----------------------------------------
client
---------------------------------------

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

int nodelay = 1;
#define HOST_BUF_LEN 256
int init_client(int port, char *ip) {
int sd;
static struct sockaddr_in addr ;
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = inet_addr(ip);
if ((sd = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) < 0) {
perror("socket");
}

if(connect(sd,(struct sockaddr *)&addr,sizeof(addr)) < 0) {
perror("connect");
return(-1);
}
if (fcntl(sd, F_SETFL, O_NONBLOCK) < 0) {
perror("fcntl");
goto errout;
}
if (setsockopt(sd, SOL_SCTP, SCTP_NODELAY, &nodelay,
sizeof(nodelay)) < 0) {
perror("setsockopt");
goto errout;
}
return sd;
errout:
close(sd);
return(-1);
}
void print_param(int sd) {
char buf[HOST_BUF_LEN];
int read_b;
while((read_b = fread(buf, 1, sizeof(buf), stdin))){
if ((send(sd, buf, read_b, 0)) == -1) {
perror("send");
}

}
perror("");

close (sd);
}
int usage(int argc){
if(argc != 3) {
printf ("usage: client dest_ip\n");
return (-1);
}
return 1;
}
int main(int argc,char *argv[]) {
if(usage(argc) > 0 ){
int sock;
if ((sock = init_client(atoi(argv[1]), argv[2])))
print_param(sock) ;
}
return 1;
}


------------------------------------------------
capture
-------------------------------------------

No. Time Source Destination
Protocol Info
14885 11200.199016 192.168.1.119 192.168.1.233
SCTP INIT

Frame 14885 (84 bytes on wire, 84 bytes captured)
Linux cooked capture
Internet Protocol, Src Addr: 192.168.1.119 (192.168.1.119), Dst Addr:
192.168.1.233 (192.168.1.233)
Stream Control Transmission Protocol, Src Port: 1031 (1031), Dst Port:
10000 (10000)
Source port: 1031
Destination port: 10000
Verification tag: 0x00000000
Checksum: 0x709a9cc2 (correct CRC32C)
INIT chunk (Outbound streams: 1, inbound streams: 33)
Chunk type: INIT (1)
0... .... = Bit: Stop processing of the packet
.0.. .... = Bit: Do not report
Chunk flags: 0x00
Chunk length: 34
Initiate tag: 0xf31ad461
Advertised receiver window credit (a_rwnd): 65535
Number of outbound streams: 1
Number of inbound streams: 33
Initial TSN: 1641290483
IPv4 address parameter (Address: 192.168.1.119)
Supported address types parameter (Supported types: IPv4)
Chunk padding: 0000

No. Time Source Destination
Protocol Info
14886 11200.285549 192.168.1.233 192.168.1.119
SCTP INIT_ACK

Frame 14886 (156 bytes on wire, 156 bytes captured)
Linux cooked capture
Internet Protocol, Src Addr: 192.168.1.233 (192.168.1.233), Dst Addr:
192.168.1.119 (192.168.1.119)
Stream Control Transmission Protocol, Src Port: 10000 (10000), Dst
Port: 1031 (1031)
Source port: 10000
Destination port: 1031
Verification tag: 0xf31ad461
Checksum: 0x95255afd (correct CRC32C)
INIT_ACK chunk (Outbound streams: 33, inbound streams: 33)
Chunk type: INIT_ACK (2)
0... .... = Bit: Stop processing of the packet
.0.. .... = Bit: Do not report
Chunk flags: 0x00
Chunk length: 108
Initiate tag: 0x65a4fdfd
Advertised receiver window credit (a_rwnd): 32767
Number of outbound streams: 33
Number of inbound streams: 33
Initial TSN: 1705311741
IPv4 address parameter (Address: 192.168.1.233)
State cookie parameter (Cookie length: 76 bytes)

No. Time Source Destination
Protocol Info
14887 11200.286732 192.168.1.119 192.168.1.233
SCTP COOKIE_ECHO

Frame 14887 (128 bytes on wire, 128 bytes captured)
Linux cooked capture
Internet Protocol, Src Addr: 192.168.1.119 (192.168.1.119), Dst Addr:
192.168.1.233 (192.168.1.233)
Stream Control Transmission Protocol, Src Port: 1031 (1031), Dst Port:
10000 (10000)
Source port: 1031
Destination port: 10000
Verification tag: 0x65a4fdfd
Checksum: 0x42ac8772 (correct CRC32C)
COOKIE_ECHO chunk (Cookie length: 76 bytes)
Chunk type: COOKIE_ECHO (10)
0... .... = Bit: Stop processing of the packet
.0.. .... = Bit: Do not report
Chunk flags: 0x00
Chunk length: 80
Cookie: 0001B1830000177065A4FDFDC0A80177C0A801E904072710.. .

No. Time Source Destination
Protocol Info
14888 11200.809261 192.168.1.233 192.168.1.119
SCTP COOKIE_ACK SACK

Frame 14888 (68 bytes on wire, 68 bytes captured)
Linux cooked capture
Internet Protocol, Src Addr: 192.168.1.233 (192.168.1.233), Dst Addr:
192.168.1.119 (192.168.1.119)
Stream Control Transmission Protocol, Src Port: 10000 (10000), Dst
Port: 1031 (1031)
Source port: 10000
Destination port: 1031
Verification tag: 0xf31ad461
Checksum: 0xb5c67036 (correct CRC32C)
COOKIE_ACK chunk
Chunk type: COOKIE_ACK (11)
0... .... = Bit: Stop processing of the packet
.0.. .... = Bit: Do not report
Chunk flags: 0x00
Chunk length: 4
SACK chunk (Cumulative TSN: 1641290482, a_rwnd: 32767, gaps: 0,
duplicate TSNs: 0)
Chunk type: SACK (3)
0... .... = Bit: Stop processing of the packet
.0.. .... = Bit: Do not report
Chunk flags: 0x00
Chunk length: 16
Cumulative TSN ACK: 1641290482
Advertised receiver window credit (a_rwnd): 32767
Number of gap acknowldgement blocks : 0
Number of duplicated TSNs: 0

No. Time Source Destination
Protocol Info
14889 11200.812771 192.168.1.119 192.168.1.233
SCTP DATA

Frame 14889 (320 bytes on wire, 320 bytes captured)
Linux cooked capture
Internet Protocol, Src Addr: 192.168.1.119 (192.168.1.119), Dst Addr:
192.168.1.233 (192.168.1.233)
Stream Control Transmission Protocol, Src Port: 1031 (1031), Dst Port:
10000 (10000)
Source port: 1031
Destination port: 10000
Verification tag: 0x65a4fdfd
Checksum: 0xe8e930c8 (correct CRC32C)
DATA chunk(ordered, complete segment, TSN: 1641290483, SID: 0,
SSN: 1, PPID: 0, payload length: 256 bytes)
Chunk type: DATA (0)
0... .... = Bit: Stop processing of the packet
.0.. .... = Bit: Do not report
Chunk flags: 0x03
.... ...1 = E-Bit: Last segment
.... ..1. = B-Bit: First segment
.... .0.. = U-Bit: Ordered deliviery
Chunk length: 272
TSN: 1641290483
Stream Identifier: 0x0000
Stream sequence number: 1
Payload protocol identifier: not specified (0)
Data (256 bytes)

0000 2f 65 74 63 2f 67 64 6d 2f 50 72 65 53 65 73 73 /etc/gdm/
PreSess
0010 69 6f 6e 2f 44 65 66 61 75 6c 74 3a 20 52 65 67 ion/Default:
Reg
0020 69 73 74 65 72 69 6e 67 20 79 6f 75 72 20 73 65 istering your
se
0030 73 73 69 6f 6e 20 77 69 74 68 20 77 74 6d 70 20 ssion with
wtmp
0040 61 6e 64 20 75 74 6d 70 0a 2f 65 74 63 2f 67 64 and utmp./etc/
gd
0050 6d 2f 50 72 65 53 65 73 73 69 6f 6e 2f 44 65 66 m/PreSession/
Def
0060 61 75 6c 74 3a 20 72 75 6e 6e 69 6e 67 3a 20 2f ault:
running: /
0070 75 73 72 2f 58 31 31 52 36 2f 62 69 6e 2f 73 65 usr/X11R6/bin/
se
0080 73 73 72 65 67 20 2d 61 20 2d 77 20 2f 76 61 72 ssreg -a -w /
var
0090 2f 6c 6f 67 2f 77 74 6d 70 20 2d 75 20 2f 76 61 /log/wtmp -u /
va
00a0 72 2f 72 75 6e 2f 75 74 6d 70 20 2d 78 20 22 2f r/run/utmp -x
"/
00b0 76 61 72 2f 6c 69 62 2f 67 64 6d 2f 3a 30 2e 58 var/lib/gdm/:
0.X
00c0 73 65 72 76 65 72 73 22 20 2d 68 20 22 22 20 2d servers" -h ""
-
00d0 6c 20 22 3a 30 22 20 22 66 72 6f 67 22 0a 2f 65 l ":0" "frog"./
e
00e0 74 63 2f 67 64 6d 2f 58 73 65 73 73 69 6f 6e 3a tc/gdm/
Xsession:
00f0 20 42 65 67 69 6e 6e 69 6e 67 20 73 65 73 73 69 Beginning
sessi

No. Time Source Destination
Protocol Info
14890 11200.814174 192.168.1.119 192.168.1.233
SCTP DATA

Frame 14890 (320 bytes on wire, 320 bytes captured)
Linux cooked capture
Internet Protocol, Src Addr: 192.168.1.119 (192.168.1.119), Dst Addr:
192.168.1.233 (192.168.1.233)
Stream Control Transmission Protocol, Src Port: 1031 (1031), Dst Port:
10000 (10000)
Source port: 1031
Destination port: 10000
Verification tag: 0x65a4fdfd
Checksum: 0xb455a2ca (correct CRC32C)
DATA chunk(ordered, complete segment, TSN: 1641290484, SID: 0,
SSN: 1, PPID: 0, payload length: 256 bytes)
Chunk type: DATA (0)
0... .... = Bit: Stop processing of the packet
.0.. .... = Bit: Do not report
Chunk flags: 0x03
.... ...1 = E-Bit: Last segment
.... ..1. = B-Bit: First segment
.... .0.. = U-Bit: Ordered deliviery
Chunk length: 272
TSN: 1641290484
Stream Identifier: 0x0000
Stream sequence number: 1
Payload protocol identifier: not specified (0)
Data (256 bytes)

0000 6f 6e 20 73 65 74 75 70 2e 2e 2e 0a 53 45 53 53 on
setup....SESS
0010 49 4f 4e 5f 4d 41 4e 41 47 45 52 3d 6c 6f 63 61
ION_MANAGER=loca
0020 6c 2f 64 65 62 69 61 6e 3a 2f 74 6d 70 2f 2e 49 l/debian:/
tmp/.I
0030 43 45 2d 75 6e 69 78 2f 37 33 39 0a 47 6e 6f 6d CE-unix/
739.Gnom
0040 65 2d 4d 65 73 73 61 67 65 3a 20 67 6e 6f 6d 65 e-Message:
gnome
0050 5f 65 78 65 63 75 74 65 5f 61 73 79 6e 63 5f 77
_execute_async_w
0060 69 74 68 5f 65 6e 76 5f 66 64 73 3a 20 72 65 74 ith_env_fds:
ret
0070 75 72 6e 69 6e 67 20 2d 31 0a 6c 69 62 68 61 6c urning
-1.libhal
0080 2e 63 20 37 36 37 20 3a 20 6f 72 67 2e 66 72 65 .c 767 :
org.fre
0090 65 64 65 73 6b 74 6f 70 2e 44 42 75 73 2e 45 72
edesktop.DBus.Er
00a0 72 6f 72 2e 53 65 72 76 69 63 65 44 6f 65 73 4e
ror.ServiceDoesN
00b0 6f 74 45 78 69 73 74 20 72 61 69 73 65 64 0a 22 otExist
raised."
00c0 53 65 72 76 69 63 65 20 22 6f 72 67 2e 66 72 65 Service
"org.fre
00d0 65 64 65 73 6b 74 6f 70 2e 48 61 6c 22 20 64 6f edesktop.Hal"
do
00e0 65 73 20 6e 6f 74 20 65 78 69 73 74 22 0a 0a 0a es not
exist"...
00f0 2a 2a 20 28 67 6e 6f 6d 65 2d 76 6f 6c 75 6d 65 ** (gnome-
volume

No. Time Source Destination
Protocol Info
14891 11200.815494 192.168.1.119 192.168.1.233
SCTP DATA

Frame 14891 (320 bytes on wire, 320 bytes captured)
Linux cooked capture
Internet Protocol, Src Addr: 192.168.1.119 (192.168.1.119), Dst Addr:
192.168.1.233 (192.168.1.233)
Stream Control Transmission Protocol, Src Port: 1031 (1031), Dst Port:
10000 (10000)
Source port: 1031
Destination port: 10000
Verification tag: 0x65a4fdfd
Checksum: 0x674439cb (correct CRC32C)
DATA chunk(ordered, complete segment, TSN: 1641290485, SID: 0,
SSN: 1, PPID: 0, payload length: 256 bytes)
Chunk type: DATA (0)
0... .... = Bit: Stop processing of the packet
.0.. .... = Bit: Do not report
Chunk flags: 0x03
.... ...1 = E-Bit: Last segment
.... ..1. = B-Bit: First segment
.... .0.. = U-Bit: Ordered deliviery
Chunk length: 272
TSN: 1641290485
Stream Identifier: 0x0000
Stream sequence number: 1
Payload protocol identifier: not specified (0)
Data (256 bytes)

0000 2d 6d 61 6e 61 67 65 72 3a 38 34 37 29 3a 20 57 -manager:847):
W
0010 41 52 4e 49 4e 47 20 2a 2a 3a 20 6d 61 6e 61 67 ARNING **:
manag
0020 65 72 2e 63 2f 31 30 39 39 3a 20 73 65 65 6d 73 er.c/1099:
seems
0030 20 74 68 61 74 20 48 41 4c 20 69 73 20 6e 6f 74 that HAL is
not
0040 20 72 75 6e 6e 69 6e 67 0a 0a 47 6e 6f 6d 65 2d
running..Gnome-
0050 4d 65 73 73 61 67 65 3a 20 67 6e 6f 6d 65 5f 65 Message:
gnome_e
0060 78 65 63 75 74 65 5f 61 73 79 6e 63 5f 77 69 74
xecute_async_wit
0070 68 5f 65 6e 76 5f 66 64 73 3a 20 72 65 74 75 72 h_env_fds:
retur
0080 6e 69 6e 67 20 2d 31 0a 0a 2a 2a 20 28 67 6e 6f ning -1..**
(gno
0090 6d 65 2d 63 75 70 73 2d 69 63 6f 6e 3a 38 35 33 me-cups-icon:
853
00a0 29 3a 20 57 41 52 4e 49 4e 47 20 2a 2a 3a 20 43 ): WARNING **:
C
00b0 6f 75 6c 64 20 6e 6f 74 20 73 74 61 72 74 20 74 ould not start
t
00c0 68 65 20 70 72 69 6e 74 65 72 20 74 72 61 79 20 he printer
tray
00d0 69 63 6f 6e 2c 20 62 65 63 61 75 73 65 20 74 68 icon, because
th
00e0 65 20 43 55 50 53 20 73 65 72 76 65 72 20 63 6f e CUPS server
co
00f0 75 6c 64 20 6e 6f 74 20 62 65 20 63 6f 6e 74 61 uld not be
conta

No. Time Source Destination
Protocol Info
14892 11200.816529 192.168.1.119 192.168.1.233
SCTP DATA

Frame 14892 (72 bytes on wire, 72 bytes captured)
Linux cooked capture
Internet Protocol, Src Addr: 192.168.1.119 (192.168.1.119), Dst Addr:
192.168.1.233 (192.168.1.233)
Stream Control Transmission Protocol, Src Port: 1031 (1031), Dst Port:
10000 (10000)
Source port: 1031
Destination port: 10000
Verification tag: 0x65a4fdfd
Checksum: 0x0230a0a0 (correct CRC32C)
DATA chunk(ordered, complete segment, TSN: 1641290486, SID: 0,
SSN: 1, PPID: 0, payload length: 6 bytes)
Chunk type: DATA (0)
0... .... = Bit: Stop processing of the packet
.0.. .... = Bit: Do not report
Chunk flags: 0x03
.... ...1 = E-Bit: Last segment
.... ..1. = B-Bit: First segment
.... .0.. = U-Bit: Ordered deliviery
Chunk length: 22
TSN: 1641290486
Stream Identifier: 0x0000
Stream sequence number: 1
Payload protocol identifier: not specified (0)
Chunk padding: 3030
Data (6 bytes)

0000 63 74 65 64 2e 0a cted..

No. Time Source Destination
Protocol Info
14893 11200.817927 192.168.1.119 192.168.1.233
SCTP ABORT

Frame 14893 (56 bytes on wire, 56 bytes captured)
Linux cooked capture
Internet Protocol, Src Addr: 192.168.1.119 (192.168.1.119), Dst Addr:
192.168.1.233 (192.168.1.233)
Stream Control Transmission Protocol, Src Port: 1031 (1031), Dst Port:
10000 (10000)
Source port: 1031
Destination port: 10000
Verification tag: 0x65a4fdfd
Checksum: 0xa23208ad (correct CRC32C)
ABORT chunk
Chunk type: ABORT (6)
0... .... = Bit: Stop processing of the packet
.0.. .... = Bit: Do not report
Chunk flags: 0x00
.... ...0 = T-Bit: Tag not reflected
Chunk length: 8
User initiated ABORT cause
Cause code: User initiated ABORT (0x000c)
Cause length: 4

No. Time Source Destination
Protocol Info
14894 11200.870181 192.168.1.233 192.168.1.119
SCTP SACK

Frame 14894 (64 bytes on wire, 64 bytes captured)
Linux cooked capture
Internet Protocol, Src Addr: 192.168.1.233 (192.168.1.233), Dst Addr:
192.168.1.119 (192.168.1.119)
Stream Control Transmission Protocol, Src Port: 10000 (10000), Dst
Port: 1031 (1031)
Source port: 10000
Destination port: 1031
Verification tag: 0xf31ad461
Checksum: 0xfea533ac (correct CRC32C)
SACK chunk (Cumulative TSN: 1641290484, a_rwnd: 32255, gaps: 0,
duplicate TSNs: 0)
Chunk type: SACK (3)
0... .... = Bit: Stop processing of the packet
.0.. .... = Bit: Do not report
Chunk flags: 0x00
Chunk length: 16
Cumulative TSN ACK: 1641290484
Advertised receiver window credit (a_rwnd): 32255
Number of gap acknowldgement blocks : 0
Number of duplicated TSNs: 0

No. Time Source Destination
Protocol Info
14895 11200.906652 192.168.1.233 192.168.1.119
SCTP SACK

Frame 14895 (64 bytes on wire, 64 bytes captured)
Linux cooked capture
Internet Protocol, Src Addr: 192.168.1.233 (192.168.1.233), Dst Addr:
192.168.1.119 (192.168.1.119)
Stream Control Transmission Protocol, Src Port: 10000 (10000), Dst
Port: 1031 (1031)
Source port: 10000
Destination port: 1031
Verification tag: 0xf31ad461
Checksum: 0x6e75f53e (correct CRC32C)
SACK chunk (Cumulative TSN: 1641290486, a_rwnd: 31993, gaps: 0,
duplicate TSNs: 0)
Chunk type: SACK (3)
0... .... = Bit: Stop processing of the packet
.0.. .... = Bit: Do not report
Chunk flags: 0x00
Chunk length: 16
Cumulative TSN ACK: 1641290486
Advertised receiver window credit (a_rwnd): 31993
Number of gap acknowldgement blocks : 0
Number of duplicated TSNs: 0