NetSim Source Code Help
Loading...
Searching...
No Matches
firewall.c File Reference
#include "main.h"
#include "List.h"
#include "../IP/IP.h"
#include "NetSim_utility.h"
#include "Firewall.h"
Include dependency graph for firewall.c:

Go to the source code of this file.

Data Structures

struct  stru_IP_ACL
 

Macros

#define _NETSIM_FIREWALL_CODE_
 
#define ACL_ALLOC()   (ptrACL)list_alloc(sizeof(NETSIM_ACL),offsetof(NETSIM_ACL,ele))
 
#define ACL_NEXT(acl)   acl=(ptrACL)LIST_NEXT(acl)
 
#define ACL_ADD(lacl, acl)   LIST_ADD_LAST((void**)lacl,acl)
 
#define ACL_GET(d)   ((ptrACL)(GET_IP_DEVVAR(d)->ACL))
 
#define ACL_SET(d, acl)   (GET_IP_DEVVAR(d)->ACL = (void*)acl)
 

Typedefs

typedef struct stru_IP_ACL NETSIM_ACL
 
typedef struct stru_IP_ACLptrACL
 

Functions

static ACL_ACTION action_from_str (char *s)
 
static NETSIM_IPAddress num_to_subnet (int num)
 
static int perfix_from_mask (NETSIM_IPAddress mask)
 
static void ip_from_str (char *s, NETSIM_IPAddress *ip, NETSIM_IPAddress *subnet)
 
static IP_PROTOCOL_NUMBER ipprotocol_from_str (char *pro)
 
static char * str_from_proto (IP_PROTOCOL_NUMBER num)
 
static ACL_TYPE type_from_str (char *str)
 
static bool check_mac_block (NETSIM_ID d, NETSIM_ID in)
 
void acl_add_new_line (NETSIM_ID d, char *s)
 
static NETSIM_IPAddress get_dest_ip (NetSim_PACKET *packet)
 
int fn_NetSim_FirewallConfig (NETSIM_ID nDeviceId)
 
static ACL_ACTION fn_NetSim_Firewall (NETSIM_ID nDeviceId, NETSIM_ID interfaceId, NetSim_PACKET *packet, ACL_TYPE type, bool isMAC)
 
ACL_ACTION fn_NetSim_MAC_Firewall (NETSIM_ID nDeviceId, NETSIM_ID interfaceId, NetSim_PACKET *packet, ACL_TYPE type)
 
ACL_ACTION fn_NetSim_NETWORK_Firewall (NETSIM_ID nDeviceId, NETSIM_ID interfaceId, NetSim_PACKET *packet, ACL_TYPE type)
 
void fn_NetSim_Firewall_Free (NETSIM_ID d)
 
char * acl_print (NETSIM_ID d)
 

Macro Definition Documentation

◆ _NETSIM_FIREWALL_CODE_

#define _NETSIM_FIREWALL_CODE_

Definition at line 15 of file firewall.c.

◆ ACL_ADD

#define ACL_ADD (   lacl,
  acl 
)    LIST_ADD_LAST((void**)lacl,acl)

Definition at line 42 of file firewall.c.

◆ ACL_ALLOC

#define ACL_ALLOC ( )    (ptrACL)list_alloc(sizeof(NETSIM_ACL),offsetof(NETSIM_ACL,ele))

Definition at line 40 of file firewall.c.

◆ ACL_GET

#define ACL_GET (   d)    ((ptrACL)(GET_IP_DEVVAR(d)->ACL))

Definition at line 43 of file firewall.c.

◆ ACL_NEXT

#define ACL_NEXT (   acl)    acl=(ptrACL)LIST_NEXT(acl)

Definition at line 41 of file firewall.c.

◆ ACL_SET

#define ACL_SET (   d,
  acl 
)    (GET_IP_DEVVAR(d)->ACL = (void*)acl)

Definition at line 44 of file firewall.c.

Typedef Documentation

◆ NETSIM_ACL

typedef struct stru_IP_ACL NETSIM_ACL

◆ ptrACL

typedef struct stru_IP_ACL* ptrACL

Function Documentation

◆ acl_add_new_line()

void acl_add_new_line ( NETSIM_ID  d,
char *  s 
)

Definition at line 185 of file firewall.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ acl_print()

char * acl_print ( NETSIM_ID  d)

Definition at line 346 of file firewall.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ action_from_str()

static ACL_ACTION action_from_str ( char *  s)
static

Definition at line 46 of file firewall.c.

Here is the caller graph for this function:

◆ check_mac_block()

static bool check_mac_block ( NETSIM_ID  d,
NETSIM_ID  in 
)
static

Definition at line 171 of file firewall.c.

Here is the caller graph for this function:

◆ fn_NetSim_Firewall()

static ACL_ACTION fn_NetSim_Firewall ( NETSIM_ID  nDeviceId,
NETSIM_ID  interfaceId,
NetSim_PACKET packet,
ACL_TYPE  type,
bool  isMAC 
)
static

This function is to check whether the particular packet is blocked or allowed by firewall

Definition at line 267 of file firewall.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fn_NetSim_Firewall_Free()

void fn_NetSim_Firewall_Free ( NETSIM_ID  d)

Definition at line 338 of file firewall.c.

Here is the caller graph for this function:

◆ fn_NetSim_FirewallConfig()

int fn_NetSim_FirewallConfig ( NETSIM_ID  nDeviceId)

This function is to configure the firewall.

Definition at line 235 of file firewall.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fn_NetSim_MAC_Firewall()

ACL_ACTION fn_NetSim_MAC_Firewall ( NETSIM_ID  nDeviceId,
NETSIM_ID  interfaceId,
NetSim_PACKET packet,
ACL_TYPE  type 
)

Definition at line 328 of file firewall.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fn_NetSim_NETWORK_Firewall()

ACL_ACTION fn_NetSim_NETWORK_Firewall ( NETSIM_ID  nDeviceId,
NETSIM_ID  interfaceId,
NetSim_PACKET packet,
ACL_TYPE  type 
)

Definition at line 333 of file firewall.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_dest_ip()

static NETSIM_IPAddress get_dest_ip ( NetSim_PACKET packet)
static

Definition at line 217 of file firewall.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ip_from_str()

static void ip_from_str ( char *  s,
NETSIM_IPAddress ip,
NETSIM_IPAddress subnet 
)
static

Definition at line 103 of file firewall.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ipprotocol_from_str()

static IP_PROTOCOL_NUMBER ipprotocol_from_str ( char *  pro)
static

Definition at line 129 of file firewall.c.

Here is the caller graph for this function:

◆ num_to_subnet()

static NETSIM_IPAddress num_to_subnet ( int  num)
static

Definition at line 57 of file firewall.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perfix_from_mask()

static int perfix_from_mask ( NETSIM_IPAddress  mask)
static

Definition at line 95 of file firewall.c.

Here is the caller graph for this function:

◆ str_from_proto()

static char * str_from_proto ( IP_PROTOCOL_NUMBER  num)
static

Definition at line 148 of file firewall.c.

Here is the caller graph for this function:

◆ type_from_str()

static ACL_TYPE type_from_str ( char *  str)
static

Definition at line 161 of file firewall.c.

Here is the caller graph for this function: