Commit 905e3e8e authored by Jan Engelhardt's avatar Jan Engelhardt Committed by David S. Miller

[NETFILTER]: nf_conntrack_h323: constify and annotate H.323 helper

Constify data tables (predominantly in nf_conntrack_h323_types.c, but
also a few in nf_conntrack_h323_asn1.c) and use const qualifiers on
variables where possible in the h323 sources.
Signed-off-by: default avatarJan Engelhardt <jengelh@computergmbh.de>
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3cb609d5
...@@ -32,7 +32,8 @@ static int set_addr(struct sk_buff *skb, ...@@ -32,7 +32,8 @@ static int set_addr(struct sk_buff *skb,
__be32 ip; __be32 ip;
__be16 port; __be16 port;
} __attribute__ ((__packed__)) buf; } __attribute__ ((__packed__)) buf;
struct tcphdr _tcph, *th; const struct tcphdr *th;
struct tcphdr _tcph;
buf.ip = ip; buf.ip = ip;
buf.port = port; buf.port = port;
...@@ -99,7 +100,7 @@ static int set_sig_addr(struct sk_buff *skb, struct nf_conn *ct, ...@@ -99,7 +100,7 @@ static int set_sig_addr(struct sk_buff *skb, struct nf_conn *ct,
unsigned char **data, unsigned char **data,
TransportAddress *taddr, int count) TransportAddress *taddr, int count)
{ {
struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info; const struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
int dir = CTINFO2DIR(ctinfo); int dir = CTINFO2DIR(ctinfo);
int i; int i;
__be16 port; __be16 port;
......
...@@ -87,7 +87,7 @@ typedef struct field_t { ...@@ -87,7 +87,7 @@ typedef struct field_t {
unsigned char ub; unsigned char ub;
unsigned short attr; unsigned short attr;
unsigned short offset; unsigned short offset;
struct field_t *fields; const struct field_t *fields;
} field_t; } field_t;
/* Bit Stream */ /* Bit Stream */
...@@ -111,21 +111,21 @@ static unsigned int get_bitmap(bitstr_t *bs, unsigned int b); ...@@ -111,21 +111,21 @@ static unsigned int get_bitmap(bitstr_t *bs, unsigned int b);
static unsigned int get_uint(bitstr_t *bs, int b); static unsigned int get_uint(bitstr_t *bs, int b);
/* Decoder Functions */ /* Decoder Functions */
static int decode_nul(bitstr_t *bs, field_t *f, char *base, int level); static int decode_nul(bitstr_t *bs, const struct field_t *f, char *base, int level);
static int decode_bool(bitstr_t *bs, field_t *f, char *base, int level); static int decode_bool(bitstr_t *bs, const struct field_t *f, char *base, int level);
static int decode_oid(bitstr_t *bs, field_t *f, char *base, int level); static int decode_oid(bitstr_t *bs, const struct field_t *f, char *base, int level);
static int decode_int(bitstr_t *bs, field_t *f, char *base, int level); static int decode_int(bitstr_t *bs, const struct field_t *f, char *base, int level);
static int decode_enum(bitstr_t *bs, field_t *f, char *base, int level); static int decode_enum(bitstr_t *bs, const struct field_t *f, char *base, int level);
static int decode_bitstr(bitstr_t *bs, field_t *f, char *base, int level); static int decode_bitstr(bitstr_t *bs, const struct field_t *f, char *base, int level);
static int decode_numstr(bitstr_t *bs, field_t *f, char *base, int level); static int decode_numstr(bitstr_t *bs, const struct field_t *f, char *base, int level);
static int decode_octstr(bitstr_t *bs, field_t *f, char *base, int level); static int decode_octstr(bitstr_t *bs, const struct field_t *f, char *base, int level);
static int decode_bmpstr(bitstr_t *bs, field_t *f, char *base, int level); static int decode_bmpstr(bitstr_t *bs, const struct field_t *f, char *base, int level);
static int decode_seq(bitstr_t *bs, field_t *f, char *base, int level); static int decode_seq(bitstr_t *bs, const struct field_t *f, char *base, int level);
static int decode_seqof(bitstr_t *bs, field_t *f, char *base, int level); static int decode_seqof(bitstr_t *bs, const struct field_t *f, char *base, int level);
static int decode_choice(bitstr_t *bs, field_t *f, char *base, int level); static int decode_choice(bitstr_t *bs, const struct field_t *f, char *base, int level);
/* Decoder Functions Vector */ /* Decoder Functions Vector */
typedef int (*decoder_t)(bitstr_t *, field_t *, char *, int); typedef int (*decoder_t)(bitstr_t *, const struct field_t *, char *, int);
static const decoder_t Decoders[] = { static const decoder_t Decoders[] = {
decode_nul, decode_nul,
decode_bool, decode_bool,
...@@ -264,7 +264,8 @@ static unsigned int get_uint(bitstr_t *bs, int b) ...@@ -264,7 +264,8 @@ static unsigned int get_uint(bitstr_t *bs, int b)
} }
/****************************************************************************/ /****************************************************************************/
static int decode_nul(bitstr_t *bs, field_t *f, char *base, int level) static int decode_nul(bitstr_t *bs, const struct field_t *f,
char *base, int level)
{ {
PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name); PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
...@@ -272,7 +273,8 @@ static int decode_nul(bitstr_t *bs, field_t *f, char *base, int level) ...@@ -272,7 +273,8 @@ static int decode_nul(bitstr_t *bs, field_t *f, char *base, int level)
} }
/****************************************************************************/ /****************************************************************************/
static int decode_bool(bitstr_t *bs, field_t *f, char *base, int level) static int decode_bool(bitstr_t *bs, const struct field_t *f,
char *base, int level)
{ {
PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name); PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
...@@ -283,7 +285,8 @@ static int decode_bool(bitstr_t *bs, field_t *f, char *base, int level) ...@@ -283,7 +285,8 @@ static int decode_bool(bitstr_t *bs, field_t *f, char *base, int level)
} }
/****************************************************************************/ /****************************************************************************/
static int decode_oid(bitstr_t *bs, field_t *f, char *base, int level) static int decode_oid(bitstr_t *bs, const struct field_t *f,
char *base, int level)
{ {
int len; int len;
...@@ -299,7 +302,8 @@ static int decode_oid(bitstr_t *bs, field_t *f, char *base, int level) ...@@ -299,7 +302,8 @@ static int decode_oid(bitstr_t *bs, field_t *f, char *base, int level)
} }
/****************************************************************************/ /****************************************************************************/
static int decode_int(bitstr_t *bs, field_t *f, char *base, int level) static int decode_int(bitstr_t *bs, const struct field_t *f,
char *base, int level)
{ {
unsigned int len; unsigned int len;
...@@ -342,7 +346,8 @@ static int decode_int(bitstr_t *bs, field_t *f, char *base, int level) ...@@ -342,7 +346,8 @@ static int decode_int(bitstr_t *bs, field_t *f, char *base, int level)
} }
/****************************************************************************/ /****************************************************************************/
static int decode_enum(bitstr_t *bs, field_t *f, char *base, int level) static int decode_enum(bitstr_t *bs, const struct field_t *f,
char *base, int level)
{ {
PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name); PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
...@@ -357,7 +362,8 @@ static int decode_enum(bitstr_t *bs, field_t *f, char *base, int level) ...@@ -357,7 +362,8 @@ static int decode_enum(bitstr_t *bs, field_t *f, char *base, int level)
} }
/****************************************************************************/ /****************************************************************************/
static int decode_bitstr(bitstr_t *bs, field_t *f, char *base, int level) static int decode_bitstr(bitstr_t *bs, const struct field_t *f,
char *base, int level)
{ {
unsigned int len; unsigned int len;
...@@ -390,7 +396,8 @@ static int decode_bitstr(bitstr_t *bs, field_t *f, char *base, int level) ...@@ -390,7 +396,8 @@ static int decode_bitstr(bitstr_t *bs, field_t *f, char *base, int level)
} }
/****************************************************************************/ /****************************************************************************/
static int decode_numstr(bitstr_t *bs, field_t *f, char *base, int level) static int decode_numstr(bitstr_t *bs, const struct field_t *f,
char *base, int level)
{ {
unsigned int len; unsigned int len;
...@@ -407,7 +414,8 @@ static int decode_numstr(bitstr_t *bs, field_t *f, char *base, int level) ...@@ -407,7 +414,8 @@ static int decode_numstr(bitstr_t *bs, field_t *f, char *base, int level)
} }
/****************************************************************************/ /****************************************************************************/
static int decode_octstr(bitstr_t *bs, field_t *f, char *base, int level) static int decode_octstr(bitstr_t *bs, const struct field_t *f,
char *base, int level)
{ {
unsigned int len; unsigned int len;
...@@ -455,7 +463,8 @@ static int decode_octstr(bitstr_t *bs, field_t *f, char *base, int level) ...@@ -455,7 +463,8 @@ static int decode_octstr(bitstr_t *bs, field_t *f, char *base, int level)
} }
/****************************************************************************/ /****************************************************************************/
static int decode_bmpstr(bitstr_t *bs, field_t *f, char *base, int level) static int decode_bmpstr(bitstr_t *bs, const struct field_t *f,
char *base, int level)
{ {
unsigned int len; unsigned int len;
...@@ -480,11 +489,12 @@ static int decode_bmpstr(bitstr_t *bs, field_t *f, char *base, int level) ...@@ -480,11 +489,12 @@ static int decode_bmpstr(bitstr_t *bs, field_t *f, char *base, int level)
} }
/****************************************************************************/ /****************************************************************************/
static int decode_seq(bitstr_t *bs, field_t *f, char *base, int level) static int decode_seq(bitstr_t *bs, const struct field_t *f,
char *base, int level)
{ {
unsigned int ext, bmp, i, opt, len = 0, bmp2, bmp2_len; unsigned int ext, bmp, i, opt, len = 0, bmp2, bmp2_len;
int err; int err;
field_t *son; const struct field_t *son;
unsigned char *beg = NULL; unsigned char *beg = NULL;
PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name); PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
...@@ -596,11 +606,12 @@ static int decode_seq(bitstr_t *bs, field_t *f, char *base, int level) ...@@ -596,11 +606,12 @@ static int decode_seq(bitstr_t *bs, field_t *f, char *base, int level)
} }
/****************************************************************************/ /****************************************************************************/
static int decode_seqof(bitstr_t *bs, field_t *f, char *base, int level) static int decode_seqof(bitstr_t *bs, const struct field_t *f,
char *base, int level)
{ {
unsigned int count, effective_count = 0, i, len = 0; unsigned int count, effective_count = 0, i, len = 0;
int err; int err;
field_t *son; const struct field_t *son;
unsigned char *beg = NULL; unsigned char *beg = NULL;
PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name); PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
...@@ -685,11 +696,12 @@ static int decode_seqof(bitstr_t *bs, field_t *f, char *base, int level) ...@@ -685,11 +696,12 @@ static int decode_seqof(bitstr_t *bs, field_t *f, char *base, int level)
/****************************************************************************/ /****************************************************************************/
static int decode_choice(bitstr_t *bs, field_t *f, char *base, int level) static int decode_choice(bitstr_t *bs, const struct field_t *f,
char *base, int level)
{ {
unsigned int type, ext, len = 0; unsigned int type, ext, len = 0;
int err; int err;
field_t *son; const struct field_t *son;
unsigned char *beg = NULL; unsigned char *beg = NULL;
PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name); PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
...@@ -756,7 +768,7 @@ static int decode_choice(bitstr_t *bs, field_t *f, char *base, int level) ...@@ -756,7 +768,7 @@ static int decode_choice(bitstr_t *bs, field_t *f, char *base, int level)
/****************************************************************************/ /****************************************************************************/
int DecodeRasMessage(unsigned char *buf, size_t sz, RasMessage *ras) int DecodeRasMessage(unsigned char *buf, size_t sz, RasMessage *ras)
{ {
static field_t ras_message = { static const struct field_t ras_message = {
FNAME("RasMessage") CHOICE, 5, 24, 32, DECODE | EXT, FNAME("RasMessage") CHOICE, 5, 24, 32, DECODE | EXT,
0, _RasMessage 0, _RasMessage
}; };
...@@ -773,7 +785,7 @@ int DecodeRasMessage(unsigned char *buf, size_t sz, RasMessage *ras) ...@@ -773,7 +785,7 @@ int DecodeRasMessage(unsigned char *buf, size_t sz, RasMessage *ras)
static int DecodeH323_UserInformation(unsigned char *buf, unsigned char *beg, static int DecodeH323_UserInformation(unsigned char *buf, unsigned char *beg,
size_t sz, H323_UserInformation *uuie) size_t sz, H323_UserInformation *uuie)
{ {
static field_t h323_userinformation = { static const struct field_t h323_userinformation = {
FNAME("H323-UserInformation") SEQ, 1, 2, 2, DECODE | EXT, FNAME("H323-UserInformation") SEQ, 1, 2, 2, DECODE | EXT,
0, _H323_UserInformation 0, _H323_UserInformation
}; };
...@@ -792,7 +804,7 @@ int DecodeMultimediaSystemControlMessage(unsigned char *buf, size_t sz, ...@@ -792,7 +804,7 @@ int DecodeMultimediaSystemControlMessage(unsigned char *buf, size_t sz,
MultimediaSystemControlMessage * MultimediaSystemControlMessage *
mscm) mscm)
{ {
static field_t multimediasystemcontrolmessage = { static const struct field_t multimediasystemcontrolmessage = {
FNAME("MultimediaSystemControlMessage") CHOICE, 2, 4, 4, FNAME("MultimediaSystemControlMessage") CHOICE, 2, 4, 4,
DECODE | EXT, 0, _MultimediaSystemControlMessage DECODE | EXT, 0, _MultimediaSystemControlMessage
}; };
......
...@@ -114,7 +114,8 @@ static int get_tpkt_data(struct sk_buff *skb, unsigned int protoff, ...@@ -114,7 +114,8 @@ static int get_tpkt_data(struct sk_buff *skb, unsigned int protoff,
{ {
struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info; struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
int dir = CTINFO2DIR(ctinfo); int dir = CTINFO2DIR(ctinfo);
struct tcphdr _tcph, *th; const struct tcphdr *th;
struct tcphdr _tcph;
int tcpdatalen; int tcpdatalen;
int tcpdataoff; int tcpdataoff;
unsigned char *tpkt; unsigned char *tpkt;
...@@ -212,11 +213,11 @@ static int get_tpkt_data(struct sk_buff *skb, unsigned int protoff, ...@@ -212,11 +213,11 @@ static int get_tpkt_data(struct sk_buff *skb, unsigned int protoff,
} }
/****************************************************************************/ /****************************************************************************/
static int get_h245_addr(struct nf_conn *ct, unsigned char *data, static int get_h245_addr(struct nf_conn *ct, const unsigned char *data,
H245_TransportAddress *taddr, H245_TransportAddress *taddr,
union nf_inet_addr *addr, __be16 *port) union nf_inet_addr *addr, __be16 *port)
{ {
unsigned char *p; const unsigned char *p;
int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num; int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
int len; int len;
...@@ -625,7 +626,7 @@ int get_h225_addr(struct nf_conn *ct, unsigned char *data, ...@@ -625,7 +626,7 @@ int get_h225_addr(struct nf_conn *ct, unsigned char *data,
TransportAddress *taddr, TransportAddress *taddr,
union nf_inet_addr *addr, __be16 *port) union nf_inet_addr *addr, __be16 *port)
{ {
unsigned char *p; const unsigned char *p;
int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num; int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
int len; int len;
...@@ -704,9 +705,8 @@ static int expect_h245(struct sk_buff *skb, struct nf_conn *ct, ...@@ -704,9 +705,8 @@ static int expect_h245(struct sk_buff *skb, struct nf_conn *ct,
/* If the calling party is on the same side of the forward-to party, /* If the calling party is on the same side of the forward-to party,
* we don't need to track the second call */ * we don't need to track the second call */
static int callforward_do_filter(union nf_inet_addr *src, static int callforward_do_filter(const union nf_inet_addr *src,
union nf_inet_addr *dst, const union nf_inet_addr *dst, int family)
int family)
{ {
const struct nf_afinfo *afinfo; const struct nf_afinfo *afinfo;
struct flowi fl1, fl2; struct flowi fl1, fl2;
...@@ -1185,7 +1185,8 @@ static struct nf_conntrack_helper nf_conntrack_helper_q931[] __read_mostly = { ...@@ -1185,7 +1185,8 @@ static struct nf_conntrack_helper nf_conntrack_helper_q931[] __read_mostly = {
static unsigned char *get_udp_data(struct sk_buff *skb, unsigned int protoff, static unsigned char *get_udp_data(struct sk_buff *skb, unsigned int protoff,
int *datalen) int *datalen)
{ {
struct udphdr _uh, *uh; const struct udphdr *uh;
struct udphdr _uh;
int dataoff; int dataoff;
uh = skb_header_pointer(skb, protoff, sizeof(_uh), &_uh); uh = skb_header_pointer(skb, protoff, sizeof(_uh), &_uh);
...@@ -1468,7 +1469,7 @@ static int process_arq(struct sk_buff *skb, struct nf_conn *ct, ...@@ -1468,7 +1469,7 @@ static int process_arq(struct sk_buff *skb, struct nf_conn *ct,
enum ip_conntrack_info ctinfo, enum ip_conntrack_info ctinfo,
unsigned char **data, AdmissionRequest *arq) unsigned char **data, AdmissionRequest *arq)
{ {
struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info; const struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
int dir = CTINFO2DIR(ctinfo); int dir = CTINFO2DIR(ctinfo);
__be16 port; __be16 port;
union nf_inet_addr addr; union nf_inet_addr addr;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment