new set of cppcheck fixes
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
//#define MPLS
|
||||
|
||||
#ifdef MPLS
|
||||
#include <net/mpls.h>
|
||||
#include <net/mpls.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -46,12 +46,9 @@
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Add a new classifier rule (send direction)
|
||||
struct classifier_entity *nas_CLASS_add_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref)
|
||||
{
|
||||
struct classifier_entity *nas_CLASS_add_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) {
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *gc;
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_ADD_SCLASSIFIER: begin for dscp %d, classref %d\n", dscp,classref);
|
||||
#endif
|
||||
@@ -91,8 +88,7 @@ struct classifier_entity *nas_CLASS_add_sclassifier(struct cx_entity *cx, uint8_
|
||||
// Add a new classifier rule (receive direction)
|
||||
struct classifier_entity *nas_CLASS_add_rclassifier(uint8_t dscp,
|
||||
uint16_t classref,
|
||||
struct nas_priv *gpriv)
|
||||
{
|
||||
struct nas_priv *gpriv) {
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *gc;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
@@ -125,8 +121,7 @@ struct classifier_entity *nas_CLASS_add_rclassifier(uint8_t dscp,
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Add a new classifier rule (forwarding)
|
||||
struct classifier_entity *nas_CLASS_add_fclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref)
|
||||
{
|
||||
struct classifier_entity *nas_CLASS_add_fclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) {
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *gc;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
@@ -166,8 +161,7 @@ struct classifier_entity *nas_CLASS_add_fclassifier(struct cx_entity *cx, uint8_
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_CLASS_flush_sclassifier(struct cx_entity *cx)
|
||||
{
|
||||
void nas_CLASS_flush_sclassifier(struct cx_entity *cx) {
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t dscpi;
|
||||
struct classifier_entity *gc;
|
||||
@@ -196,8 +190,7 @@ void nas_CLASS_flush_sclassifier(struct cx_entity *cx)
|
||||
#endif
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_CLASS_flush_fclassifier(struct cx_entity *cx)
|
||||
{
|
||||
void nas_CLASS_flush_fclassifier(struct cx_entity *cx) {
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t dscpi;
|
||||
struct classifier_entity *gc;
|
||||
@@ -227,8 +220,7 @@ void nas_CLASS_flush_fclassifier(struct cx_entity *cx)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_CLASS_flush_rclassifier(struct nas_priv *gpriv)
|
||||
{
|
||||
void nas_CLASS_flush_rclassifier(struct nas_priv *gpriv) {
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t dscpi;
|
||||
struct classifier_entity *gc;
|
||||
@@ -251,8 +243,7 @@ void nas_CLASS_flush_rclassifier(struct nas_priv *gpriv)
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Delete a classifier rule (send direction)
|
||||
void nas_CLASS_del_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref)
|
||||
{
|
||||
void nas_CLASS_del_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) {
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *p,*np;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
@@ -295,8 +286,7 @@ void nas_CLASS_del_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t clas
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Delete a classifier rule (send direction)
|
||||
void nas_CLASS_del_fclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref)
|
||||
{
|
||||
void nas_CLASS_del_fclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) {
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *p,*np;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
@@ -339,8 +329,7 @@ void nas_CLASS_del_fclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t clas
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Delete a classifier rule (receive direction)
|
||||
void nas_CLASS_del_rclassifier(uint8_t dscp, uint16_t classref,struct nas_priv *gpriv)
|
||||
{
|
||||
void nas_CLASS_del_rclassifier(uint8_t dscp, uint16_t classref,struct nas_priv *gpriv) {
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *p,*np;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
@@ -379,8 +368,7 @@ struct cx_entity *nas_CLASS_cx6(struct sk_buff *skb,
|
||||
unsigned char dscp,
|
||||
struct nas_priv *gpriv,
|
||||
int inst,
|
||||
unsigned char *cx_searcher)
|
||||
{
|
||||
unsigned char *cx_searcher) {
|
||||
//---------------------------------------------------------------------------
|
||||
unsigned char cxi;
|
||||
unsigned int *addr,*dst=NULL;
|
||||
@@ -388,17 +376,12 @@ struct cx_entity *nas_CLASS_cx6(struct sk_buff *skb,
|
||||
struct classifier_entity *p=NULL;
|
||||
|
||||
if (skb!=NULL) {
|
||||
|
||||
for (cxi=*cx_searcher; cxi<NAS_CX_MAX; cxi++) {
|
||||
|
||||
(*cx_searcher)++;
|
||||
|
||||
p = gpriv->cx[cxi].sclassifier[dscp];
|
||||
|
||||
while (p!=NULL) {
|
||||
if (p->version == 6) { // verify that this is an IPv4 rule
|
||||
|
||||
|
||||
if ((addr = (unsigned int *)(&(p->daddr.ipv6)))== NULL) {
|
||||
printk("nas_CLASS_cx6: addr is null \n");
|
||||
p = p->next;
|
||||
@@ -409,9 +392,8 @@ struct cx_entity *nas_CLASS_cx6(struct sk_buff *skb,
|
||||
printk("cx %d : %X,%X.%X,%X\n",cxi,addr[0],addr[1],addr[2],addr[3]);
|
||||
#endif //NAS_DEBUG_CLASS
|
||||
|
||||
//if ((dst = (unsigned int*)&(((struct rt6_info *)skbdst)->rt6i_gateway)) == 0){
|
||||
if ( (dst = &((struct iphdr*)(skb_network_header(skb)))->daddr) == NULL) {
|
||||
|
||||
if ( (dst = &((struct iphdr *)(skb_network_header(skb)))->daddr) == NULL) {
|
||||
printk("nas_CLASS_cx6: dst addr is null \n");
|
||||
p = p->next;
|
||||
continue;
|
||||
@@ -446,11 +428,15 @@ struct cx_entity *nas_CLASS_cx6(struct sk_buff *skb,
|
||||
}
|
||||
}
|
||||
|
||||
printk("nas_CLASS_cx6 NOT FOUND: %X.%X.%X.%X\n",
|
||||
dst[0],
|
||||
dst[1],
|
||||
dst[2],
|
||||
dst[3]);
|
||||
|
||||
if (dst ) {
|
||||
printk("nas_CLASS_cx6 NOT FOUND: %X.%X.%X.%X\n",
|
||||
dst[0],
|
||||
dst[1],
|
||||
dst[2],
|
||||
dst[3]);
|
||||
}
|
||||
|
||||
return default_ip;
|
||||
}
|
||||
|
||||
@@ -460,8 +446,7 @@ struct cx_entity *nas_CLASS_cx4(struct sk_buff *skb,
|
||||
unsigned char dscp,
|
||||
struct nas_priv *gpriv,
|
||||
int inst,
|
||||
unsigned char *cx_searcher)
|
||||
{
|
||||
unsigned char *cx_searcher) {
|
||||
//---------------------------------------------------------------------------
|
||||
unsigned char cxi;
|
||||
unsigned char *addr;
|
||||
@@ -473,10 +458,9 @@ struct cx_entity *nas_CLASS_cx4(struct sk_buff *skb,
|
||||
// return(gpriv->cx); //dump to clusterhead
|
||||
|
||||
if (skb!=NULL) {
|
||||
daddr = ((struct iphdr*)(skb_network_header(skb)))->daddr;
|
||||
daddr = ((struct iphdr *)(skb_network_header(skb)))->daddr;
|
||||
|
||||
if (daddr!=0) {
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("[NAS][CLASS][IPv4] Searching for %d.%d.%d.%d\n",
|
||||
((unsigned char *)&daddr)[0],
|
||||
@@ -491,7 +475,6 @@ struct cx_entity *nas_CLASS_cx4(struct sk_buff *skb,
|
||||
|
||||
while (p!=NULL) {
|
||||
if (p->version == 4) { // verify that this is an IPv4 rule
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
addr = (char *)(&(p->daddr.ipv4));
|
||||
printk("found classifier cx %d for destination: %d.%d.%d.%d\n",cxi,addr[0],addr[1],addr[2],addr[3]);
|
||||
@@ -536,32 +519,23 @@ struct cx_entity *nas_CLASS_MPLS(struct sk_buff *skb,
|
||||
unsigned char exp,
|
||||
struct nas_priv *gpriv,
|
||||
int inst,
|
||||
unsigned char *cx_searcher)
|
||||
{
|
||||
unsigned char *cx_searcher) {
|
||||
//---------------------------------------------------------------------------
|
||||
unsigned char cxi;
|
||||
|
||||
struct cx_entity *default_label=NULL;
|
||||
struct classifier_entity *p=NULL;
|
||||
|
||||
// if (inst >0)
|
||||
// return(gpriv->cx); //dump to clusterhead
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
|
||||
|
||||
printk("[NAS][CLASS][MPLS] Searching for label %d\n",MPLSCB(skb)->label);
|
||||
#endif
|
||||
|
||||
for (cxi=*cx_searcher; cxi<NAS_CX_MAX; ++cxi) {
|
||||
|
||||
(*cx_searcher)++;
|
||||
p = gpriv->cx[cxi].sclassifier[exp];
|
||||
|
||||
while (p!=NULL) {
|
||||
if (p->version == NAS_MPLS_VERSION_CODE) { // verify that this is an MPLS rule
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("cx %d : label %d\n",cxi,p->daddr.mpls_label);
|
||||
#endif //NAS_DEBUG_CLASS
|
||||
@@ -588,11 +562,8 @@ struct cx_entity *nas_CLASS_MPLS(struct sk_buff *skb,
|
||||
// goto to next classification rule for the connection
|
||||
p = p->next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return default_label;
|
||||
}
|
||||
|
||||
@@ -600,8 +571,7 @@ struct cx_entity *nas_CLASS_MPLS(struct sk_buff *skb,
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Search the sending function
|
||||
void nas_CLASS_send(struct sk_buff *skb,int inst)
|
||||
{
|
||||
void nas_CLASS_send(struct sk_buff *skb,int inst) {
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *p, *sp;
|
||||
uint8_t *protocolh,version;
|
||||
@@ -609,15 +579,10 @@ void nas_CLASS_send(struct sk_buff *skb,int inst)
|
||||
uint16_t classref;
|
||||
struct cx_entity *cx;
|
||||
//unsigned int i;
|
||||
|
||||
//unsigned int router_adv = 0;
|
||||
struct net_device *dev=nasdev[inst];
|
||||
|
||||
struct nas_priv *gpriv=netdev_priv(dev);
|
||||
|
||||
unsigned char cx_searcher,no_connection=1;
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: begin - inst %d\n",inst);
|
||||
#endif
|
||||
@@ -629,9 +594,7 @@ void nas_CLASS_send(struct sk_buff *skb,int inst)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_SEND
|
||||
|
||||
printk("[NAS][CLASS][SEND] Got packet from kernel:\n");
|
||||
|
||||
for (i=0; i<256; i++)
|
||||
@@ -641,80 +604,65 @@ void nas_CLASS_send(struct sk_buff *skb,int inst)
|
||||
#endif
|
||||
// find all connections related to socket
|
||||
cx_searcher = 0;
|
||||
|
||||
no_connection = 1;
|
||||
|
||||
//while (cx_searcher<NAS_CX_MAX) {
|
||||
|
||||
cx = NULL;
|
||||
|
||||
// Address classification
|
||||
switch (ntohs(skb->protocol)) {
|
||||
case ETH_P_IPV6:
|
||||
version = 6;
|
||||
|
||||
protocolh=nas_TOOL_get_protocol6(
|
||||
(struct ipv6hdr *)(skb_network_header(skb)),
|
||||
&protocol);
|
||||
dscp=nas_TOOL_get_dscp6(
|
||||
(struct ipv6hdr *)(skb_network_header(skb))
|
||||
);
|
||||
case ETH_P_IPV6:
|
||||
version = 6;
|
||||
protocolh=nas_TOOL_get_protocol6(
|
||||
(struct ipv6hdr *)(skb_network_header(skb)),
|
||||
&protocol);
|
||||
dscp=nas_TOOL_get_dscp6(
|
||||
(struct ipv6hdr *)(skb_network_header(skb))
|
||||
);
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: %p %d %p %d %p \n",skb, dscp, gpriv, inst, &cx_searcher);
|
||||
printk("NAS_CLASS_SEND: %p %d %p %d %p \n",skb, dscp, gpriv, inst, &cx_searcher);
|
||||
#endif
|
||||
cx=nas_CLASS_cx6(skb,dscp,gpriv,inst,&cx_searcher);
|
||||
|
||||
|
||||
cx=nas_CLASS_cx6(skb,dscp,gpriv,inst,&cx_searcher);
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: Got IPv6 packet, dscp = %d\n",dscp);
|
||||
printk("NAS_CLASS_SEND: Got IPv6 packet, dscp = %d\n",dscp);
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
|
||||
case ETH_P_IP:
|
||||
|
||||
|
||||
dscp=nas_TOOL_get_dscp4((struct iphdr *)(skb_network_header(skb)));
|
||||
cx=nas_CLASS_cx4(skb,dscp,gpriv,inst,&cx_searcher);
|
||||
protocolh=nas_TOOL_get_protocol4(
|
||||
(struct iphdr *)(skb_network_header(skb)),
|
||||
&protocol);
|
||||
case ETH_P_IP:
|
||||
dscp=nas_TOOL_get_dscp4((struct iphdr *)(skb_network_header(skb)));
|
||||
cx=nas_CLASS_cx4(skb,dscp,gpriv,inst,&cx_searcher);
|
||||
protocolh=nas_TOOL_get_protocol4(
|
||||
(struct iphdr *)(skb_network_header(skb)),
|
||||
&protocol);
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: Got IPv4 packet (%x), dscp = %d, cx = %x\n",ntohs(skb->protocol),dscp,cx);
|
||||
printk("NAS_CLASS_SEND: Got IPv4 packet (%x), dscp = %d, cx = %x\n",ntohs(skb->protocol),dscp,cx);
|
||||
#endif
|
||||
version = 4;
|
||||
|
||||
break;
|
||||
version = 4;
|
||||
break;
|
||||
#ifdef MPLS
|
||||
|
||||
case ETH_P_MPLS_UC:
|
||||
cx=nas_CLASS_MPLS(skb,MPLSCB(skb)->exp,gpriv,inst,&cx_searcher);
|
||||
|
||||
case ETH_P_MPLS_UC:
|
||||
cx=nas_CLASS_MPLS(skb,MPLSCB(skb)->exp,gpriv,inst,&cx_searcher);
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: Got MPLS unicast packet, exp = %d, label = %d, cx = %x\n",MPLSCB(skb)->exp,MPLSCB(skb)->label,cx);
|
||||
printk("NAS_CLASS_SEND: Got MPLS unicast packet, exp = %d, label = %d, cx = %x\n",MPLSCB(skb)->exp,MPLSCB(skb)->label,cx);
|
||||
#endif
|
||||
dscp = MPLSCB(skb)->exp;
|
||||
version = NAS_MPLS_VERSION_CODE;
|
||||
protocol = version;
|
||||
break;
|
||||
#endif
|
||||
|
||||
dscp = MPLSCB(skb)->exp;
|
||||
version = NAS_MPLS_VERSION_CODE;
|
||||
protocol = version;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
printk("NAS_CLASS_SEND: Unknown protocol\n");
|
||||
version = 0;
|
||||
return;
|
||||
default:
|
||||
printk("NAS_CLASS_SEND: Unknown protocol\n");
|
||||
version = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// If a valid connection for the DSCP/EXP with destination address
|
||||
// is found scan all protocol-based classification rules
|
||||
|
||||
if (cx) {
|
||||
|
||||
classref=0;
|
||||
sp=NULL;
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("[NAS][CLASSIFIER] DSCP/EXP %d : looking for classifier entry\n",dscp);
|
||||
#endif
|
||||
@@ -738,12 +686,10 @@ void nas_CLASS_send(struct sk_buff *skb,int inst)
|
||||
classref=sp->classref;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (sp!=NULL) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
|
||||
char sfct[10], sprotocol[10];
|
||||
|
||||
if (sp->fct==nas_COMMON_QOS_send)
|
||||
@@ -759,41 +705,38 @@ void nas_CLASS_send(struct sk_buff *skb,int inst)
|
||||
strcpy(sfct, "dc");
|
||||
|
||||
switch(protocol) {
|
||||
case NAS_PROTOCOL_UDP:
|
||||
strcpy(sprotocol, "udp");
|
||||
printk("udp packet\n");
|
||||
break;
|
||||
case NAS_PROTOCOL_UDP:
|
||||
strcpy(sprotocol, "udp");
|
||||
printk("udp packet\n");
|
||||
break;
|
||||
|
||||
case NAS_PROTOCOL_TCP:
|
||||
strcpy(sprotocol, "tcp");
|
||||
printk("tcp packet\n");
|
||||
break;
|
||||
case NAS_PROTOCOL_TCP:
|
||||
strcpy(sprotocol, "tcp");
|
||||
printk("tcp packet\n");
|
||||
break;
|
||||
|
||||
case NAS_PROTOCOL_ICMP4:
|
||||
strcpy(sprotocol, "icmp4");
|
||||
printk("icmp4 packet\n");
|
||||
break;
|
||||
case NAS_PROTOCOL_ICMP4:
|
||||
strcpy(sprotocol, "icmp4");
|
||||
printk("icmp4 packet\n");
|
||||
break;
|
||||
|
||||
case NAS_PROTOCOL_ICMP6:
|
||||
strcpy(sprotocol, "icmp6");
|
||||
print_TOOL_pk_icmp6((struct icmp6hdr*)protocolh);
|
||||
break;
|
||||
case NAS_PROTOCOL_ICMP6:
|
||||
strcpy(sprotocol, "icmp6");
|
||||
print_TOOL_pk_icmp6((struct icmp6hdr *)protocolh);
|
||||
break;
|
||||
#ifdef MPLS
|
||||
|
||||
case NAS_MPLS_VERSION_CODE:
|
||||
strcpy(sprotocol,"mpls");
|
||||
break;
|
||||
case NAS_MPLS_VERSION_CODE:
|
||||
strcpy(sprotocol,"mpls");
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
printk("NAS_CLASS_SEND: (dscp %u, %s) received, (classref %u, fct %s, rab_id %u) classifier rule\n",
|
||||
dscp, sprotocol, sp->classref, sfct, sp->rab_id);
|
||||
#endif
|
||||
|
||||
sp->fct(skb, cx, sp,inst, NULL);
|
||||
|
||||
} // if classifier entry match found
|
||||
|
||||
else {
|
||||
printk("NAS_CLASS_SEND: no corresponding item in the classifier, so the message is dropped\n");
|
||||
// nas_COMMON_del_send(skb, cx, NULL,inst);
|
||||
@@ -802,20 +745,14 @@ void nas_CLASS_send(struct sk_buff *skb,int inst)
|
||||
no_connection = 0;
|
||||
} // if connection found
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
|
||||
if (no_connection == 1)
|
||||
printk("NAS_CLASS_SEND: no corresponding connection, so the message is dropped\n");
|
||||
|
||||
#endif /* NAS_DEBUG_CLASS */
|
||||
|
||||
|
||||
// } // while loop over connections
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: end\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user