12
12
* it under the terms of the GNU General Public License as published by
13
13
* the Free Software Foundation; either version 2 of the License, or
14
14
* (at your option) any later version.
16
16
* This program is distributed in the hope that it will be useful,
17
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
19
* GNU General Public License for more details.
21
21
* You should have received a copy of the GNU General Public License
22
22
* along with this program; if not, write to the Free Software
23
23
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
170
169
while (pkt_ptr != NULL) {
173
i < ((Len > (pkt_ptr->len) ? pkt_ptr->len : Len) - Offset);
176
c = pkt_ptr->data[i + Offset];
177
c1 = Hex_List[c >> 4];
178
c2 = Hex_List[c & 0xF];
183
if (j == 32) { /* Print and reset */
185
fprintf(fd, " %s\n", outbuf1);
191
Len = Len - pkt_ptr->len; /* Reduce amount by this much */
192
pkt_ptr = pkt_ptr->next;
172
i < ((Len > (pkt_ptr->len) ? pkt_ptr->len : Len) - Offset);
175
c = pkt_ptr->data[i + Offset];
176
c1 = Hex_List[c >> 4];
177
c2 = Hex_List[c & 0xF];
182
if (j == 32) { /* Print and reset */
184
fprintf(fd, " %s\n", outbuf1);
190
Len = Len - pkt_ptr->len; /* Reduce amount by this much */
191
pkt_ptr = pkt_ptr->next;
274
272
case RFCNB_SESSION_MESSAGE:
276
fprintf(fd, "SESSION MESSAGE: Length = %i\n", RFCNB_Pkt_Len(pkt->data));
277
RFCNB_Print_Hex(fd, pkt, RFCNB_Pkt_Hdr_Len,
274
fprintf(fd, "SESSION MESSAGE: Length = %i\n", RFCNB_Pkt_Len(pkt->data));
275
RFCNB_Print_Hex(fd, pkt, RFCNB_Pkt_Hdr_Len,
278
276
#ifdef RFCNB_PRINT_DATA
279
RFCNB_Pkt_Len(pkt->data) - RFCNB_Pkt_Hdr_Len);
277
RFCNB_Pkt_Len(pkt->data) - RFCNB_Pkt_Hdr_Len);
284
if (Prot_Print_Routine != 0) { /* Print the rest of the packet */
286
Prot_Print_Routine(fd, strcmp(dirn, "sent"), pkt, RFCNB_Pkt_Hdr_Len,
287
RFCNB_Pkt_Len(pkt->data) - RFCNB_Pkt_Hdr_Len);
282
if (Prot_Print_Routine != 0) { /* Print the rest of the packet */
284
Prot_Print_Routine(fd, strcmp(dirn, "sent"), pkt, RFCNB_Pkt_Hdr_Len,
285
RFCNB_Pkt_Len(pkt->data) - RFCNB_Pkt_Hdr_Len);
292
290
case RFCNB_SESSION_REQUEST:
294
fprintf(fd, "SESSION REQUEST: Length = %i\n",
295
RFCNB_Pkt_Len(pkt->data));
296
RFCNB_NBName_To_AName((char *) (pkt->data + RFCNB_Pkt_Called_Offset), lname);
297
fprintf(fd, " Called Name: %s\n", lname);
298
RFCNB_NBName_To_AName((char *) (pkt->data + RFCNB_Pkt_Calling_Offset), lname);
299
fprintf(fd, " Calling Name: %s\n", lname);
292
fprintf(fd, "SESSION REQUEST: Length = %i\n",
293
RFCNB_Pkt_Len(pkt->data));
294
RFCNB_NBName_To_AName((char *) (pkt->data + RFCNB_Pkt_Called_Offset), lname);
295
fprintf(fd, " Called Name: %s\n", lname);
296
RFCNB_NBName_To_AName((char *) (pkt->data + RFCNB_Pkt_Calling_Offset), lname);
297
fprintf(fd, " Calling Name: %s\n", lname);
303
301
case RFCNB_SESSION_ACK:
305
fprintf(fd, "RFCNB SESSION ACK: Length = %i\n",
306
RFCNB_Pkt_Len(pkt->data));
303
fprintf(fd, "RFCNB SESSION ACK: Length = %i\n",
304
RFCNB_Pkt_Len(pkt->data));
310
308
case RFCNB_SESSION_REJ:
311
fprintf(fd, "RFCNB SESSION REJECT: Length = %i\n",
312
RFCNB_Pkt_Len(pkt->data));
314
if (RFCNB_Pkt_Len(pkt->data) < 1) {
315
fprintf(fd, " Protocol Error, short Reject packet!\n");
317
fprintf(fd, " Error = %x\n", CVAL(pkt->data, RFCNB_Pkt_Error_Offset));
309
fprintf(fd, "RFCNB SESSION REJECT: Length = %i\n",
310
RFCNB_Pkt_Len(pkt->data));
312
if (RFCNB_Pkt_Len(pkt->data) < 1) {
313
fprintf(fd, " Protocol Error, short Reject packet!\n");
315
fprintf(fd, " Error = %x\n", CVAL(pkt->data, RFCNB_Pkt_Error_Offset));
322
320
case RFCNB_SESSION_RETARGET:
324
fprintf(fd, "RFCNB SESSION RETARGET: Length = %i\n",
325
RFCNB_Pkt_Len(pkt->data));
327
/* Print out the IP address etc and the port? */
322
fprintf(fd, "RFCNB SESSION RETARGET: Length = %i\n",
323
RFCNB_Pkt_Len(pkt->data));
325
/* Print out the IP address etc and the port? */
331
329
case RFCNB_SESSION_KEEP_ALIVE:
333
fprintf(fd, "RFCNB SESSION KEEP ALIVE: Length = %i\n",
334
RFCNB_Pkt_Len(pkt->data));
331
fprintf(fd, "RFCNB SESSION KEEP ALIVE: Length = %i\n",
332
RFCNB_Pkt_Len(pkt->data));
355
353
if ((addr = inet_addr(host)) == INADDR_NONE) { /* Oh well, a good try :-) */
357
/* Now try a name look up with gethostbyname */
359
if ((hp = gethostbyname(host)) == NULL) { /* Not in DNS */
361
/* Try NetBIOS name lookup, how the hell do we do that? */
362
RFCNB_errno = RFCNBE_BadName; /* Is this right? */
363
RFCNB_saved_errno = errno;
366
} else { /* We got a name */
355
/* Now try a name look up with gethostbyname */
357
if ((hp = gethostbyname(host)) == NULL) { /* Not in DNS */
359
/* Try NetBIOS name lookup, how the hell do we do that? */
360
RFCNB_errno = RFCNBE_BadName; /* Is this right? */
361
RFCNB_saved_errno = errno;
364
} else { /* We got a name */
367
365
Dest_IP->s_addr = (*((struct in_addr*)hp->h_addr_list[0])).s_addr;
369
367
} else { /* It was an IP address */
370
Dest_IP->s_addr = addr;
368
Dest_IP->s_addr = addr;
499
497
case RFCNB_SESSION_REJ: /* Didnt like us ... too bad */
501
/* Why did we get rejected ? */
503
switch (CVAL(resp, RFCNB_Pkt_Error_Offset)) {
506
RFCNB_errno = RFCNBE_CallRejNLOCN;
509
RFCNB_errno = RFCNBE_CallRejNLFCN;
512
RFCNB_errno = RFCNBE_CallRejCNNP;
515
RFCNB_errno = RFCNBE_CallRejInfRes;
518
RFCNB_errno = RFCNBE_CallRejUnSpec;
521
RFCNB_errno = RFCNBE_ProtErr;
499
/* Why did we get rejected ? */
501
switch (CVAL(resp, RFCNB_Pkt_Error_Offset)) {
504
RFCNB_errno = RFCNBE_CallRejNLOCN;
507
RFCNB_errno = RFCNBE_CallRejNLFCN;
510
RFCNB_errno = RFCNBE_CallRejCNNP;
513
RFCNB_errno = RFCNBE_CallRejInfRes;
516
RFCNB_errno = RFCNBE_CallRejUnSpec;
519
RFCNB_errno = RFCNBE_ProtErr;
528
526
case RFCNB_SESSION_ACK: /* Got what we wanted ... */
533
531
case RFCNB_SESSION_RETARGET: /* Go elsewhere */
535
*redirect = TRUE; /* Copy port and ip addr */
537
memcpy(Dest_IP, (resp + RFCNB_Pkt_IP_Offset), sizeof(struct in_addr));
538
*port = SVAL(resp, RFCNB_Pkt_Port_Offset);
533
*redirect = TRUE; /* Copy port and ip addr */
535
memcpy(Dest_IP, (resp + RFCNB_Pkt_IP_Offset), sizeof(struct in_addr));
536
*port = SVAL(resp, RFCNB_Pkt_Port_Offset);
543
541
default: /* A protocol error */
545
RFCNB_errno = RFCNBE_ProtErr;
543
RFCNB_errno = RFCNBE_ProtErr;