插入代码需要用listings包,\usepackage{listings}
插入图片需要用\usepackage{graphics}
例子:
\begin{lstlisting}[caption={发送伪造的IP数据包}, label=snoof:code:send_raw_ip_packet] /************************************************************* Given an IP packet, send it out using a raw socket. **************************************************************/ void send_raw_ip_packet(struct ipheader* ip) { struct sockaddr_in dest_info; int enable = 1; // Step 1: Create a raw network socket. int sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); // Step 2: Set socket option. setsockopt(sock, IPPROTO_IP, IP_HDRINCL, &enable, sizeof(enable)); // Step 3: Provide needed information about destination. dest_info.sin_family = AF_INET; dest_info.sin_addr = ip->iph_destip; // Step 4: Send the packet out. sendto(sock, ip, ntohs(ip->iph_len), 0, (struct sockaddr *)&dest_info, sizeof(dest_info)); close(sock); } \end{lstlisting}如果需要排序,带点的排序效果的例子:
\begin{itemize} \item \textbf{第一步:开启有效的pcap会话(\ding{192}行)。}……。 \item \textbf{第二步:设置过滤器(\ding{193}和\ding{194}行)。}……。 \item \textbf{第三步:捕获数据包(\ding{195}行)。} ……。
\end{itemize}
\ding{192}表示①需要包\usepackage{pifont}
带序号的排序例子:
\begin{enumerate} \item \textbf{原始套接字创建:}……。 \item \textbf{协议选择:}……。 \item \textbf{开启混杂模式:}…… \item \textbf{等待数据包:}……
\end{enumerate}。
