Logo 
Search:

Networking Articles

Submit Article
Home » Articles » Networking » TCP/IPRSS Feeds

TCP/IP program of finite State Machine initializer

Posted By: Milind Mishra     Category: Networking     Views: 2918

TCP/IP program of finite State Machine initializer.

Code for TCP/IP program of finite State Machine initializer in Networking

#include <sys/types.h>
#include <stdio.h>
#include "tnfsm.h"#define    TINVALID    0xff    /* an invalid transition index        */int
fsminit(u_char fsm[][NCHRS], struct fsm_trans ttab[], int nstates)
{
    struct fsm_trans    *pt;
    int            sn, ti, cn;

    for (cn=0; cn<NCHRS; ++cn)
        for (ti=0; ti<nstates; ++ti)
            fsm[ti][cn] = TINVALID;

    for (ti=0; ttab[ti].ft_state != FSINVALID; ++ti) {
        pt = &ttab[ti];
        sn = pt->ft_state;
        if (pt->ft_char == TCANY) {
            for (cn=0; cn<NCHRS; ++cn)
                if (fsm[sn][cn] == TINVALID)
                    fsm[sn][cn] = ti;
        } else
            fsm[sn][pt->ft_char] = ti;
    }
    /* set all uninitialized indices to an invalid transition    */for (cn=0; cn<NCHRS; ++cn)
        for (ti=0; ti<nstates; ++ti)
            if (fsm[ti][cn] == TINVALID)
                fsm[ti][cn] = ti;
}
  
Share: 


Didn't find what you were looking for? Find more on TCP/IP program of finite State Machine initializer Or get search suggestion and latest updates.

Milind Mishra
Milind Mishra author of TCP/IP program of finite State Machine initializer is from India.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!