global: constify things
const everything, that should be const. Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
This commit is contained in:
parent
52c4940523
commit
d05923d2b1
|
@ -50,7 +50,7 @@ int dnsc_use_edns0 = 1;
|
||||||
#define CHECKLEN(x) if (buflen < (x) + (unsigned)(p-buf)) return 0
|
#define CHECKLEN(x) if (buflen < (x) + (unsigned)(p-buf)) return 0
|
||||||
|
|
||||||
int
|
int
|
||||||
dns_encode(char *buf, size_t buflen, struct query *q, qr_t qr, char *data, size_t datalen)
|
dns_encode(char *buf, size_t buflen, struct query *q, qr_t qr, const char *data, size_t datalen)
|
||||||
{
|
{
|
||||||
HEADER *header;
|
HEADER *header;
|
||||||
short name;
|
short name;
|
||||||
|
@ -120,7 +120,7 @@ dns_encode(char *buf, size_t buflen, struct query *q, qr_t qr, char *data, size_
|
||||||
For SRV, see RFC2782.
|
For SRV, see RFC2782.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *mxdata = data;
|
const char *mxdata = data;
|
||||||
char *startp;
|
char *startp;
|
||||||
int namelen;
|
int namelen;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ typedef enum {
|
||||||
|
|
||||||
extern int dnsc_use_edns0;
|
extern int dnsc_use_edns0;
|
||||||
|
|
||||||
int dns_encode(char *, size_t, struct query *, qr_t, char *, size_t);
|
int dns_encode(char *, size_t, struct query *, qr_t, const char *, size_t);
|
||||||
int dns_encode_ns_response(char *buf, size_t buflen, struct query *q, char *topdomain);
|
int dns_encode_ns_response(char *buf, size_t buflen, struct query *q, char *topdomain);
|
||||||
int dns_encode_a_response(char *buf, size_t buflen, struct query *q);
|
int dns_encode_a_response(char *buf, size_t buflen, struct query *q);
|
||||||
unsigned short dns_get_id(char *packet, size_t packetlen);
|
unsigned short dns_get_id(char *packet, size_t packetlen);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
int
|
int
|
||||||
build_hostname(char *buf, size_t buflen,
|
build_hostname(char *buf, size_t buflen,
|
||||||
const char *data, const size_t datalen,
|
const char *data, const size_t datalen,
|
||||||
const char *topdomain, struct encoder *encoder, int maxlen)
|
const char *topdomain, const struct encoder *encoder, int maxlen)
|
||||||
{
|
{
|
||||||
size_t space;
|
size_t space;
|
||||||
char *b;
|
char *b;
|
||||||
|
@ -56,7 +56,7 @@ build_hostname(char *buf, size_t buflen,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
unpack_data(char *buf, size_t buflen, char *data, size_t datalen, struct encoder *enc)
|
unpack_data(char *buf, size_t buflen, char *data, size_t datalen, const struct encoder *enc)
|
||||||
{
|
{
|
||||||
if (!enc->eats_dots())
|
if (!enc->eats_dots())
|
||||||
datalen = inline_undotify(data, datalen);
|
datalen = inline_undotify(data, datalen);
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#define DOWNCODECCHECK1_LEN 48
|
#define DOWNCODECCHECK1_LEN 48
|
||||||
|
|
||||||
struct encoder {
|
struct encoder {
|
||||||
char name[8];
|
const char name[8];
|
||||||
int (*encode) (char *, size_t *, const void *, size_t);
|
int (*encode) (char *, size_t *, const void *, size_t);
|
||||||
int (*decode) (void *, size_t *, const char *, size_t);
|
int (*decode) (void *, size_t *, const char *, size_t);
|
||||||
int (*places_dots) (void);
|
int (*places_dots) (void);
|
||||||
|
@ -35,10 +35,9 @@ struct encoder {
|
||||||
int (*blocksize_encoded)(void);
|
int (*blocksize_encoded)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
int build_hostname(char *, size_t, const char *, const size_t, const char *, struct encoder *, int);
|
int build_hostname(char *, size_t, const char *, const size_t, const char *, const struct encoder *, int);
|
||||||
int unpack_data(char *, size_t, char *, size_t, struct encoder *);
|
int unpack_data(char *, size_t, char *, size_t, const struct encoder *);
|
||||||
int inline_dotify(char *, size_t);
|
int inline_dotify(char *, size_t);
|
||||||
int inline_undotify(char *, size_t);
|
int inline_undotify(char *, size_t);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _ENCODING_H_ */
|
#endif /* _ENCODING_H_ */
|
||||||
|
|
|
@ -119,7 +119,7 @@ struct dnsfd {
|
||||||
};
|
};
|
||||||
|
|
||||||
static int read_dns(int fd, struct dnsfd *dns_fds, int tun_fd, struct query *q);
|
static int read_dns(int fd, struct dnsfd *dns_fds, int tun_fd, struct query *q);
|
||||||
static void write_dns(int fd, struct query *q, char *data, int datalen, char downenc);
|
static void write_dns(int fd, struct query *q, const char *data, int datalen, char downenc);
|
||||||
static void handle_full_packet(int tun_fd, struct dnsfd *dns_fds, int userid);
|
static void handle_full_packet(int tun_fd, struct dnsfd *dns_fds, int userid);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -2118,7 +2118,7 @@ read_dns(int fd, struct dnsfd *dns_fds, int tun_fd, struct query *q)
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
write_dns_nameenc(char *buf, size_t buflen, char *data, int datalen, char downenc)
|
write_dns_nameenc(char *buf, size_t buflen, const char *data, int datalen, char downenc)
|
||||||
/* Returns #bytes of data that were encoded */
|
/* Returns #bytes of data that were encoded */
|
||||||
{
|
{
|
||||||
static int td1 = 0;
|
static int td1 = 0;
|
||||||
|
@ -2188,7 +2188,7 @@ write_dns_nameenc(char *buf, size_t buflen, char *data, int datalen, char downen
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_dns(int fd, struct query *q, char *data, int datalen, char downenc)
|
write_dns(int fd, struct query *q, const char *data, int datalen, char downenc)
|
||||||
{
|
{
|
||||||
char buf[64*1024];
|
char buf[64*1024];
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
|
@ -230,7 +230,7 @@ putlong(char **dst, uint32_t value)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
putdata(char **dst, char *data, size_t len)
|
putdata(char **dst, const char *data, size_t len)
|
||||||
{
|
{
|
||||||
memcpy(*dst, data, len);
|
memcpy(*dst, data, len);
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ putdata(char **dst, char *data, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
puttxtbin(char **buf, size_t bufremain, char *from, size_t fromremain)
|
puttxtbin(char **buf, size_t bufremain, const char *from, size_t fromremain)
|
||||||
{
|
{
|
||||||
unsigned char uc;
|
unsigned char uc;
|
||||||
unsigned char *ucp = &uc;
|
unsigned char *ucp = &uc;
|
||||||
|
|
|
@ -28,7 +28,7 @@ int putname(char **, size_t, const char *);
|
||||||
int putbyte(char **, unsigned char);
|
int putbyte(char **, unsigned char);
|
||||||
int putshort(char **, unsigned short);
|
int putshort(char **, unsigned short);
|
||||||
int putlong(char **, uint32_t);
|
int putlong(char **, uint32_t);
|
||||||
int putdata(char **, char *, size_t);
|
int putdata(char **, const char *, size_t);
|
||||||
int puttxtbin(char **, size_t, char *, size_t);
|
int puttxtbin(char **, size_t, const char *, size_t);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -161,7 +161,7 @@ int find_available_user(void)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void user_switch_codec(int userid, struct encoder *enc)
|
void user_switch_codec(int userid, const struct encoder *enc)
|
||||||
{
|
{
|
||||||
if (userid < 0 || userid >= usercount)
|
if (userid < 0 || userid >= usercount)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -51,7 +51,7 @@ struct tun_user {
|
||||||
struct packet inpacket;
|
struct packet inpacket;
|
||||||
struct packet outpacket;
|
struct packet outpacket;
|
||||||
int outfragresent;
|
int outfragresent;
|
||||||
struct encoder *encoder;
|
const struct encoder *encoder;
|
||||||
char downenc;
|
char downenc;
|
||||||
int out_acked_seqno;
|
int out_acked_seqno;
|
||||||
int out_acked_fragment;
|
int out_acked_fragment;
|
||||||
|
@ -84,7 +84,7 @@ const char* users_get_first_ip(void);
|
||||||
int find_user_by_ip(uint32_t);
|
int find_user_by_ip(uint32_t);
|
||||||
int all_users_waiting_to_send(void);
|
int all_users_waiting_to_send(void);
|
||||||
int find_available_user(void);
|
int find_available_user(void);
|
||||||
void user_switch_codec(int userid, struct encoder *enc);
|
void user_switch_codec(int userid, const struct encoder *enc);
|
||||||
void user_set_conn_type(int userid, enum connection c);
|
void user_set_conn_type(int userid, enum connection c);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue