src/main/java/org/jivesoftware/smack/Connection.java
public void addPacketInterceptor(PacketInterceptor packetInterceptor,
            PacketFilter packetFilter) {
        if (packetInterceptor == null) {
            throw new NullPointerException("Packet interceptor is null.");
        }
        interceptors.put(packetInterceptor, new InterceptorWrapper(
                packetInterceptor, packetFilter));
    }
public void addPacketInterceptor(PacketInterceptor packetInterceptor,
            PacketFilter packetFilter) {
        if (packetInterceptor == null) {
            throw new NullPointerException("Packet interceptor is null.");
        }
        interceptors.put(packetInterceptor, new InterceptorWrapper(
                packetInterceptor, packetFilter));
    }
Registers a packet interceptor with this connection. The interceptor will
be invoked every time a packet is about to be sent by this connection.
Interceptors may modify the packet to be sent. A packet filter determines
which packets will be delivered to the interceptor.

<p>
NOTE: For a similar functionality on incoming packets, see
{@link #addPacketListener(PacketListener, PacketFilter)}.

@param packetInterceptor
the packet interceptor to notify of packets about to be sent.
@param packetFilter
the packet filter to use.