2 * MIME functions for netfilter modules. This file provides implementations
3 * for basic MIME parsing. MIME headers are used in many protocols, such as
4 * HTTP, RTSP, SIP, etc.
6 * gcc will warn for defined but unused functions, so we only include the
7 * functions requested. The following macros are used:
8 * NF_NEED_MIME_NEXTLINE nf_mime_nextline()
10 #ifndef _NETFILTER_MIME_H
11 #define _NETFILTER_MIME_H
13 /* Only include these functions for kernel code. */
16 #include <linux/ctype.h>
19 * Given a buffer and length, advance to the next line and mark the current
20 * line. If the current line is empty, *plinelen will be set to zero. If
21 * not, it will be set to the actual line length (including CRLF).
23 * 'line' in this context means logical line (includes LWS continuations).
24 * Returns 1 on success, 0 on failure.
26 #ifdef NF_NEED_MIME_NEXTLINE
28 nf_mime_nextline(char* p
, uint len
, uint
* poff
, uint
* plineoff
, uint
* plinelen
)
32 int is_first_line
= 1;
41 while (p
[off
] != '\n')
52 /* if we saw a crlf, physlen needs adjusted */
53 if (physlen
> 0 && p
[off
] == '\n' && p
[off
-1] == '\r')
58 /* advance past the newline */
61 /* check for an empty line */
67 /* check for colon on the first physical line */
71 if (memchr(p
+(*poff
), ':', physlen
) == NULL
)
77 while (p
[off
] == ' ' || p
[off
] == '\t');
80 *plinelen
= (physlen
== 0) ? 0 : (off
- *poff
);
85 #endif /* NF_NEED_MIME_NEXTLINE */
87 #endif /* __KERNEL__ */
89 #endif /* _NETFILTER_MIME_H */