void client(void) { int s_source; struct sockaddr_in local; int len; diag_printf("client:started\n"); ChangeMacAddr(); init_all_network_interfaces(); show_threads(); s_source = socket(AF_INET, SOCK_DGRAM, 0); if (s_source < 0) { pexit("stream socket"); } memset(&local, 0, sizeof(local)); local.sin_family = AF_INET; local.sin_len = sizeof(local); local.sin_port = htons(SOURCE_PORT); local.sin_addr.s_addr = inet_addr("10.130.249.103");//htonl(INADDR_LOOPBACK); while(1) { if ( (len= sendto(s_source,data_buf_write,sizeof(data_buf_write), 0,(struct sockaddr *)&local,sizeof(local))) < 0 ) { //CYG_TEST_FAIL_FINISH("Error writing buffer"); cyg_thread_yield(); } //else // diag_printf("sendto success\n"); } close(s_source); }
static int usblp_read( struct usblp *usblp, char *buffer, size_t count, int *ppos) { if (!usblp->bidir) return -EINVAL; if (usblp->readurb.status == -EINPROGRESS) { // if (file->f_flags & O_NONBLOCK) // return -EAGAIN; #if 0 //ZOT716u2 while (usblp->readurb.status == -EINPROGRESS) { // if (signal_pending(current)) // return -EINTR; cyg_thread_yield(); // interruptible_sleep_on(&usblp->wait); } #else //ZOT716u2 while (usblp->readurb.status == -EINPROGRESS) { cyg_semaphore_wait(usblp->wait); } #endif //ZOT716u2 } if (!usblp->dev) return -ENODEV; #ifdef SUPPORT_PRN_COUNT count = count < USBLP_BUF_SIZE ? count : USBLP_BUF_SIZE; copy_to_user(buffer, (uint8 *)usblp->readurb.transfer_buffer + usblp->readcount, count); #else if (usblp->readurb.status) { //{{MARK_DEBUG // err("usblp%d: error %d reading from printer", // usblp->minor, usblp->readurb.status); //}}MARK_DEBUG usblp->readurb.dev = usblp->dev; usblp->readcount = 0; usb_submit_urb(&usblp->readurb); return -EIO; } count = count < usblp->readurb.actual_length - usblp->readcount ? count : usblp->readurb.actual_length - usblp->readcount; if (copy_to_user(buffer, (uint8 *)usblp->readurb.transfer_buffer + usblp->readcount, count)) return -EFAULT; #endif //SUPPORT_PRN_COUNT if ((usblp->readcount += count) == usblp->readurb.actual_length) { usblp->readcount = 0; usblp->readurb.dev = usblp->dev; usb_submit_urb(&usblp->readurb); } return count; }
//------------------------------------------------------------------- // SNMP AGENT process //------------------------------------------------------------------- void SnmpAgent(cyg_addrword_t data) //615wu { if(snmp_open(&session) == NULL) return; for (;;) { snmp_read (&session); cyg_thread_yield(); //615wu } }
/*--------------------------------------------------------*/ void udp_client_process(void){ /******************** lock the Scheduler ************************/ cyg_scheduler_lock(); /****************************************************************/ static struct ctimer backoff_timer; PRINTF("UDP client started\n"); set_global_address(); print_local_addresses(); client_conn = udp_new(NULL, UIP_HTONS(UDP_SERVER_PORT), NULL); udp_bind(client_conn, UIP_HTONS(UDP_CLIENT_PORT)); PRINTF("Created a connection with the server "); PRINT6ADDR(&client_conn->ripaddr); PRINTF(" local/remote port %u/%u\n", UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport)); ctimer_set(&backoff_timer,SEND_TIME,send_packet,NULL); // PRINTF(" local/remote port %u/%u\n", client_conn->lport, client_conn->rport); void* message = NULL; /******************** unlock the Scheduler ************************/ cyg_scheduler_unlock(); /****************************************************************/ while(1){ // cyg_thread_yield(); message = cyg_mbox_tryget (mbox_out_tcpip_handle); MyEvent_t* msg_local = message ; if ( message != NULL){ cyg_handle_t* event_handlePtr; event_handlePtr = (cyg_handle_t*) msg_local-> dataPtr; if( cyg_thread_self() == *event_handlePtr){ tcpip_handler(); } } cyg_thread_yield(); } }
/**************************************************************************** do a switch on the message type, and return the response size ****************************************************************************/ static int switch_message(int type,char *inbuf,char *outbuf, int size,int bufsize, int ProcSockID, int threadid) { int outsize = 0; static int num_smb_messages = sizeof(smb_messages) / sizeof(struct smb_message_struct); int match; // extern int Client; connection_struct *conn; //0703 last_message = type; /* make sure this is an SMB packet */ if (strncmp(smb_base(inbuf),"\377SMB",4) != 0) { //os kwait(NULL); cyg_thread_yield(); return(-1); } for (match=0;match<num_smb_messages;match++) if (smb_messages[match].code == type) break; if (match == num_smb_messages) { //Jesse outsize = reply_unknown(inbuf,outbuf); outsize = ERROR(ERRSRV,ERRaccess); } else { if (smb_messages[match].fn) { //0609 int flags = smb_messages[match].flags; //0609 static uint16 last_session_tag = UID_FIELD_INVALID; uint16 session_tag = SVAL(inbuf,smb_uid); /* Ensure this value is replaced in the incoming packet. */ SSVAL(inbuf,smb_uid,session_tag); //0703 last_inbuf = inbuf; conn = conn_find(SVAL(inbuf, smb_tid), threadid); if (conn) conn->lastused = (msclock() /1000); //add by ron 7/5/2001 outsize = smb_messages[match].fn(conn,inbuf,outbuf,size,bufsize, ProcSockID, threadid); } else { outsize = reply_unknown(inbuf,outbuf); } } return(outsize); }
void thread_join(cyg_handle_t* handle, cyg_thread* thread, cyg_thread_info* info) { BOOL ex = FALSE; while((ex == FALSE) && (handle != NULL)) { cyg_thread_get_info(*handle, thread->unique_id, info); //diag_printf("state is %d\n",info->state); switch(info->state) { case 16: cyg_thread_delete(*handle); ex = TRUE; break; default: cyg_thread_yield(); break; } } }
static void test_tcp_socket_thread_join(int ithread_handle) { cyg_thread_info info; cyg_uint16 id = 0; cyg_bool rc; cyg_handle_t next_thread = 0; cyg_uint16 next_id = 0; while(cyg_thread_get_next(&next_thread, &next_id) != false) { if(ithread_handle == next_thread) { id = next_id; break; } } while(1) { rc = cyg_thread_get_info(ithread_handle, id, &info); if(rc == false) { printf("Error get thread %d info\n", ithread_handle); break; } else { if((info.state & EXITED) != 0) { break; } } cyg_thread_yield(); } }
void main_thread_entry(cyg_addrword_t p) { CYG_TEST_INFO("Initializing lwIP"); cyg_lwip_simple_init(); test_state = TEST_CHAT_INIT; req_state = REQ_DNS_INIT; while (1) { cyg_lwip_simple_poll(); switch (test_state) { case TEST_INITIAL: diag_printf("INFO:<Starting test run (%d/%d)>\n", run, NUM_RUNS); test_state = TEST_CHAT_INIT; break; case TEST_CHAT_INIT: CYG_TEST_INFO("Initializing chat"); sd = sio_open(SIO_DEV_PPPOS); if (!sd) CYG_TEST_FAIL_FINISH("Cannot open serial"); chat = chat_new(sd, chat_items, CHAT_TIMEOUT, chat_cb, chat_send_cb, NULL); if (!chat) CYG_TEST_FAIL_FINISH("Cannot allocate chat"); test_state = TEST_CHAT_RUN; break; case TEST_CHAT_RUN: chat_poll(chat); break; case TEST_CHAT_FINISH: chat_free(chat); if (chat_ok) test_state = TEST_PPP_INIT; else test_state = TEST_NEXT_RUN; break; case TEST_PPP_INIT: CYG_TEST_INFO("Initializing PPP"); if (ppp_init() != ERR_OK) CYG_TEST_FAIL_FINISH("Cannot initialize PPP"); pd = ppp_open_serial(sd, ppp_status_cb, (void *) pd); if (pd < 0) CYG_TEST_FAIL_FINISH("Cannot open PPP over serial"); ppp_set_auth(PPPAUTHTYPE_ANY, CYGDAT_NET_LWIP_PPP_TEST_USERNAME, CYGDAT_NET_LWIP_PPP_TEST_PASSWORD); test_state = TEST_PPP_INIT_WAIT; break; case TEST_PPP_INIT_WAIT: ppp_poll(pd); break; case TEST_PPP_UP: ppp_poll(pd); handle_req_state(); break; case TEST_PPP_CLOSE: ppp_close(pd); test_state = TEST_PPP_CLOSE_WAIT; break; case TEST_PPP_CLOSE_WAIT: ppp_poll(pd); if (!ppp_is_open(pd)) // Escape from data mode sio_write(sd, (u8_t *) "+++", 3); cyg_thread_delay(200); test_state = TEST_NEXT_RUN; break; case TEST_NEXT_RUN: if (run < NUM_RUNS) { run++; test_state = TEST_INITIAL; } else { test_state = TEST_FINISH; } break; case TEST_FINISH: test_state = TEST_CHAT_INIT; diag_printf("INFO:<Test done (%d/%d) successful runs\n", success, NUM_RUNS); break; } cyg_thread_yield(); } }
void eloop_run(void) { //eason 20100407 fd_set *rfds, *wfds, *efds; int res; struct timeval _tv; struct os_time tv, now; #if 0 //eason 20100407 rfds = os_malloc(sizeof(*rfds)); wfds = os_malloc(sizeof(*wfds)); efds = os_malloc(sizeof(*efds)); if (rfds == NULL || wfds == NULL || efds == NULL) { printf("eloop_run - malloc failed\n"); goto out; } #endif //eason 20100407 while (!eloop.terminate && (eloop.timeout || eloop.readers.count > 0 || eloop.writers.count > 0 || eloop.exceptions.count > 0)) { #if 0 //eason 20100407 if (eloop.timeout) { os_get_time(&now); if (os_time_before(&now, &eloop.timeout->time)) os_time_sub(&eloop.timeout->time, &now, &tv); else tv.sec = tv.usec = 0; #if 0 printf("next timeout in %lu.%06lu sec\n", tv.sec, tv.usec); #endif _tv.tv_sec = tv.sec; _tv.tv_usec = tv.usec; } eloop_sock_table_set_fds(&eloop.readers, rfds); eloop_sock_table_set_fds(&eloop.writers, wfds); eloop_sock_table_set_fds(&eloop.exceptions, efds); res = select(eloop.max_sock + 1, rfds, wfds, efds, eloop.timeout ? &_tv : NULL); if (res < 0 && errno != EINTR && errno != 0) { perror("select"); goto out; } eloop_process_pending_signals(); #endif //eason 20100407 /* check if some registered timeouts have occurred */ if (eloop.timeout) { struct eloop_timeout *tmp; /*eason 20100407 os_get_time(&now); if (!os_time_before(&now, &eloop.timeout->time)) {*/ if (jiffies >= (eloop.timeout->timeout)){ //eason 20100407 tmp = eloop.timeout; eloop.timeout = eloop.timeout->next; tmp->handler(tmp->eloop_data, tmp->user_data); os_free(tmp); } } #if 0 //eason 20100407 if (res <= 0) continue; eloop_sock_table_dispatch(&eloop.readers, rfds); eloop_sock_table_dispatch(&eloop.writers, wfds); eloop_sock_table_dispatch(&eloop.exceptions, efds); #else eloop_sock_table_dispatch(&eloop.readers); eloop_sock_table_dispatch(&eloop.writers); eloop_sock_table_dispatch(&eloop.exceptions); #endif //eason 20100407 cyg_thread_yield(); //eason 20100407 } #if 0 //eason 20100407 out: os_free(rfds); os_free(wfds); os_free(efds); #endif //eason 20100407 }
void PortNWrite(cyg_addrword_t data) { uint32 start; int written; int port = UsedPortNumber; #ifdef SUPPORT_PRN_COUNT BYTE reqbuf[40] = {0x1B,0x25,0x2D,0x31,0x32,0x33,0x34,0x35,0x58, 0x40,0x50,0x4A,0x4C,0x20,0x49,0x4E,0x46,0x4F,0x20, 0x50,0x41,0x47,0x45,0x43,0x4F,0x55,0x4E,0x54,0x20,0x0D,0x0A, 0x1B,0x25,0x2D,0x31,0x32,0x33,0x34,0x35,0x58}; BYTE respbuf[40] = {0}; #endif while( 1 ) { cyg_semaphore_wait (&SP_SIGNAL_PORT_1); PNW_Statu[port] = 1; //for dbg //ZOTIPS PrnStartPrintNegotiate( port ); while(PrnStartPrintNegotiate( port )!=0) cyg_thread_yield(); #ifdef SUPPORT_PRN_COUNT // check if it is IEEE1284 or USB printer device // if( port >= NUM_OF_1284_PORT ){ if(PrnLangSupport(port,P1284_PJL)) usbprn_write( port, reqbuf, 40 ); // } #endif //SUPPORT_PRN_COUNT //ZOTIPS armond_printf("Start writing, Data size: %d\n",PortIO[port].DataSize); start = jiffies; while( jiffies - start < PRN_EXIT_PRINT_MODE_TIME ) { if( PortIO[port].DataSize ) { written = 0; PortIO[port].TotalSize = PortIO[port].DataSize; //for simonsay.htm to debug Printing_StartNum[port] = (jiffies ? jiffies : 1); do { #ifndef PRNTEST // check if it is IEEE1284 or USB printer device written = usbprn_write( port, PortIO[port].DataPtr, PortIO[port].DataSize ); //written = PortIO[port].DataSize; #else written = PortIO[port].DataSize; //615wu-spooler-temp #endif PortIO[port].DataSize = PortIO[port].TotalSize - written; if( PortIO[port].DataSize ) PortIO[port].PortTimeout++; else PortIO[port].PortTimeout = 0; } while( written < PortIO[port].TotalSize ); start = jiffies; PortIO[port].DataSize = 0; //for simonsay.htm to debug Printing_StartNum[port] = 0; } // cyg_thread_yield(); if( DMAPrinting( port ) == 0 ) { // ppause( 20 ); ppause( 10 ); if( PrnGetPrinterStatus( port ) == PrnNoUsed ) ppause( 100 ); } } //ZOTIPS armond_printf("End writing\n"); PrnEndPrintNegotiate( port ); adjPortType[port] = PrnReadPortStatus( port ); #ifdef SUPPORT_PRN_COUNT //read pagecount info from printer if(PrnLangSupport(port,P1284_PJL)){ memset(respbuf,0,40); usbprn_read( port, respbuf, 30 ); PageCount[port] = atol(memchr(respbuf,0x0A,30)); } #endif PNW_Statu[port] = 0; //for dbg G_PortReady |= ( 1 << port ); } }
static int usblp_write( struct usblp *usblp, const char *buffer, size_t count, int *ppos) { int timeout, errno = 0, writecount = 0; uint32 start; //ZOT716u2 armond_printf("Start usblp_write\n"); while (writecount < count) { // FIXME: only use urb->status inside completion // callbacks; this way is racey... if (usblp->writeurb.status == -EINPROGRESS) { // if (file->f_flags & O_NONBLOCK) // return -EAGAIN; #if 0 //ZOT716u2 start = jiffies; timeout = USBLP_WRITE_TIMEOUT; while ( usblp->writeurb.status == -EINPROGRESS) { // if (signal_pending(current)) // return writecount ? writecount : -EINTR; //cyg_thread_yield(); // timeout = interruptible_sleep_on_timeout(&usblp->wait, timeout); if( jiffies - start > timeout ) break; cyg_thread_yield(); } #else //ZOT716u2 timeout = USBLP_WRITE_TIMEOUT; if (timeout && usblp->writeurb.status == -EINPROGRESS) { timeout = cyg_semaphore_timed_wait(usblp->wait, cyg_current_time() + ((timeout / MSPTICK)?(timeout / MSPTICK):1)); } #endif //ZOT716u2 } if (!usblp->dev) return -ENODEV; if (usblp->writeurb.status != 0) { //Print Server Recover Mechanism for OHCI //635u2 if (usblp->writeurb.status != -EINPROGRESS) { usblp->writeurb.status = 0; return writecount; } if (usblp->quirks & USBLP_QUIRK_BIDIR) { //{{MARK_DEBUG // if (usblp->writeurb.status != -EINPROGRESS) // err("usblp%d: error %d writing to printer", // usblp->minor, usblp->writeurb.status); //}}MARK_DEBUG errno = usblp->writeurb.status; } else { // errno = usblp_check_status(usblp, errno); errno = usblp->writeurb.status; } continue; } writecount += usblp->writeurb.transfer_buffer_length; usblp->writeurb.transfer_buffer_length = 0; if (writecount == count) continue; usblp->writeurb.transfer_buffer_length = (count - writecount) < USBLP_BUF_SIZE ? (count - writecount) : USBLP_BUF_SIZE; copy_from_user(usblp->writeurb.transfer_buffer, buffer + writecount, usblp->writeurb.transfer_buffer_length); usblp->writeurb.dev = usblp->dev; usb_submit_urb(&usblp->writeurb); //635u2 /* #if defined(N635U2)|| defined(N635U2W) if(usblp->dev->ttport == 0) { if(usblp->dev->speed == USB_SPEED_HIGH) PrnLightToggle[1]++; else PrnLightToggle[3]++; } else { if(usblp->dev->speed == USB_SPEED_HIGH) PrnLightToggle[2]++; else PrnLightToggle[4]++; } #else USBLightToggle++; #endif */ #if 0 //ZOT716u2 USBLightToggle++; #else //ZOT716u2 if(usblp->dev->speed == USB_SPEED_HIGH) USB20LightToggle++; else USB11LightToggle++; #endif //ZOT716u2 } return count; }
static Cyg_ErrNo disk_bwrite(cyg_io_handle_t handle, const void *buf, cyg_uint32 *len, // In blocks cyg_uint32 pos) // In blocks { cyg_devtab_entry_t *t = (cyg_devtab_entry_t *) handle; disk_channel *chan = (disk_channel *) t->priv; disk_controller *ctlr = chan->controller; disk_funs *funs = chan->funs; cyg_disk_info_t *info = chan->info; cyg_uint32 size = *len; cyg_uint8 *bbuf = (cyg_uint8 * const) buf; Cyg_ErrNo res = ENOERR; cyg_uint32 last; cyg_drv_mutex_lock( &ctlr->lock ); while( ctlr->busy ) cyg_drv_cond_wait( &ctlr->queue ); if (info->connected && chan->valid) { ctlr->busy = true; if (NULL != chan->partition) { pos += chan->partition->start; last = chan->partition->end; } else { last = info->blocks_num-1; } D(("disk write block=%d len=%d buf=%p\n", pos, *len, buf)); while( size > 0 ) { cyg_uint32 tfr = size; if (pos > last) { res = -EIO; goto done; } if( tfr > info->ident.max_transfer ) tfr = info->ident.max_transfer; ctlr->result = -EWOULDBLOCK; cyg_drv_dsr_lock(); res = (funs->write)(chan, (void*)bbuf, tfr, pos); if( res == -EWOULDBLOCK ) { // If the driver replys EWOULDBLOCK, then the transfer is // being handled asynchronously and when it is finished it // will call disk_transfer_done(). This will wake us up here // to continue. while( ctlr->result == -EWOULDBLOCK ) cyg_drv_cond_wait( &ctlr->async ); res = ctlr->result; } cyg_drv_dsr_unlock(); if (ENOERR != res) goto done; if (!info->connected) { res = -EINVAL; goto done; } bbuf += tfr * info->block_size; pos += tfr; size -= tfr; } ctlr->busy = false; cyg_drv_cond_signal( &ctlr->queue ); } else res = -EINVAL; done: cyg_drv_mutex_unlock( &ctlr->lock ); #ifdef CYGPKG_KERNEL cyg_thread_yield(); #endif *len -= size; return res; }
void mainfunc(cyg_addrword_t data) { /******************** lock the Scheduler ************************/ cyg_scheduler_lock(); /****************************************************************/ printf("Hello, eCos mainfunc!\n"); ds2411_id[0] = 0x00; ds2411_id[1] = 0x12; ds2411_id[2] = 0x75; ds2411_id[3] = 0x00; ds2411_id[4] = 0x0c; ds2411_id[5] = 0x59; //ds2411_id[6] = 0x57; //ds2411_id[7] = 0x3d; ds2411_id[6] = 0x10; ds2411_id[7] = 0x17; ds2411_id[2] &= 0xfe; /* ds2411_id[0] = 0x02; ds2411_id[1] = 0x00; ds2411_id[2] = 0x00; ds2411_id[3] = 0x00; ds2411_id[4] = 0x00; ds2411_id[5] = 0x00; //ds2411_id[6] = 0x57; //ds2411_id[7] = 0x3d; ds2411_id[6] = 0x00; ds2411_id[7] = 0x00; */ /* for setting "hardcoded" IEEE 802.15.4 MAC addresses */ #ifdef IEEE_802154_MAC_ADDRESS { uint8_t ieee[] = IEEE_802154_MAC_ADDRESS; memcpy(ds2411_id, ieee, sizeof(uip_lladdr.addr)); ds2411_id[7] = node_id & 0xff; } #endif random_init(5); set_rime_addr(); NETSTACK_RADIO.init(); { cyg_uint8 longaddr[8]; cyg_uint16 shortaddr; shortaddr = (rimeaddr_node_addr.u8[0] << 8) + rimeaddr_node_addr.u8[1]; memset(longaddr, 0, sizeof(longaddr)); rimeaddr_copy((rimeaddr_t *)&longaddr, &rimeaddr_node_addr); printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ", longaddr[0], longaddr[1], longaddr[2], longaddr[3], longaddr[4], longaddr[5], longaddr[6], longaddr[7]); uz2400_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr); } uz2400_set_channel(RF_CHANNEL);/////////////////////////////////////////// #if WITH_UIP6 memcpy(&uip_lladdr.addr, ds2411_id, sizeof(uip_lladdr.addr)); /* Setup nullmac-like MAC for 802.15.4 */ /* sicslowpan_init(sicslowmac_init(&cc2420_driver)); */ /* printf(" %s channel %u\n", sicslowmac_driver.name, RF_CHANNEL); */ /* Setup X-MAC for 802.15.4 */ queuebuf_init(); //NETSTACK_RADIO.init(); NETSTACK_RDC.init(); NETSTACK_MAC.init(); NETSTACK_NETWORK.init(); printf("%s %s, channel check rate %lu Hz, radio channel %u\n", NETSTACK_MAC.name, NETSTACK_RDC.name, CLOCK_CONF_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1: NETSTACK_RDC.channel_check_interval()), RF_CHANNEL); //================ uip_init(); rpl_init(); //============= printf("Tentative link-local IPv6 address "); { uip_ds6_addr_t *lladdr=NULL; int i; lladdr = uip_ds6_get_link_local(-1); for(i = 0; i < 7; ++i) { printf("%02x%02x:", lladdr->ipaddr.u8[i * 2], lladdr->ipaddr.u8[i * 2 + 1]); } printf("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]); } if(!UIP_CONF_IPV6_RPL) { uip_ipaddr_t ipaddr; int i; uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0); uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE); printf("Tentative global IPv6 address "); for(i = 0; i < 7; ++i) { printf("%02x%02x:", ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]); } printf("%02x%02x\n", ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]); } #endif /* WITH_UIP6 */ static cyg_uint32 GLedPinspec; GLedPinspec = CYGHWR_HAL_STM32_GPIO( C, 6, OUT_50MHZ , OUT_PUSHPULL ); volatile static cyg_uint8 blink=0; /******************** unlock the Scheduler ************************/ cyg_scheduler_unlock(); /****************************************************************/ while(1){ /* blink=~blink; CYGHWR_HAL_STM32_GPIO_OUT(GLedPinspec,blink); cyg_thread_delay(500); */ cyg_thread_yield(); } }
//os void smbd_process(int ProcSockID, void *nouse1, void *nouse2) void smbd_process (cyg_addrword_t data) { int ProcSockID = data; //0704 extern int smb_echo_count; //0705 time_t last_timeout_processing_time = time(NULL); /* 0416 from global variable */ //char __inbuf[SMB_BUFFER_SIZE + SAFETY_MARGIN]; //0621char __oubuf[SMB_BUFFER_SIZE + SAFETY_MARGIN]; //Jesse char __inbuf[SMB_BUFFER_SIZE]; //Jesse char __oubuf[MAX_SEND_SIZE]; char __inbuf[SMB_BUFFER_SIZE + 16]; char __oubuf[MAX_SEND_SIZE + 16]; char *InBuffer = __inbuf; char *OutBuffer = __oubuf; int i, threadid=0; int testInbufsize=0, testOutbufsize=0; testInbufsize = sizeof(__inbuf); testOutbufsize = sizeof(__oubuf); // InBuffer += SMB_ALIGNMENT; // ??? why ??? 7/18/2001 by ron // OutBuffer += SMB_ALIGNMENT; /* re-initialise the timezone */ //0302 TimeInit(); for (i =0; i < NUM_SMBTHREAD; i++){ if (smbthread[i] == ProcSockID){ threadid =i; break; } } if (threadid >= NUM_SMBTHREAD) threadid = -1; thread_isused[threadid]++; //for debug while (True) { // int change_notify_timeout = 1 * 1000; int got_smb = False; //0705 int select_timeout = SMBD_SELECT_TIMEOUT*1000;//setup_select_timeout(); check_idle_conn(RELEASE_RESOURCE_TIMEOUT, threadid); // check Idle Connection ....Ron Add 3/8/2002 while(!receive_message_or_smb(InBuffer,SMB_BUFFER_SIZE, &got_smb ,ProcSockID ,threadid) || _forceclosethread[threadid] ==1) { if(!timeout_processing(SET_SMBD_TIMEOUT, threadid)){ conn_close_all(threadid); pipe_close_all(threadid); //7/19/2001 by ron reset_global_variables(threadid); //Jesse close_s(ProcSockID); //close socket 6/29/2001 by ron close(ProcSockID); //close socket cyg_thread_exit(); return; } //0418 num_smbs = 0; /* Reset smb counter. */ //os kwait(NULL); cyg_thread_yield(); } //while if (threadid < 0 ||ProcSockID < 0) { cyg_thread_exit(); return; } if(got_smb) { /* * Ensure we do timeout processing if the SMB we just got was * only an echo request. This allows us to set the select * timeout in 'receive_message_or_smb()' to any value we like * without worrying that the client will send echo requests * faster than the select timeout, thus starving out the * essential processing (change notify, blocking locks) that * the timeout code does. JRA. */ //0704 int num_echos = smb_echo_count; process_smb(InBuffer, OutBuffer, ProcSockID, threadid); } //if //os kwait(NULL); cyg_thread_yield(); } //while }