44 |
|
|
45 |
/* Receive a message on the ISO layer, return code */ |
/* Receive a message on the ISO layer, return code */ |
46 |
static STREAM |
static STREAM |
47 |
iso_recv_msg(uint8 *code) |
iso_recv_msg(uint8 * code) |
48 |
{ |
{ |
49 |
STREAM s; |
STREAM s; |
50 |
uint16 length; |
uint16 length; |
52 |
|
|
53 |
s = tcp_recv(4); |
s = tcp_recv(4); |
54 |
if (s == NULL) |
if (s == NULL) |
55 |
return False; |
return NULL; |
56 |
|
|
57 |
in_uint8(s, version); |
in_uint8(s, version); |
58 |
if (version != 3) |
if (version != 3) |
59 |
{ |
{ |
60 |
error("TPKT v%d\n", version); |
error("TPKT v%d\n", version); |
61 |
return False; |
return NULL; |
62 |
} |
} |
63 |
|
|
64 |
in_uint8s(s, 1); /* pad */ |
in_uint8s(s, 1); /* pad */ |
66 |
|
|
67 |
s = tcp_recv(length - 4); |
s = tcp_recv(length - 4); |
68 |
if (s == NULL) |
if (s == NULL) |
69 |
return False; |
return NULL; |
70 |
|
|
71 |
in_uint8s(s, 1); /* hdrlen */ |
in_uint8s(s, 1); /* hdrlen */ |
72 |
in_uint8(s, *code); |
in_uint8(s, *code); |
121 |
uint8 code; |
uint8 code; |
122 |
|
|
123 |
s = iso_recv_msg(&code); |
s = iso_recv_msg(&code); |
124 |
if ((s == NULL) || (code != ISO_PDU_DT)) |
if (s == NULL) |
125 |
|
return NULL; |
126 |
|
|
127 |
|
if (code != ISO_PDU_DT) |
128 |
{ |
{ |
129 |
error("expected DT, got %d\n", code); |
error("expected DT, got 0x%x\n", code); |
130 |
return False; |
return NULL; |
131 |
} |
} |
132 |
|
|
133 |
return s; |
return s; |
144 |
|
|
145 |
iso_send_msg(ISO_PDU_CR); |
iso_send_msg(ISO_PDU_CR); |
146 |
|
|
147 |
if ((iso_recv_msg(&code) == NULL) || (code != ISO_PDU_CC)) |
if (iso_recv_msg(&code) == NULL) |
148 |
|
return False; |
149 |
|
|
150 |
|
if (code != ISO_PDU_CC) |
151 |
{ |
{ |
152 |
error("expected CC, got %d\n", code); |
error("expected CC, got 0x%x\n", code); |
153 |
tcp_disconnect(); |
tcp_disconnect(); |
154 |
return False; |
return False; |
155 |
} |
} |