FACT++  1.0
static int is_header ( int  conn_id)
static

Definition at line 62 of file dna.c.

References DNA_CONNECTION::buffer, Dna_conns, HDR_MAGIC, RD_DATA, RD_HDR, DNA_CONNECTION::read_ast, READ_HEADER_SIZE, STA_DISC, DNA_CONNECTION::state, TRP_MAGIC, and TST_MAGIC.

Referenced by ast_read_h().

63 {
64  register DNA_CONNECTION *dna_connp = &Dna_conns[conn_id];
65  register int ret;
66 
67  ret = 0;
68  if( (vtohl(dna_connp->buffer[2]) == TRP_MAGIC) &&
69  (vtohl(dna_connp->buffer[1]) == 0) &&
70  (vtohl(dna_connp->buffer[0]) == READ_HEADER_SIZE) )
71  {
72  dna_connp->state = RD_HDR;
73  ret = 1;
74  }
75  else if( (vtohl(dna_connp->buffer[2]) == TST_MAGIC) &&
76  (vtohl(dna_connp->buffer[1]) == 0) &&
77  (vtohl(dna_connp->buffer[0]) == READ_HEADER_SIZE) )
78  {
79  dna_connp->state = RD_HDR;
80  ret = 1;
81  }
82  else if( (vtohl(dna_connp->buffer[2]) == (int)HDR_MAGIC ) &&
83  (vtohl(dna_connp->buffer[0]) == (int)READ_HEADER_SIZE ) )
84  {
85  dna_connp->state = RD_DATA;
86  ret = 1;
87  }
88  else
89  {
90 /*
91  dim_print_date_time();
92  printf( " conn: %d to %s@%s, expecting header\n", conn_id,
93  Net_conns[conn_id].task, Net_conns[conn_id].node );
94  printf( "buffer[0]=%d\n", vtohl(dna_connp->buffer[0]));
95  printf( "buffer[1]=%d\n", vtohl(dna_connp->buffer[1]));
96  printf( "buffer[2]=%x\n", vtohl(dna_connp->buffer[2]));
97  printf( "closing the connection.\n" );
98  printf( " Previous conn: %d, Previous Packet\n", Prev_conn_id);
99  printf( "buffer[0]=%d\n", vtohl(Prev_packet[0]));
100  printf( "buffer[1]=%d\n", vtohl(Prev_packet[1]));
101  printf( "buffer[2]=%x\n", vtohl(Prev_packet[2]));
102  printf( " Previous Buffer\n");
103  printf( "buffer[0]=%d\n", vtohl(Prev_buffer[0]));
104  printf( "buffer[1]=%d\n", vtohl(Prev_buffer[1]));
105  printf( "buffer[2]=%x\n", vtohl(Prev_buffer[2]));
106  fflush(stdout);
107 */
108  dna_connp->read_ast(conn_id, NULL, 0, STA_DISC);
109  ret = 0;
110  }
111  return(ret);
112 }
#define HDR_MAGIC
Definition: dim.h:209
#define READ_HEADER_SIZE
Definition: dna.c:21
#define STA_DISC
Definition: dim.h:197
Definition: dim.h:190
#define TST_MAGIC
Definition: dim.h:211
CONN_STATE state
Definition: dim.h:390
#define TRP_MAGIC
Definition: dim.h:212
DllExp DIM_NOSHARE DNA_CONNECTION * Dna_conns
Definition: conn_handler.c:31
int * buffer
Definition: dim.h:384
Definition: dim.h:190
void(* read_ast)()
Definition: dim.h:382

+ Here is the caller graph for this function: