48 "RFCNBE_OK: Routine completed successfully.",
49 "RFCNBE_NoSpace: No space available for a malloc call.",
50 "RFCNBE_BadName: NetBIOS name could not be translated to IP address.",
51 "RFCNBE_BadRead: Read system call returned an error. Check errno.",
52 "RFCNBE_BadWrite: Write system call returned an error. Check errno.",
53 "RFCNBE_ProtErr: A protocol error has occurred.",
54 "RFCNBE_ConGone: Connection dropped during a read or write system call.",
55 "RFCNBE_BadHandle: Bad connection handle passed.",
56 "RFCNBE_BadSocket: Problems creating socket.",
57 "RFCNBE_ConnectFailed: Connection failed. See errno.",
58 "RFCNBE_CallRejNLOCN: Call rejected. Not listening on called name.",
59 "RFCNBE_CallRejNLFCN: Call rejected. Not listening for called name.",
60 "RFCNBE_CallRejCNNP: Call rejected. Called name not present.",
61 "RFCNBE_CallRejInfRes: Call rejected. Name present, but insufficient resources.",
62 "RFCNBE_CallRejUnSpec: Call rejected. Unspecified error.",
63 "RFCNBE_BadParam: Bad parameters passed to a routine.",
64 "RFCNBE_Timeout: IO Operation timed out ..."
78 for (i = 0; i < 16; i++) {
88 c1 = (char) ((
int) c / 16 + (
int)
'A');
89 c2 = (char) ((
int) c % 16 + (
int)
'A');
93 name2[i * 2 + 1] = c2;
114 for (i = 0; i < 16; i++) {
118 c1 = (char) ((c >> 4) +
'A');
119 c2 = (char) ((c & 0xF) +
'A');
122 NBName[i * 2 + 1] = c2;
135 for (i = 0; i < 16; i++) {
138 c2 = NBName[i * 2 + 1];
140 c = (char) (((
int) c1 - (
int)
'A') * 16 + ((
int) c2 - (
int)
'A'));
153 char c1, c2, outbuf1[33];
157 static char Hex_List[17] =
"0123456789ABCDEF";
163 while (pkt_ptr !=
NULL) {
166 i < ((Len > (pkt_ptr->
len) ? pkt_ptr->
len : Len) - Offset);
169 c = pkt_ptr->
data[i + Offset];
170 c1 = Hex_List[c >> 4];
171 c2 = Hex_List[c & 0xF];
178 fprintf(fd,
" %s\n", outbuf1);
184 Len = Len - pkt_ptr->
len;
185 pkt_ptr = pkt_ptr->
next;
194 fprintf(fd,
" %s\n", outbuf1);
218 if ((pkt->
data = (
char *) malloc(n)) ==
NULL) {
236 while (pkt !=
NULL) {
238 pkt_next = pkt->
next;
240 data_ptr = pkt->
data;
242 if (data_ptr !=
NULL)
261 fprintf(fd,
"RFCNB Pkt %s:", dirn);
269#ifdef RFCNB_PRINT_DATA
285 fprintf(fd,
"SESSION REQUEST: Length = %i\n",
288 fprintf(fd,
" Called Name: %s\n", lname);
290 fprintf(fd,
" Calling Name: %s\n", lname);
296 fprintf(fd,
"RFCNB SESSION ACK: Length = %i\n",
302 fprintf(fd,
"RFCNB SESSION REJECT: Length = %i\n",
306 fprintf(fd,
" Protocol Error, short Reject packet!\n");
315 fprintf(fd,
"RFCNB SESSION RETARGET: Length = %i\n",
324 fprintf(fd,
"RFCNB SESSION KEEP ALIVE: Length = %i\n",
347 if ((hp = gethostbyname(host)) ==
NULL) {
357 memcpy((
void *) Dest_IP, (
void *) hp->h_addr_list[0],
sizeof(
struct in_addr));
362 memcpy((
void *) Dest_IP, (
void *) &addr,
sizeof(
struct in_addr));
386 struct sockaddr_in Socket;
391 if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
397 memset((
char *) &Socket, 0,
sizeof(Socket));
398 memcpy((
char *) &Socket.sin_addr, (
char *) &Dest_IP,
sizeof(Dest_IP));
400 Socket.sin_port = htons(
port);
401 Socket.sin_family = PF_INET;
405 if (connect(fd, (
struct sockaddr *) &Socket,
sizeof(Socket)) < 0) {
423 struct in_addr *Dest_IP,
443 sess_pkt = pkt->
data;
456 fprintf(stderr,
"Sending packet: ");
465 fprintf(stderr,
"Getting packet.\n");
469 res_pkt.
len =
sizeof(resp);
#define RFCNBE_CallRejNLOCN
#define RFCNBE_CallRejInfRes
#define RFCNBE_CallRejCNNP
#define RFCNBE_CallRejNLFCN
#define RFCNBE_ConnectFailed
#define RFCNBE_CallRejUnSpec
int RFCNB_Put_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len)
int RFCNB_Get_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len)
#define RFCNB_SESSION_REQUEST
#define RFCNB_Pkt_Hdr_Len
#define RFCNB_Pkt_Type(p)
#define RFCNB_Pkt_N2Len_Offset
#define RFCNB_Pkt_Type_Offset
#define RFCNB_SESSION_REJ
#define RFCNB_Put_Pkt_Len(p, v)
#define RFCNB_Pkt_Sess_Len
#define RFCNB_Pkt_Error_Offset
#define RFCNB_SESSION_KEEP_ALIVE
#define RFCNB_Pkt_Called_Offset
#define RFCNB_Pkt_N1Len_Offset
#define RFCNB_SESSION_RETARGET
#define RFCNB_Pkt_Port_Offset
#define RFCNB_SESSION_ACK
#define RFCNB_Pkt_IP_Offset
#define RFCNB_SESSION_MESSAGE
#define RFCNB_Pkt_Calling_Offset
int RFCNB_Session_Req(struct RFCNB_Con *con, char *Called_Name, char *Calling_Name, BOOL *redirect, struct in_addr *Dest_IP, int *port)
struct RFCNB_Pkt * RFCNB_Alloc_Pkt(int n)
void RFCNB_NBName_To_AName(char *NBName, char *AName)
int RFCNB_Name_To_IP(char *host, struct in_addr *Dest_IP)
void RFCNB_Print_Pkt(FILE *fd, char *dirn, struct RFCNB_Pkt *pkt, int len)
void RFCNB_AName_To_NBName(char *AName, char *NBName)
void RFCNB_Print_Hex(FILE *fd, struct RFCNB_Pkt *pkt, int Offset, int Len)
void RFCNB_CvtPad_Name(char *name1, char *name2)
void RFCNB_Free_Pkt(struct RFCNB_Pkt *pkt)
int RFCNB_IP_Connect(struct in_addr Dest_IP, int port)
const char * RFCNB_Error_Strings[]
RFCNB_Prot_Print_Routine * Prot_Print_Routine